I am using GDB from a console in a pre-configured environment and the version that it provides has a few bugs. The most annoying one is that, sometimes, when stepping into functions or adding breakpoints or printing the call stack, it spews out hundreds of consecutive lines similar to this one:
warning: Range for type (null) has invalid bounds 0..-103
The only reference I could find for this issue is here and it isn't helpful.
Given the above, I thought it should be simple to either
instruct GDB to suppress such warnings - looks like a dead end. As far as I can tell, GDB doesn't allow users to suppress such warnings.
intercept them in a hook via .gdbinit - seems promising. I was able to change the terminal colour, for example, by poking through the .gdbinit file referenced in this answer. Unfortunately, I couldn't find any hook in the documentation that would be useful for my purpose.
filter the warnings (maybe via some sort of proxy between stdout and GDB) - feels hackish, but I wouldn't mind doing this, if it would somehow work. A stupid attempt was to redirect stderr to
/dev/null
like so:gdb -p xxxxxx 2> /dev/null
, but it looks like the warnings are actually pushed to stdout. Bummer. Then I also thought that maybe I could do something silly such as filtering stdout via grep like sogdb -p xxxxxx | grep -v ^warning
, but this seems to have the unwanted side effect of making the terminal prompt invisible for some reason.
Does anyone have some idea what could work? I searched quite a lot for something that might help me implement the 3rd idea, but, so far, I came out empty-handed...