This is the mail archive of the gdb@sourceware.org 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]

Re: GDB Script predefined variables


Rob Quill wrote:
I was wondering what predefined variables, if any, there are in GDB,
that can be used when writing a GDB script. Specifically, I want the
script to be able to test when the program has finished executing, but
any other predefined variables would also be useful, if there is a
list somewhere or someone knows them all.

To show all GDB variables, predefined or otherwise:


(gdb) show conv

For your specific needs, there is a variable '$_exitcode' defined after the program exits (it does not exist before).

If you try to test a GDB convenience variable before it exists, GDB will create it for you, but it does not initialise it (the value will be 'void'). I'm not sure it is an official feature, but the following comparison works:

if $_exitcode == (void)0
  echo program not finished\n
end

The value of the void is not significant - it is just to make the expression valid.

HTH

Andrew


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