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

C++ GDB Python Pretty Printing Tutorial?

Check out Tom Tromey’s pretty printing tutorials part 1 and part 2. There is also the libstdc++-v6 pretty printer implementation to look at, which is what I used myself as a template when I started out. A somewhat simpler example (as of this writing) is the Boost pretty printer by RĂ¼diger Sonderfeld.

Disable AVX-optimized functions in glibc (LD_HWCAP_MASK, /etc/ld.so.nohwcap) for valgrind & gdb record

It looks like there is a nice workaround for this implemented in recent versions of glibc: a “tunables” feature that guides selection of optimized string functions. You can find a general overview of this feature here and the relevant code inside glibc in ifunc-impl-list.c. Here’s how I figured it out. First, I took the address … Read more

What exactly is -fno-builtin doing here?

From man gcc -fno-builtin -fno-builtin-function Don’t recognize built-in functions that do not begin with __builtin_ as prefix. GCC normally generates special code to handle certain built-in functions more efficiently; for instance, calls to “alloca” may become single instructions which adjust the stack directly, and calls to “memcpy” may become inline copy loops. The resulting code … 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