From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 78148 invoked by alias); 27 Jun 2018 19:31:57 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 78138 invoked by uid 89); 27 Jun 2018 19:31:57 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-25.7 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,KAM_NUMSUBJECT,SPF_PASS autolearn=ham version=3.3.2 spammy=objet X-HELO: sessmg22.ericsson.net Received: from sessmg22.ericsson.net (HELO sessmg22.ericsson.net) (193.180.251.58) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 27 Jun 2018 19:31:55 +0000 DKIM-Signature: v=1; a=rsa-sha256; d=ericsson.com; s=mailgw201801; c=relaxed/simple; q=dns/txt; i=@ericsson.com; t=1530127912; h=From:Sender:Reply-To:Subject:Date:Message-Id:To:CC:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=yS1x1hg5BryH3RwqqN3gjWSFYBHepDKyfMjpF859V0I=; b=g/oCUl1iTGjvZB5kivs6e9NXHLF9cO4QyITFJ4+cDiPRvdNplDPmugspIOEcN1bk iSHEkwEe6GiPCK+PmoU0MHW/fHiyndHXn6xwHjfUuQt0++MWQlOWYaeMbkx+oVoy twb3W38xouPmt7L1Z0YiCHM2g4EZ49DW/TaVXYehMQg=; Received: from ESESSMB505.ericsson.se (Unknown_Domain [153.88.183.123]) by sessmg22.ericsson.net (Symantec Mail Security) with SMTP id B5.1A.31169.826E33B5; Wed, 27 Jun 2018 21:31:52 +0200 (CEST) Received: from ESESSMR501.ericsson.se (153.88.183.108) by ESESSMB505.ericsson.se (153.88.183.123) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1466.3; Wed, 27 Jun 2018 21:31:52 +0200 Received: from ESESBMB503.ericsson.se (153.88.183.170) by ESESSMR501.ericsson.se (153.88.183.108) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1466.3; Wed, 27 Jun 2018 21:31:52 +0200 Received: from NAM03-BY2-obe.outbound.protection.outlook.com (153.88.183.157) by ESESBMB503.ericsson.se (153.88.183.170) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1466.3 via Frontend Transport; Wed, 27 Jun 2018 21:31:51 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ericsson.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=09434gNaomEUM+/YGsn5wT/+/sjuIOMYERIwDIEyE48=; b=c/DSi3ci8L37gtwzI9H/EAooKx9dUPlXxoMK7S+Aa7uBJpJZOK6EbQdPfCUXVF9ZD5RT4VOoHkqeY+rD0h74t0U9TZXq+CTvfwni9LkQNfjbr0Z4qJVovuH0ybn94B7awQ2FrXylgQqOt+aoep7+rzOHPkH6FZEc1lFz4SHr+18= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=simon.marchi@ericsson.com; Received: from elxacz23q12.ericsson.se (129.192.64.65) by DM6PR15MB2393.namprd15.prod.outlook.com (2603:10b6:5:8d::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.906.20; Wed, 27 Jun 2018 19:31:48 +0000 From: Simon Marchi To: CC: Simon Marchi Subject: [pushed] Format gdb-gdb.py.in with autopep8 Date: Wed, 27 Jun 2018 19:31:00 -0000 Message-Id: <1530127899-7088-1-git-send-email-simon.marchi@ericsson.com> MIME-Version: 1.0 Content-Type: text/plain Return-Path: simon.marchi@ericsson.com Received-SPF: None (protection.outlook.com: ericsson.com does not designate permitted sender hosts) X-IsSubscribed: yes X-SW-Source: 2018-06/txt/msg00669.txt.bz2 Format using "autopep8 -i". gdb/ChangeLog: * gdb-gdb.py.in: Format using autopep8. --- gdb/ChangeLog | 4 ++++ gdb/gdb-gdb.py.in | 24 +++++++++++++++++++++--- 2 files changed, 25 insertions(+), 3 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index d8bae23..be45bc3 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,5 +1,9 @@ 2018-06-27 Simon Marchi + * gdb-gdb.py.in: Format using autopep8. + +2018-06-27 Simon Marchi + * gdb-gdb.py.in (CoreAddrPrettyPrinter): New class. (type_lookup_function): Recognize CORE_ADDR values. diff --git a/gdb/gdb-gdb.py.in b/gdb/gdb-gdb.py.in index 436f05c..363a93e 100644 --- a/gdb/gdb-gdb.py.in +++ b/gdb/gdb-gdb.py.in @@ -18,6 +18,7 @@ import gdb import os.path + class TypeFlag: """A class that allows us to store a flag name, its short name, and its value. @@ -34,6 +35,7 @@ class TypeFlag: value: The associated value. short_name: The enumeration name, with the suffix stripped. """ + def __init__(self, name, value): self.name = name self.value = value @@ -42,12 +44,13 @@ class TypeFlag: def __lt__(self, other): """Sort by value order.""" return self.value < other.value - + # A list of all existing TYPE_INSTANCE_FLAGS_* enumerations, # stored as TypeFlags objects. Lazy-initialized. TYPE_FLAGS = None + class TypeFlagsPrinter: """A class that prints a decoded form of an instance_flags value. @@ -59,8 +62,10 @@ class TypeFlagsPrinter: If not, then printing of the instance_flag is going to be degraded, but it's not a fatal error. """ + def __init__(self, val): self.val = val + def __str__(self): global TYPE_FLAGS if TYPE_FLAGS is None: @@ -73,6 +78,7 @@ class TypeFlagsPrinter: else: flag_list = ["???"] return "0x%x [%s]" % (self.val, "|".join(flag_list)) + def init_TYPE_FLAGS(self): """Initialize the TYPE_FLAGS global as a list of TypeFlag objects. This operation requires the search of a couple of enumeration types. @@ -94,10 +100,13 @@ class TypeFlagsPrinter: for field in iflags.fields()] TYPE_FLAGS.sort() + class StructTypePrettyPrinter: """Pretty-print an object of type struct type""" + def __init__(self, val): self.val = val + def to_string(self): fields = [] fields.append("pointer_type = %s" % self.val['pointer_type']) @@ -109,10 +118,13 @@ class StructTypePrettyPrinter: fields.append("main_type = %s" % self.val['main_type']) return "\n{" + ",\n ".join(fields) + "}" + class StructMainTypePrettyPrinter: """Pretty-print an objet of type main_type""" + def __init__(self, val): self.val = val + def flags_to_string(self): """struct main_type contains a series of components that are one-bit ints whose name start with "flag_". For instance: @@ -124,9 +136,9 @@ class StructMainTypePrettyPrinter: """ fields = [field.name.replace("flag_", "") for field in self.val.type.fields() - if field.name.startswith("flag_") - and self.val[field.name]] + if field.name.startswith("flag_") and self.val[field.name]] return "|".join(fields) + def owner_to_string(self): """Return an image of component "owner". """ @@ -134,6 +146,7 @@ class StructMainTypePrettyPrinter: return "%s (objfile)" % self.val['owner']['objfile'] else: return "%s (gdbarch)" % self.val['owner']['gdbarch'] + def struct_field_location_img(self, field_val): """Return an image of the loc component inside the given field gdb.Value. @@ -152,6 +165,7 @@ class StructMainTypePrettyPrinter: return 'dwarf_block = %s' % loc_val['dwarf_block'] else: return 'loc = ??? (unsupported loc_kind value)' + def struct_field_img(self, fieldno): """Return an image of the main_type field number FIELDNO. """ @@ -166,6 +180,7 @@ class StructMainTypePrettyPrinter: fields.append("bitsize = %d" % f['bitsize']) fields.append(self.struct_field_location_img(f)) return label + "\n" + " {" + ",\n ".join(fields) + "}" + def bounds_img(self): """Return an image of the main_type bounds. """ @@ -177,6 +192,7 @@ class StructMainTypePrettyPrinter: if b['high_undefined'] != 0: high += " (undefined)" return "flds_bnds.bounds = {%s, %s}" % (low, high) + def type_specific_img(self): """Return a string image of the main_type type_specific union. Only the relevant component of that union is printed (based on @@ -245,11 +261,13 @@ def type_lookup_function(val): return CoreAddrPrettyPrinter(val) return None + def register_pretty_printer(objfile): """A routine to register a pretty-printer against the given OBJFILE. """ objfile.pretty_printers.append(type_lookup_function) + if __name__ == "__main__": if gdb.current_objfile() is not None: # This is the case where this script is being "auto-loaded" -- 2.7.4