From a6a181a303aeebb013d5237bfc8dd8b3b12aea50 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sat, 28 Apr 2012 22:24:52 +0000 Subject: [PATCH] Add a gdb pretty-printer for wxFileName objects. This pretty-printer works by calling the C++ wxFileName::GetFullPath() directly instead of interpreting the object data from gdb because this is much simpler to do, so it can only be used when debugging live programs. If this is a serious restriction, it would need to be changed to use gdb data access only later. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@71303 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- misc/gdb/print.py | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/misc/gdb/print.py b/misc/gdb/print.py index 8e19a57..2618686 100755 --- a/misc/gdb/print.py +++ b/misc/gdb/print.py @@ -39,6 +39,19 @@ class wxDateTimePrinter: sec = int(msec / 1000) return datetime.datetime.fromtimestamp(sec).isoformat(' ') +class wxFileNamePrinter: + def __init__(self, val): + self.val = val + + def to_string(self): + # It is simpler to just call the internal function here than to iterate + # over m_dirs array ourselves. The disadvantage of this approach is + # that it requires a live inferior process and so doesn't work when + # debugging using only a core file. If this ever becomes a serious + # problem, this should be rewritten to use m_dirs and m_name and m_ext. + return gdb.parse_and_eval('((wxFileName*)%s)->GetFullPath(0)' % + self.val.address) + class wxXYPrinterBase: def __init__(self, val): self.x = val['x'] @@ -66,7 +79,12 @@ class wxRectPrinter(wxXYPrinterBase): def wxLookupFunction(val): # Using a list is probably ok for so few items but consider switching to a # set (or a dict and cache class types as the keys in it?) if needed later. - types = ['wxString', 'wxDateTime', 'wxPoint', 'wxSize', 'wxRect'] + types = ['wxString', + 'wxDateTime', + 'wxFileName', + 'wxPoint', + 'wxSize', + 'wxRect'] for t in types: if val.type.tag == t: -- 2.7.4