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]

pretty print beginner question


Hi again,

after I heared that gdb.printing is comming with gdb 7.3 and we using the last release 7.2 I tried other examples from the older manual, but without any result?

I have a file printer.py:
class StdStringPrinter(object):
    "Print a std::string"

def __init__(self, val):
    self.val = val 

def to_string(self):
    return self.val['_M_dataplus']['_M_p']

def display_hint(self):
    return 'string'


def str_lookup_function(val):
    lookup_tag = val.type.tag
    if lookup_tag == None:
        return None
    regex = re.compile("^std::basic_string<char,.*>$")
    if regex.match(lookup_tag):
        return StdStringPrinter(val)
    return None

def register_printers(objfile):
   objfile.pretty_printers.add(str_lookup_function)


source it from the gdb prompt: source printer.py

have a little c++ prog with a std::string s

if i do a "print s" the output is as without printer.py

Can anyone give a short complete and running example how to write and load and setup a first pretty printer for any kind of data...

It is hard to fill the gaps in the manual :-(

Thanks
 Klaus


-- 
Empfehlen Sie GMX DSL Ihren Freunden und Bekannten und wir
belohnen Sie mit bis zu 50,- Euro! https://freundschaftswerbung.gmx.de


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