Skip to content

Commit

Permalink
Debugger: Change DWARF symbol table name
Browse files Browse the repository at this point in the history
Signed-off-by: iipeace <[email protected]>
  • Loading branch information
iipeace committed May 26, 2024
1 parent ec2a451 commit 7a53835
Showing 1 changed file with 29 additions and 13 deletions.
42 changes: 29 additions & 13 deletions guider/guider.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
__credits__ = "Peace Lee"
__license__ = "GPLv2"
__version__ = "3.9.8"
__revision__ = "240525"
__revision__ = "240526"
__maintainer__ = "Peace Lee"
__email__ = "[email protected]"
__repository__ = "https://github.com/iipeace/guider"
Expand Down Expand Up @@ -8549,7 +8549,7 @@ def convUnit2Size(value, verb=True):
# sizeZB = 1180591620717411303424
# sizeYB = 120892581961462917470617

if isinstance(value, (long, float)):
if isinstance(value, (int, long, float)):
return value

value = str(value)
Expand Down Expand Up @@ -34706,6 +34706,21 @@ def convMemStat(mlist):
"rss": long(mlist[rssIdx]) << 12,
}

@staticmethod
def getMemStatList(pid):
try:
mlist = SysMgr.getMemStat(SysMgr.pid)
return SysMgr.convMemStat(mlist)
except SystemExit:
sys.exit(0)
except:
SysMgr.printWarn(
"failed to memory stats for %s(%s)"
% (SysMgr.getComm(pid), pid),
reason=True,
)
return {}

@staticmethod
def getMemStat(pid):
try:
Expand Down Expand Up @@ -87592,7 +87607,7 @@ def loadAndroidJITSymbols(self):
continue
symInfo.update(v)
origElfObj.attr[n] = symInfo
elif n in ("dwarf", "dwarfTable"):
elif n in ("dwarf", "dwarfsymTable"):
dwarfInfo = origElfObj.attr.get(n, {})
if not dwarfInfo:
origElfObj.attr[n] = {}
Expand Down Expand Up @@ -87775,7 +87790,7 @@ def loadAndroidJITSymbols(self):
jmapTable.append(
[attrs["value"], sym, attrs["size"], fname]
)
elif n in ("dwarf", "dwarfTable"):
elif n in ("dwarf", "dwarfsymTable"):
if not fname in ElfAnalyzer.cachedFiles:
ElfAnalyzer.cachedFiles[fname] = elfObj
dwarfInfo = ElfAnalyzer.cachedFiles[fname].attr.get(n, {})
Expand Down Expand Up @@ -103418,7 +103433,7 @@ def mergeSymTable(self, force=False, onlyFunc=True, removeOrig=False):

# merge sym tables #
tempSymTable = {}
for secName in ("symTable", "dynsymTable", "dwarfTable"):
for secName in ("symTable", "dynsymTable", "dwarfsymTable"):
if not secName in self.attr:
continue
tempSymTable.update(self.attr[secName])
Expand Down Expand Up @@ -106385,7 +106400,7 @@ def _printStrSect(sh_name, strtab):
frameSectName = ""

# check frame section #
self.attr["dwarfTable"] = {}
self.attr["dwarfsymTable"] = {}
if SysMgr.dwarfEnable and e_shframe >= 0 and frameSectName:

def _getEncType(encoding):
Expand Down Expand Up @@ -106762,10 +106777,7 @@ def _getRegRule(reg):
table = myObj["table"]
regOrder = myObj["regOrder"]

if "initLoc" in myObj:
initLoc = myObj["initLoc"]
else:
initLoc = 0
initLoc = myObj.get("initLoc", 0)

# get return address register #
if "rar" in myObj:
Expand Down Expand Up @@ -107308,7 +107320,7 @@ def _decodeData2(table, pos):
continue

# register stripped function info #
self.attr["dwarfTable"][hex(initLoc)] = {
self.attr["dwarfsymTable"][hex(initLoc)] = {
"value": initLoc,
"size": lenSize,
"type": "FUNC",
Expand Down Expand Up @@ -107570,7 +107582,7 @@ def _decodeEntry(
not foffset in self.addrTable
or not self.addrTable[foffset]
):
self.attr["dwarfTable"][hex(foffset)] = {
self.attr["dwarfsymTable"][hex(foffset)] = {
"value": foffset,
"size": 1,
"type": "FUNC",
Expand Down Expand Up @@ -109380,12 +109392,14 @@ def _addEntryOldState(cmd, args, isExtended=False):
path=newpath, debug=debug, fd=dfd, size=len(mdata)
)

for dt in ("symTable", "dynsymTable", "dwarfTable"):
# merge tables #
for dt in ("symTable", "dynsymTable", "dwarfsymTable"):
if not dt in dobj.attr:
continue
self.attr.setdefault(dt, {})
self.attr[dt].update(dobj.attr[dt])

# merge dwarf data #
for dt in dobj.attr.get("dwarf", []):
self.attr.setdefault("dwarf", {})
if type(dobj.attr["dwarf"][dt]) is list:
Expand All @@ -109397,6 +109411,8 @@ def _addEntryOldState(cmd, args, isExtended=False):
else:
self.attr["dwarf"].setdefault(dt, {})
self.attr["dwarf"][dt].update(dobj.attr["dwarf"][dt])

del dobj
except ValueError:
pass
except SystemExit:
Expand Down

0 comments on commit 7a53835

Please sign in to comment.