From 99fd84517de583842bfcf63d2991e7e856a7e3c6 Mon Sep 17 00:00:00 2001 From: Chintalagiri Shashank Date: Wed, 27 Jul 2016 04:14:59 +0530 Subject: [PATCH] Added address describe. --- fpvgcc/fpv.py | 6 ++++++ fpvgcc/gccMemoryMap.py | 8 ++++++++ setup.py | 2 +- 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/fpvgcc/fpv.py b/fpvgcc/fpv.py index 87e5947..6a5dcd1 100644 --- a/fpvgcc/fpv.py +++ b/fpvgcc/fpv.py @@ -708,6 +708,8 @@ def main(): help='Print list of loaded files.') action.add_argument('--la', action='store_true', help='Print list of detected aliases.') + action.add_argument('--addr', metavar='ADDRESS', + help='Describe contents at address.') args = parser.parse_args() if args.verbose == 0: logging.basicConfig(level=logging.ERROR) @@ -758,6 +760,10 @@ def main(): for node in state_machine.memory_map.root.all_nodes(): if node.objfile == args.lobj: print(node) + elif args.addr: + for node in state_machine.memory_map.root.all_nodes(): + if node.contains_address(args.addr): + print(node) if __name__ == '__main__': diff --git a/fpvgcc/gccMemoryMap.py b/fpvgcc/gccMemoryMap.py index f2b73ec..625f1fc 100644 --- a/fpvgcc/gccMemoryMap.py +++ b/fpvgcc/gccMemoryMap.py @@ -87,6 +87,14 @@ def address(self): def address(self, value): self._address = int(value, 16) + def contains_address(self, addr): + if not self.address or self.region in ['DISCARDED', 'UNDEF']: + return False + if int(self.address, 0) <= int(addr, 0) < \ + (int(self.address, 0) + self.size): + return True + return False + @property def defsize(self): return self._defsize diff --git a/setup.py b/setup.py index 8e45576..58b0e06 100644 --- a/setup.py +++ b/setup.py @@ -14,7 +14,7 @@ def read(fname): setup( name="fpv-gcc", - version="0.4", + version="0.5", author="Chintalagiri Shashank", author_email="shashank@chintal.in", description="Analysing code footprint on embedded microcontrollers "