This is the mail archive of the gdb@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Turning off printing of char pointer contents


"Ray Bejjani" <ray.bejjani@gmail.com> writes:
> I'm trying to turn off printing the contents of char pointers. I'm use
> GDB to debug an embedded app remotely. In some instances the pointers
> are left uninitialised and can point to sections of memory that cause
> system crashes when accessed (or they cause external hardware to
> change state when read). I am using DDD on top of GDB but I can
> reproduce the issue with GDB as well. GDB seems to treat C strings in
> a special manner, attempting to print the contents until it sees an
> null terminator or hit the limit set by the "print elements" setting.
> My system crashes when this happens.
> Unfortunately, doing a set print elements 0 is interpreted as no
> limit. Are there any other settings I can use to suppress this
> feature? In particular, I would like it to treat char (or unsigned
> char) pointers like it does other pointers where it doesn't attempt to
> dereference them. I would still like to be able to display/print the
> contents of strings when needed but only on demand. Failing that,
> where in the code should I look to try and force this to not happen?

Have you looked at "Memory region attributes" in the GDB manual?  You
can define memory regions, and then use 'set mem
inaccessible-by-default' to tell GDB not to touch memory regions you
haven't defined.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]