* Can back trace be stopped from always prints "char*" strings ?
@ 2008-03-12 11:50 Chris Johns
2008-03-12 14:00 ` Daniel Jacobowitz
2008-03-12 20:15 ` Michael Snyder
0 siblings, 2 replies; 6+ messages in thread
From: Chris Johns @ 2008-03-12 11:50 UTC (permalink / raw)
To: gdb
Hello,
I have a union being passed to a function. The union is:
typedef union {
/** This is a pointer to a string name. */
const char *name_p;
/** This is the actual 32-bit "raw" integer name. */
uint32_t name_u32;
} Objects_Name;
The problem is the bt command ties to read the string pointed to by name_p
how-ever this can be any value if the name_u32 field has been set. This has
side effects on the embedded target I am using like killing the session.
Is there a way to stop the bt accessing the char* data and just printing the
pointer value ?
Regards
Chris
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: Can back trace be stopped from always prints "char*" strings ?
2008-03-12 11:50 Can back trace be stopped from always prints "char*" strings ? Chris Johns
@ 2008-03-12 14:00 ` Daniel Jacobowitz
2008-03-12 14:23 ` Paul Koning
2008-03-12 15:05 ` Thiago Jung Bauermann
2008-03-12 20:15 ` Michael Snyder
1 sibling, 2 replies; 6+ messages in thread
From: Daniel Jacobowitz @ 2008-03-12 14:00 UTC (permalink / raw)
To: Chris Johns; +Cc: gdb
On Wed, Mar 12, 2008 at 08:13:51PM +1100, Chris Johns wrote:
> Is there a way to stop the bt accessing the char* data and just printing
> the pointer value ?
I don't think there is. You might want to look at "set mem
inaccessible-by-default" and the "mem" command; that's good for
preventing stray memory reads.
--
Daniel Jacobowitz
CodeSourcery
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Can back trace be stopped from always prints "char*" strings ?
2008-03-12 14:00 ` Daniel Jacobowitz
@ 2008-03-12 14:23 ` Paul Koning
2008-03-13 18:13 ` Chris Johns
2008-03-12 15:05 ` Thiago Jung Bauermann
1 sibling, 1 reply; 6+ messages in thread
From: Paul Koning @ 2008-03-12 14:23 UTC (permalink / raw)
To: drow; +Cc: chrisj, gdb
>>>>> "Daniel" == Daniel Jacobowitz <drow@false.org> writes:
Daniel> On Wed, Mar 12, 2008 at 08:13:51PM +1100, Chris Johns wrote:
>> Is there a way to stop the bt accessing the char* data and just
>> printing the pointer value ?
Daniel> I don't think there is. You might want to look at "set mem
Daniel> inaccessible-by-default" and the "mem" command; that's good
Daniel> for preventing stray memory reads.
Another possibility: if the embedded target dies when this happens,
that may mean it's getting an addressing error and not handling that.
The target stub should validate addresses it's given and reject any
that are out of range. It also would make sense for it to intercept
any access errors that make it past those range checks and turn them
into error messages back to gdb instead.
paul
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: Can back trace be stopped from always prints "char*" strings ?
2008-03-12 14:23 ` Paul Koning
@ 2008-03-13 18:13 ` Chris Johns
0 siblings, 0 replies; 6+ messages in thread
From: Chris Johns @ 2008-03-13 18:13 UTC (permalink / raw)
To: Paul Koning; +Cc: drow, gdb
Paul Koning wrote:
>>>>>> "Daniel" == Daniel Jacobowitz <drow@false.org> writes:
>
> Daniel> On Wed, Mar 12, 2008 at 08:13:51PM +1100, Chris Johns wrote:
> >> Is there a way to stop the bt accessing the char* data and just
> >> printing the pointer value ?
>
> Daniel> I don't think there is. You might want to look at "set mem
> Daniel> inaccessible-by-default" and the "mem" command; that's good
> Daniel> for preventing stray memory reads.
>
This is working so I am able to move forward. Thanks. I wonder if it is such a
good idea for GDB to display the string a char* points to by default when
handling a union.
> Another possibility: if the embedded target dies when this happens,
> that may mean it's getting an addressing error and not handling that.
> The target stub should validate addresses it's given and reject any
> that are out of range. It also would make sense for it to intercept
> any access errors that make it past those range checks and turn them
> into error messages back to gdb instead.
This may work for a stub running on the target. I have a gdbserver talking
over USB to a BDM pod connected to a Coldfire. The gdbserver knows nothing
about the target memory map and I am not sure it should need to know. I think
the mem command is a good idea. Thank for the idea.
Regards
Chris
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Can back trace be stopped from always prints "char*" strings ?
2008-03-12 14:00 ` Daniel Jacobowitz
2008-03-12 14:23 ` Paul Koning
@ 2008-03-12 15:05 ` Thiago Jung Bauermann
1 sibling, 0 replies; 6+ messages in thread
From: Thiago Jung Bauermann @ 2008-03-12 15:05 UTC (permalink / raw)
To: Daniel Jacobowitz; +Cc: Chris Johns, gdb
On Wed, 2008-03-12 at 08:33 -0400, Daniel Jacobowitz wrote:
> On Wed, Mar 12, 2008 at 08:13:51PM +1100, Chris Johns wrote:
> > Is there a way to stop the bt accessing the char* data and just printing
> > the pointer value ?
>
> I don't think there is. You might want to look at "set mem
> inaccessible-by-default" and the "mem" command; that's good for
> preventing stray memory reads.
I think the newly introduced "set print frame-arguments" would help
here. It went in after GDB 6.7 though.
--
[]'s
Thiago Jung Bauermann
Software Engineer
IBM Linux Technology Center
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Can back trace be stopped from always prints "char*" strings ?
2008-03-12 11:50 Can back trace be stopped from always prints "char*" strings ? Chris Johns
2008-03-12 14:00 ` Daniel Jacobowitz
@ 2008-03-12 20:15 ` Michael Snyder
1 sibling, 0 replies; 6+ messages in thread
From: Michael Snyder @ 2008-03-12 20:15 UTC (permalink / raw)
To: Chris Johns; +Cc: gdb
On Wed, 2008-03-12 at 20:13 +1100, Chris Johns wrote:
> Hello,
>
> I have a union being passed to a function. The union is:
>
> typedef union {
> /** This is a pointer to a string name. */
> const char *name_p;
> /** This is the actual 32-bit "raw" integer name. */
> uint32_t name_u32;
> } Objects_Name;
>
> The problem is the bt command ties to read the string pointed to by name_p
> how-ever this can be any value if the name_u32 field has been set. This has
> side effects on the embedded target I am using like killing the session.
>
> Is there a way to stop the bt accessing the char* data and just printing the
> pointer value ?
Close...
The closest we have is "set print elements", which will set a limit
on how many elements of an array (including a string) are printed
by default. Unfortunately, zero has been used to mean "no limit",
otherwise it would do exactly what you want.
If you "set print elements 1", it will only print the first byte
of the string -- maybe that will help?
Gosh guys, it would mean changing documented behavior, but maybe
we ought to consider making zero mean zero, and maybe making -1
mean "unlimited"...
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2008-03-13 3:56 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-03-12 11:50 Can back trace be stopped from always prints "char*" strings ? Chris Johns
2008-03-12 14:00 ` Daniel Jacobowitz
2008-03-12 14:23 ` Paul Koning
2008-03-13 18:13 ` Chris Johns
2008-03-12 15:05 ` Thiago Jung Bauermann
2008-03-12 20:15 ` Michael Snyder
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox