Bugzilla – Attachment 43843 Details for
Bug 34745
Implementation of python gdb helpers
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
Work in progress prettyprinting hooks for (String*)
libreoffice.py (text/plain), 1.20 KB, created by
Dave Malcolm
on 2011-02-25 17:13:41 UTC
(
hide
)
Description:
Work in progress prettyprinting hooks for (String*)
Filename:
MIME Type:
Creator:
Dave Malcolm
Created:
2011-02-25 17:13:41 UTC
Size:
1.20 KB
patch
obsolete
>import gdb > >class StringPrinter(object): > def __init__(self, val): > # "val" is a gdb.Value representing a (String *) in the inferior > # process > self.val = val > > def to_string(self): > if 0 == long(self.val): > return 'NULL' > mpData = self.val['mpData'] > length = int(mpData['mnLen']) > > # Safety limit: don't send gdb into a long loop if it encounters corrupt data: > length = min(length, 1024) > # print repr(length) > maStr = mpData['maStr'] # microoptimization > # print maStr > > # FIXME: this assumes ASCII > result = ''.join([chr(int(maStr[i])) > for i in xrange(length)]) > return "String(%r)" % result > > >def pretty_printer_lookup(gdbval): > # Only for types that are "String *" > type = gdbval.type.unqualified() > if type.code == gdb.TYPE_CODE_PTR: > type = type.target().unqualified() > t = str(type) > if t in ("String"): > return StringPrinter(gdbval) > >def register (obj): > if obj == None: > obj = gdb > > # Wire up the pretty-printer > obj.pretty_printers.append(pretty_printer_lookup) > >register (gdb.current_objfile ()) > > >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 34745
: 43843 |
43844
|
44461