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/11036] Python: provide access to "hidden" variables


------- Additional Comments From pmuldoon at redhat dot com  2010-01-19 14:16 -------
I chatted with andre on irc and we came up with this reproducer:

simple.c ----------

#include <stdio.h>

int main() 
{ 
  int i = 0; 
  { 
    double i = 1.0; 
    double f = 2.0;
    { 
      const char *i = "stuff";
      const char *f = "foo";
      const char *b = "bar";
      printf ("break");
    } 
  } 

  return 0;
}

symbol.py -----------------

frame = gdb.selected_frame()
block = frame.block()
count = 0

while True:
    if block is None:
        warn("UNEXPECTED 'None' BLOCK")
        break
    
    print "Block: ",  count
    for symbol in block:
        name = symbol.print_name        
        try:
            item = frame.read_var(name)
        except RuntimeError:
            continue
        print name," (",item.type,") =",item
    if not block.function is None:
        break
        
    block = block.superblock
    count = count + 1

GDB output:

./gdb ./simple -ex 'b 13' -ex 'run' -ex 'python execfile("./symbol.py")'

Breakpoint 1 at 0x400507: file ../../frame/simple.c, line 13.

Breakpoint 1, main () at ../../frame/simple.c:13
13	      printf ("break");

Block:  0
i  ( const char * ) = 0x400618 "stuff"
f  ( const char * ) = 0x40061e "foo"
b  ( const char * ) = 0x400622 "bar"
Block:  1
i  ( const char * ) = 0x400618 "stuff"
f  ( const char * ) = 0x40061e "foo"
Block:  2
i  ( const char * ) = 0x400618 "stuff"


-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|                            |1


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

------- 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]