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

[Bug python/11482] Side effect of set print address on python API


------- Additional Comments From pmuldoon at redhat dot com  2010-04-14 20:05 -------
str() is not being affected by 'set print address on'. str() is converting a
Python variable to a string.  But if there is nothing to convert there is
nothing to convert. ;)

Take these examples.  In this (your) case the string is the address itself:

(gdb) python print gdb.selected_frame().read_var("argv")
0x7fffffffe1a8
(gdb) python print len(str(gdb.selected_frame().read_var("argv")))
14

'0x7fffffffe1a8' is 14 characters long.  You get the address as a value because
of the type (char **). If you want what that points to you have to dereference
it.  So in this example, when you 'set print address off', you are telling GDB
not to print addresses. So in this case it would be:

(gdb) python print gdb.selected_frame().read_var("argv")

(gdb) python print len(str(gdb.selected_frame().read_var("argv")))
0

Because there is nothing to print in that case.  str() has nothing to work with.
You told GDB not to print addresses, and the value of char ** type is an
address. The Python scripting has to abide by the rules set down by GDB, and set
by the user through the 'set foo' commands.

So if the value of a read_var is an address should we print it regardless of
what the user told GDB to do? I think we should abide by the options set down at
this point.

There might be a case for read_var always dereferencing what it reads, but I'm
not keen on that.  IMO, everything is working as it should?




-- 


http://sourceware.org/bugzilla/show_bug.cgi?id=11482

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.


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