This is the mail archive of the gdb@sources.redhat.com 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]

Persitance of .gdbinit variables


Hi,

I'm working on writing a bunch of user commands for my .gdbinit. However
the first time I run the command I want to insert a breakpoint into a
piece of code. I'm using some convenience variables to maintain state
thus:

[extracts from my .gdinit]
#
# Globally set some convenience variables we use to determine state
# and the like.
#
set $gcbp=0
set $gcbp_hook=0
set $foo=1234

printf "Set gcbp to %d\n", $gcbp
printf "Set gcbp_hook to %d\n", $gcbp_hook
printf "Set foo to %d\n", $foo

define gcb
   if $gcbp==0
       set $gcbp=$arg0
       if $gcbp_hook==0
           install_gcbp_hook
       end
   else
       print "Can't set new GC Breakpoint until 0x%x set", $gcbp    
   end
end
[end extracts]

When I start up gdb I can see the variables set however running gcb
fails with an Invalid type test because the variables have lost there
values:

[run]
16:04 alex@xxxxx >gdb -x gdb_dirs --args myprog
GNU gdb 5.3
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 "i386-pc-solaris2.9"...Set gcbp to 0
Set gcbp_hook to 0
Set foo to 1234
 
(gdb) gcb 0xdb570b24
Invalid type combination in equality test.
(gdb) p $gcbp_hook
$1 = void
(gdb) p $gcbp
$2 = void
(gdb)
[end of run]

Is this expected behaviour? 
Is there a way to ensure variables exist after .gdbinit has loaded?
Failing that is there a way to test if a value in undefined/void so I
can just setup at that point?

-- 
Alex Bennee <kernel-hacker@bennee.com>


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