public inbox for gdb@sourceware.org
 help / color / mirror / Atom feed
* pretty print beginner question
@ 2011-05-03  4:51 Klaus Rudolph
  2011-05-03 13:36 ` Tom Tromey
  0 siblings, 1 reply; 3+ messages in thread
From: Klaus Rudolph @ 2011-05-03  4:51 UTC (permalink / raw)
  To: gdb

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

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2011-05-03 14:19 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-05-03  4:51 pretty print beginner question Klaus Rudolph
2011-05-03 13:36 ` Tom Tromey
2011-05-03 14:19   ` pretty print beginner question <solved> Klaus Rudolph

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).