OLD | NEW |
1 #!/usr/bin/python | 1 # Copyright (c) 2011 The Chromium Authors. All rights reserved. |
2 # Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. | |
3 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
4 # found in the LICENSE file. | 3 # found in the LICENSE file. |
5 | 4 |
6 # gdb_helper.py | |
7 | |
8 ''' A bunch of helper functions for querying gdb.''' | 5 ''' A bunch of helper functions for querying gdb.''' |
9 | 6 |
10 import logging | 7 import logging |
11 import os | 8 import os |
12 import re | 9 import re |
13 import tempfile | 10 import tempfile |
14 | 11 |
15 GDB_LINE_RE = re.compile(r'Line ([0-9]*) of "([^"]*)".*') | 12 GDB_LINE_RE = re.compile(r'Line ([0-9]*) of "([^"]*)".*') |
16 | 13 |
17 def _GdbOutputToFileLine(output_line): | 14 def _GdbOutputToFileLine(output_line): |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
67 else: | 64 else: |
68 self._binaries[binary] = [address] | 65 self._binaries[binary] = [address] |
69 self._all_resolved = False | 66 self._all_resolved = False |
70 | 67 |
71 def ResolveAll(self): | 68 def ResolveAll(self): |
72 ''' Carry out all lookup requests. ''' | 69 ''' Carry out all lookup requests. ''' |
73 self._translation = {} | 70 self._translation = {} |
74 for binary in self._binaries.keys(): | 71 for binary in self._binaries.keys(): |
75 if binary != '' and binary in self._load_addresses: | 72 if binary != '' and binary in self._load_addresses: |
76 load_address = self._load_addresses[binary] | 73 load_address = self._load_addresses[binary] |
77 addr = ResolveAddressesWithinABinary(binary, load_address, self._binarie
s[binary]) | 74 addr = ResolveAddressesWithinABinary( |
| 75 binary, load_address, self._binaries[binary]) |
78 self._translation[binary] = addr | 76 self._translation[binary] = addr |
79 self._all_resolved = True | 77 self._all_resolved = True |
80 | 78 |
81 def GetFileLine(self, binary, addr): | 79 def GetFileLine(self, binary, addr): |
82 ''' Get the (filename, linenum) result of a previously-registered lookup req
uest. ''' | 80 ''' Get the (filename, linenum) result of a previously-registered lookup |
| 81 request. |
| 82 ''' |
83 if self._all_resolved: | 83 if self._all_resolved: |
84 if binary in self._translation: | 84 if binary in self._translation: |
85 if addr in self._translation[binary]: | 85 if addr in self._translation[binary]: |
86 return self._translation[binary][addr] | 86 return self._translation[binary][addr] |
87 return (None, None) | 87 return (None, None) |
OLD | NEW |