* RE: String handling in GDB command language variables
@ 2003-02-27 14:35 Fyles, Matthew
2003-02-27 14:40 ` Daniel Jacobowitz
0 siblings, 1 reply; 6+ messages in thread
From: Fyles, Matthew @ 2003-02-27 14:35 UTC (permalink / raw)
To: Daniel Jacobowitz; +Cc: gdb
When not connected to any target is it possible to store a string value
in a convenience variable.
i.e
sh-superh-elf-gdb -nw
GNU gdb 5.2.1
Copyright 2002 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you
are
welcome to change it and/or distribute copies of it under certain
conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB. Type "show warranty" for
details.
This GDB was configured as "--host=i686-pc-linux-gnu
--target=sh-superh-elf".
(gdb) set $test=1
(gdb) print $test
$1 = 1
(gdb) set $test="hello"
evaluation of this expression requires the target program to be active
(gdb)
can a convenience variable be made to be a string type within the
command language?
-----Original Message-----
From: Daniel Jacobowitz [mailto:drow@mvista.com]
Sent: Thursday, February 27, 2003 2:23 PM
To: Fyles, Matthew
Cc: gdb@sources.redhat.com
Subject: Re: String handling in GDB command language variables
On Thu, Feb 27, 2003 at 09:13:55AM -0000, Fyles, Matthew wrote:
> Just a quick question about the string handling capability of the GDB
> command language.
>
> set $test="mystring" does not work but defining a procedure and
passing
> a string in as an argument does, is there any further documentation
> anywhere about the capabilities of the language other than the
> information available in the user documentation.
>
> Is this a feature that has been considered in the past and not
> implemented or am I just not understanding the syntax for achieving
> this.
When you say "mystring" in the GDB command language, what you really
get is malloc(9) called in the target program and "mystring" copied
into it.
However, you didn't say what version of GDB you were using. I just
tried it in 5.3:
(gdb) set $a = "a"
(gdb) p $a
$1 = 0x8244708 "a"
--
Daniel Jacobowitz
MontaVista Software Debian GNU/Linux Developer
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: String handling in GDB command language variables
2003-02-27 14:35 String handling in GDB command language variables Fyles, Matthew
@ 2003-02-27 14:40 ` Daniel Jacobowitz
2003-02-27 16:43 ` Andrew Cagney
0 siblings, 1 reply; 6+ messages in thread
From: Daniel Jacobowitz @ 2003-02-27 14:40 UTC (permalink / raw)
To: Fyles, Matthew; +Cc: gdb
On Thu, Feb 27, 2003 at 02:35:38PM -0000, Fyles, Matthew wrote:
> When not connected to any target is it possible to store a string value
> in a convenience variable.
>
> i.e
>
> sh-superh-elf-gdb -nw
> GNU gdb 5.2.1
> Copyright 2002 Free Software Foundation, Inc.
> GDB is free software, covered by the GNU General Public License, and you
> are
> welcome to change it and/or distribute copies of it under certain
> conditions.
> Type "show copying" to see the conditions.
> There is absolutely no warranty for GDB. Type "show warranty" for
> details.
> This GDB was configured as "--host=i686-pc-linux-gnu
> --target=sh-superh-elf".
> (gdb) set $test=1
> (gdb) print $test
> $1 = 1
> (gdb) set $test="hello"
> evaluation of this expression requires the target program to be active
> (gdb)
>
> can a convenience variable be made to be a string type within the
> command language?
The command language always mimics the current source language being
debugged, defaulting to C; C doesn't have a string type. That's the
historical justification anyway.
If there's a consensus that a string type would be useful, it could
probably be done. I think it might be a good idea; we could use
strings for arguments to gdb commands, etc. However I'm not sure of
the syntax.
Anyone else out there have an opinion?
--
Daniel Jacobowitz
MontaVista Software Debian GNU/Linux Developer
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: String handling in GDB command language variables
2003-02-27 14:40 ` Daniel Jacobowitz
@ 2003-02-27 16:43 ` Andrew Cagney
2003-02-27 19:06 ` Daniel Jacobowitz
0 siblings, 1 reply; 6+ messages in thread
From: Andrew Cagney @ 2003-02-27 16:43 UTC (permalink / raw)
To: Daniel Jacobowitz; +Cc: Fyles, Matthew, gdb
> The command language always mimics the current source language being
> debugged, defaulting to C; C doesn't have a string type. That's the
> historical justification anyway.
>
> If there's a consensus that a string type would be useful, it could
> probably be done. I think it might be a good idea; we could use
> strings for arguments to gdb commands, etc. However I'm not sure of
> the syntax.
DanielJ's comment, GDB's current behavior is to always a malloc(), store
the value in the target, and then create a `char *' `struct value'.
Is there anything in the `rule book' that says that GDB can be lazy
(when given "string" create a `char[]' `struct value' and then only
allocate space / create the pointer when the value is needed by the
target)? Is this trivial? Is this needed?
"no"? "no"? "yes"?
Andrew
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: String handling in GDB command language variables
2003-02-27 16:43 ` Andrew Cagney
@ 2003-02-27 19:06 ` Daniel Jacobowitz
0 siblings, 0 replies; 6+ messages in thread
From: Daniel Jacobowitz @ 2003-02-27 19:06 UTC (permalink / raw)
To: gdb
On Thu, Feb 27, 2003 at 11:45:57AM -0500, Andrew Cagney wrote:
>
> >The command language always mimics the current source language being
> >debugged, defaulting to C; C doesn't have a string type. That's the
> >historical justification anyway.
> >
> >If there's a consensus that a string type would be useful, it could
> >probably be done. I think it might be a good idea; we could use
> >strings for arguments to gdb commands, etc. However I'm not sure of
> >the syntax.
>
> DanielJ's comment, GDB's current behavior is to always a malloc(), store
> the value in the target, and then create a `char *' `struct value'.
>
> Is there anything in the `rule book' that says that GDB can be lazy
> (when given "string" create a `char[]' `struct value' and then only
> allocate space / create the pointer when the value is needed by the
> target)? Is this trivial? Is this needed?
>
> "no"? "no"? "yes"?
Those are my guesses, too. I think that this change could also be
related to the kfail in our testsuite dealing with character array
types...
--
Daniel Jacobowitz
MontaVista Software Debian GNU/Linux Developer
^ permalink raw reply [flat|nested] 6+ messages in thread
* String handling in GDB command language variables
@ 2003-02-27 9:13 Fyles, Matthew
2003-02-27 14:23 ` Daniel Jacobowitz
0 siblings, 1 reply; 6+ messages in thread
From: Fyles, Matthew @ 2003-02-27 9:13 UTC (permalink / raw)
To: gdb
Just a quick question about the string handling capability of the GDB
command language.
set $test="mystring" does not work but defining a procedure and passing
a string in as an argument does, is there any further documentation
anywhere about the capabilities of the language other than the
information available in the user documentation.
Is this a feature that has been considered in the past and not
implemented or am I just not understanding the syntax for achieving
this.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: String handling in GDB command language variables
2003-02-27 9:13 Fyles, Matthew
@ 2003-02-27 14:23 ` Daniel Jacobowitz
0 siblings, 0 replies; 6+ messages in thread
From: Daniel Jacobowitz @ 2003-02-27 14:23 UTC (permalink / raw)
To: Fyles, Matthew; +Cc: gdb
On Thu, Feb 27, 2003 at 09:13:55AM -0000, Fyles, Matthew wrote:
> Just a quick question about the string handling capability of the GDB
> command language.
>
> set $test="mystring" does not work but defining a procedure and passing
> a string in as an argument does, is there any further documentation
> anywhere about the capabilities of the language other than the
> information available in the user documentation.
>
> Is this a feature that has been considered in the past and not
> implemented or am I just not understanding the syntax for achieving
> this.
When you say "mystring" in the GDB command language, what you really
get is malloc(9) called in the target program and "mystring" copied
into it.
However, you didn't say what version of GDB you were using. I just
tried it in 5.3:
(gdb) set $a = "a"
(gdb) p $a
$1 = 0x8244708 "a"
--
Daniel Jacobowitz
MontaVista Software Debian GNU/Linux Developer
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2003-02-27 19:06 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-02-27 14:35 String handling in GDB command language variables Fyles, Matthew
2003-02-27 14:40 ` Daniel Jacobowitz
2003-02-27 16:43 ` Andrew Cagney
2003-02-27 19:06 ` Daniel Jacobowitz
-- strict thread matches above, loose matches on Subject: below --
2003-02-27 9:13 Fyles, Matthew
2003-02-27 14:23 ` Daniel Jacobowitz
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox