* Array of short values
@ 2007-02-14 15:41 Christoph Bartoschek
2007-02-14 15:43 ` Frederic RISS
2007-02-14 15:51 ` Daniel Jacobowitz
0 siblings, 2 replies; 5+ messages in thread
From: Christoph Bartoschek @ 2007-02-14 15:41 UTC (permalink / raw)
To: gdb
Hi,
is it possible to easily set an array of short as a convenience variable?
set $arr = (short *) {1, 2, 3}
Currently I have to use:
set $arr = (short *) {0x00020001, 0x00000003}
Greetings,
Christoph
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: Array of short values 2007-02-14 15:41 Array of short values Christoph Bartoschek @ 2007-02-14 15:43 ` Frederic RISS 2007-02-14 15:51 ` Daniel Jacobowitz 1 sibling, 0 replies; 5+ messages in thread From: Frederic RISS @ 2007-02-14 15:43 UTC (permalink / raw) To: Christoph Bartoschek; +Cc: gdb On Wed, 2007-02-14 at 16:32 +0100, Christoph Bartoschek wrote: > Hi, > > is it possible to easily set an array of short as a convenience variable? > > set $arr = (short *) {1, 2, 3} > > Currently I have to use: > > set $arr = (short *) {0x00020001, 0x00000003} try set $arr = {(short)1, (short)2, (short)3} Not very convenient, but it should work Fred. ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Array of short values 2007-02-14 15:41 Array of short values Christoph Bartoschek 2007-02-14 15:43 ` Frederic RISS @ 2007-02-14 15:51 ` Daniel Jacobowitz 2007-02-14 17:47 ` Christoph Bartoschek 1 sibling, 1 reply; 5+ messages in thread From: Daniel Jacobowitz @ 2007-02-14 15:51 UTC (permalink / raw) To: Christoph Bartoschek; +Cc: gdb On Wed, Feb 14, 2007 at 04:32:08PM +0100, Christoph Bartoschek wrote: > Hi, > > is it possible to easily set an array of short as a convenience variable? > > set $arr = (short *) {1, 2, 3} > > Currently I have to use: > > set $arr = (short *) {0x00020001, 0x00000003} I don't think so. { (short) 1, (short) 2 } should work, though. Maybe someone will add C99 support to the C parser some day, and improve this along the way. Just so you know: this is probably not doing what you expect. Try "print $arr". In fact it's probably calling malloc() in the program, allocating memory, and stuffing your shorts there. I did some experimenting with this but got too confused by the parser - I'll be back to it, since it's related to my recent Python project. -- Daniel Jacobowitz CodeSourcery ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Array of short values 2007-02-14 15:51 ` Daniel Jacobowitz @ 2007-02-14 17:47 ` Christoph Bartoschek 2007-02-15 8:53 ` Michael Snyder 0 siblings, 1 reply; 5+ messages in thread From: Christoph Bartoschek @ 2007-02-14 17:47 UTC (permalink / raw) To: gdb Am Mittwoch, 14. Februar 2007 schrieb Daniel Jacobowitz: > On Wed, Feb 14, 2007 at 04:32:08PM +0100, Christoph Bartoschek wrote: > > Hi, > > > > is it possible to easily set an array of short as a convenience variable? > > > > set $arr = (short *) {1, 2, 3} > > > > Currently I have to use: > > > > set $arr = (short *) {0x00020001, 0x00000003} > > I don't think so. { (short) 1, (short) 2 } should work, though. > Maybe someone will add C99 support to the C parser some day, and > improve this along the way. > > Just so you know: this is probably not doing what you expect. Try > "print $arr". In fact it's probably calling malloc() in the program, > allocating memory, and stuffing your shorts there. I did some > experimenting with this but got too confused by the parser - I'll be > back to it, since it's related to my recent Python project. I would not expect that it calls malloc within the program, because malloc could be broken during a debugging session. But I guess there are not many other possibilities left. Thanks to you and Frederic. Christoph ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Array of short values 2007-02-14 17:47 ` Christoph Bartoschek @ 2007-02-15 8:53 ` Michael Snyder 0 siblings, 0 replies; 5+ messages in thread From: Michael Snyder @ 2007-02-15 8:53 UTC (permalink / raw) To: Christoph Bartoschek; +Cc: gdb On Wed, 2007-02-14 at 17:06 +0100, Christoph Bartoschek wrote: > Am Mittwoch, 14. Februar 2007 schrieb Daniel Jacobowitz: > > On Wed, Feb 14, 2007 at 04:32:08PM +0100, Christoph Bartoschek wrote: > > > Hi, > > > > > > is it possible to easily set an array of short as a convenience variable? > > > > > > set $arr = (short *) {1, 2, 3} > > > > > > Currently I have to use: > > > > > > set $arr = (short *) {0x00020001, 0x00000003} > > > > I don't think so. { (short) 1, (short) 2 } should work, though. > > Maybe someone will add C99 support to the C parser some day, and > > improve this along the way. > > > > Just so you know: this is probably not doing what you expect. Try > > "print $arr". In fact it's probably calling malloc() in the program, > > allocating memory, and stuffing your shorts there. I did some > > experimenting with this but got too confused by the parser - I'll be > > back to it, since it's related to my recent Python project. > > I would not expect that it calls malloc within the program, because malloc > could be broken during a debugging session. But I guess there are not many > other possibilities left. For good or ill, gdb relies heavily on target malloc(). Any time you create a string or an array, gdb gets the target memory by calling malloc. set var mycharptr = "hello" will call malloc. ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2007-02-15 1:03 UTC | newest] Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2007-02-14 15:41 Array of short values Christoph Bartoschek 2007-02-14 15:43 ` Frederic RISS 2007-02-14 15:51 ` Daniel Jacobowitz 2007-02-14 17:47 ` Christoph Bartoschek 2007-02-15 8:53 ` Michael Snyder
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox