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: Convenience variable for filename in add-symbol-file not expanded


David Lamy-Charrier wrote:
Thanks Andrew,

I already have a static buffer in the inferior program containing the
path to the file I want to use.
You mean that I should declare a pointer to the variable in the
inferior program too ?
And then how can I access the pointed value in gdb, using
value_of_internalvar() or parse_and_eval_address() or anything else) ?

No, I mean you can create a convenience variable with type char*. The command language can be made to substitute convenience variables starting with $, but it seems a little much to expect it to unpick program variables as well.


So, if your string were referenced by an inferior variable 'filename', it would look like:
(gdb) set $name = filename
(gdb) set $address = 0x.....
(gdb) add-symbol-file $name $address


You can then use lookup_internalvar() to get the address and then read the string from memory somehow, get_target_memory() probably (look in target.h for the various options). Of course, there may be a better way ... anyone?

HTH

Andrew


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