* Turning off printing of char pointer contents
@ 2007-05-31 22:38 Ray Bejjani
2007-05-31 22:44 ` Jason Molenda
2007-05-31 22:48 ` Jim Blandy
0 siblings, 2 replies; 6+ messages in thread
From: Ray Bejjani @ 2007-05-31 22:38 UTC (permalink / raw)
To: gdb
Hi,
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?
Thank you,
Ray Bejjani
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Turning off printing of char pointer contents
2007-05-31 22:38 Turning off printing of char pointer contents Ray Bejjani
@ 2007-05-31 22:44 ` Jason Molenda
2007-05-31 22:48 ` Jim Blandy
1 sibling, 0 replies; 6+ messages in thread
From: Jason Molenda @ 2007-05-31 22:44 UTC (permalink / raw)
To: Ray Bejjani; +Cc: gdb
You can limit the amount of data printed, e.g.
(gdb) set print elements 15
But you'll need to unset that limit to see the full contents of
strings during your debug session.
J
On May 31, 2007, at 3:38 PM, Ray Bejjani wrote:
> Hi,
> 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?
>
> Thank you,
> Ray Bejjani
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Turning off printing of char pointer contents
2007-05-31 22:38 Turning off printing of char pointer contents Ray Bejjani
2007-05-31 22:44 ` Jason Molenda
@ 2007-05-31 22:48 ` Jim Blandy
2007-06-01 1:32 ` Ray Bejjani
1 sibling, 1 reply; 6+ messages in thread
From: Jim Blandy @ 2007-05-31 22:48 UTC (permalink / raw)
To: Ray Bejjani; +Cc: gdb
"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.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Turning off printing of char pointer contents
2007-05-31 22:48 ` Jim Blandy
@ 2007-06-01 1:32 ` Ray Bejjani
2007-06-01 13:39 ` Daniel Jacobowitz
0 siblings, 1 reply; 6+ messages in thread
From: Ray Bejjani @ 2007-06-01 1:32 UTC (permalink / raw)
Cc: gdb
Thanks! That should do it. I can set regions, but I cant set (or even
show) the inaccessible-by-default setting . It's in the manual, and
I've tried it with 6.5 and 6.6 (in case it was new) but it simply
doesn't know what it is. I don't know if it matters, but I'm
cross-debugging a coldfire, so maybe it isn't supported (of course, I
cant seem to set it in my x86 one either).
I get:
(gdb) set mem inaccessible-by-default on
No symbol "mem" in current context.
Thanks again, sorry for being quite useless.
On 5/31/07, Jim Blandy <jimb@codesourcery.com> wrote:
>
> "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.
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Turning off printing of char pointer contents
2007-06-01 1:32 ` Ray Bejjani
@ 2007-06-01 13:39 ` Daniel Jacobowitz
2007-06-01 20:07 ` Ray Bejjani
0 siblings, 1 reply; 6+ messages in thread
From: Daniel Jacobowitz @ 2007-06-01 13:39 UTC (permalink / raw)
To: Ray Bejjani; +Cc: gdb
On Thu, May 31, 2007 at 06:32:07PM -0700, Ray Bejjani wrote:
> Thanks! That should do it. I can set regions, but I cant set (or even
> show) the inaccessible-by-default setting . It's in the manual, and
> I've tried it with 6.5 and 6.6 (in case it was new) but it simply
> doesn't know what it is. I don't know if it matters, but I'm
> cross-debugging a coldfire, so maybe it isn't supported (of course, I
> cant seem to set it in my x86 one either).
It's even newer than that. You'll have to grab a CVS snapshot from
the FTP site (or from CVS).
--
Daniel Jacobowitz
CodeSourcery
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Turning off printing of char pointer contents
2007-06-01 13:39 ` Daniel Jacobowitz
@ 2007-06-01 20:07 ` Ray Bejjani
0 siblings, 0 replies; 6+ messages in thread
From: Ray Bejjani @ 2007-06-01 20:07 UTC (permalink / raw)
To: gdb
It worked! Thanks a lot folks!
On 6/1/07, Daniel Jacobowitz <drow@false.org> wrote:
> On Thu, May 31, 2007 at 06:32:07PM -0700, Ray Bejjani wrote:
> > Thanks! That should do it. I can set regions, but I cant set (or even
> > show) the inaccessible-by-default setting . It's in the manual, and
> > I've tried it with 6.5 and 6.6 (in case it was new) but it simply
> > doesn't know what it is. I don't know if it matters, but I'm
> > cross-debugging a coldfire, so maybe it isn't supported (of course, I
> > cant seem to set it in my x86 one either).
>
> It's even newer than that. You'll have to grab a CVS snapshot from
> the FTP site (or from CVS).
>
> --
> Daniel Jacobowitz
> CodeSourcery
>
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2007-06-01 20:07 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-05-31 22:38 Turning off printing of char pointer contents Ray Bejjani
2007-05-31 22:44 ` Jason Molenda
2007-05-31 22:48 ` Jim Blandy
2007-06-01 1:32 ` Ray Bejjani
2007-06-01 13:39 ` Daniel Jacobowitz
2007-06-01 20:07 ` Ray Bejjani
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox