Input redirection in gdb (MinGW)

As far back as the late ’90s, broken command line redirection was a known and assumed limitation. My suspicion is that it remains that way, since the mingw32 port of gdb still gleefully passes on verbatim all run arguments (including redirects) to the debugee. Several possible workarounds: if you have the option to alter the … Read more

Force gdb to load shared library at randomized address

Is there any way to disable this gdb’s feature? Yes, you can set disable-randomization off before running the program. See this part of gdb documentation: set disable-randomization off Leave the behavior of the started executable unchanged. Some bugs rear their ugly heads only when the program is loaded at certain addresses. If your bug disappears … Read more

How to do bidirectional or reverse debugging of programs?

The latest gdb version 7.0 (released this week) supports reverse debugging on a number of platforms (eg. native i386 and x86_64 linux, VMware workstation, UndoDB, and Simics simulators from Virtutech). ftp://ftp.gnu.org/pub/gdb It works with the latest preview / pre-release of VMware workstation 7.0, which also supports reverse debugging of MSWindows guests using Visual Studio debugger. … Read more

Use gdb to Modify Binary

but the corresponding file is not changed. It’s hard to say what address you are actually modifying, and so whether your change should actually modify the binary or not. In the past, I’ve found that after modifying the binary, I need to immediately quit. If I do anything other than quit (e.g. run), then GDB … Read more

How to run record instruction-history and function-call-history in GDB?

It seems that there is no other solution except a CPU that supports it. More precisely, your kernel has to support Intel Processor Tracing (Intel PT). This can be checked in Linux with: grep intel_pt /proc/cpuinfo See also: https://unix.stackexchange.com/questions/43539/what-do-the-flags-in-proc-cpuinfo-mean The commands only works in record btrace mode. In the GDB source commit beab5d9, it is … Read more

Adding gdb to MinGW

In a command prompt I browsed to C:\MinGW\bin and ran: mingw-get.exe install gdb That fixed it for me. Not sure if it matters but I have C:\MinGW\bin in my path (guess I probably didn’t need to browse to C:\MinGW\bin).

GDB kind of doesn’t work on macOS Sierra

This is how I easily fixed the issue. [Update: based on feedback received and yet to be verified, it seems that this solution works with macOS Sierra 10.12 but not with macOS Sierra 10.12.2] See video instructions here Quit gdb Using your text editor e.g. Sublime Text, save a file called .gdbinit in your user … Read more

What does mean in gdb?

It means you compiled with e.g. gcc -O3 and the gcc optimiser found that some of your variables were redundant in some way that allowed them to be optimised away. In this particular case you appear to have three variables a, b, c with the same value and presumably they can all be aliassed to … Read more