diff options
author | Catalin Iacob <iacobcatalin@gmail.com> | 2012-02-29 22:25:13 +0100 |
---|---|---|
committer | Tor Lillqvist <tlillqvist@suse.com> | 2012-03-08 10:37:55 +0200 |
commit | 7c9dbfd3e857ee2694505eab5846141923aa4381 (patch) | |
tree | 3996cbdef6a03630de5cb453b8f43f8c4a4a6cf9 /solenv/gdb | |
parent | fdd3427a584a3f14ecb0d00557417434db04df99 (diff) |
fdo #46446: add python gdb helpers for osl::FileBase
Diffstat (limited to 'solenv/gdb')
-rw-r--r-- | solenv/gdb/libreoffice/sal.py | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/solenv/gdb/libreoffice/sal.py b/solenv/gdb/libreoffice/sal.py index 75d1cb1dc7a7..e26c008c0e7d 100644 --- a/solenv/gdb/libreoffice/sal.py +++ b/solenv/gdb/libreoffice/sal.py @@ -26,6 +26,7 @@ # instead of those above. import gdb +import gdb.types from libreoffice.util import printing from libreoffice.util.string import StringPrinterHelper @@ -90,6 +91,69 @@ class RtlReferencePrinter(object): else: return "empty %s" % self.typename +class OslFileStatusPrinter(object): + '''Prints oslFileStatus''' + + def __init__(self, typename, val): + self.val = val + + def to_string(self): + osl_file_type = gdb.lookup_type('oslFileType').strip_typedefs() + fields_to_enum_val = gdb.types.make_enum_dict(osl_file_type) + + etype = self.field_val_if_valid('eType') + if etype is not None: + pretty_etype = '<unknown type>' # in case it's not one of the fields + + for field_name, field_val in fields_to_enum_val.iteritems(): + if etype == field_val: + pretty_etype = self.pretty_file_type(field_name) + else: + pretty_etype = '<invalid type>' + + file_url = self.field_val_if_valid('ustrFileURL') + if file_url is not None: + pretty_file_url = str(file_url.dereference()) + else: + pretty_file_url = '<invalid file url>' + + pretty_file_status = pretty_etype + ': ' + pretty_file_url + + # for links append the link target if valid + if etype == fields_to_enum_val['osl_File_Type_Link']: + link_target = self.field_val_if_valid('ustrLinkTargetURL') + if link_target is None: + pretty_link_target = '<invalid link target>' + else: + pretty_link_target = str(link_target.dereference()) + + pretty_file_status += ' -> ' + pretty_link_target + + return pretty_file_status + + def pretty_file_type(self, file_type_name): + if file_type_name != 'osl_File_Type_Regular': + return file_type_name.replace('osl_File_Type_', '').lower() + else: + return 'file' # regular is not very descriptive, file is better + + def field_val_if_valid(self, field): + mask_for_field = {'eType': 0x00000001, + 'uAttributes': 0x00000002, + 'aCreationTime': 0x00000010, + 'aAccessTime': 0x00000020, + 'aModifyTime': 0x00000040, + 'uFileSize': 0x00000080, + 'ustrFileName': 0x00000100, + 'ustrFileURL': 0x00000200, + 'ustrLinkTargetURL': 0x00000400} + + valid_fields = self.val['uValidFields'] + if valid_fields & mask_for_field[field]: + return self.val[field] + else: + return None + printer = None def build_pretty_printers(): @@ -109,6 +173,7 @@ def build_pretty_printers(): # other stuff printer.add('rtl::Reference', RtlReferencePrinter) + printer.add('_oslFileStatus', OslFileStatusPrinter) return printer |