使用Python从lldb中的核心文件读取地址处的字符串

问题描述

我想使用lldb中的Python从核心文件中的地址读取字符串。问题是我使用的是核心文件,因此没有实时进程。

我可以通过使用普通的lldb来找到字符串:

(lldb) p (char*)0x56039e6d71b0
(char *) $20 = 0x000056039e6d71b0 "nop"
(lldb)

我想要的字符串是"nop"。但是,我似乎无法从lldb Python获取此字符串。

这是我到目前为止尝试过的:

评估表达式

Python Interactive Interpreter. To exit,type 'quit()','exit()' or Ctrl-D.
>>> lldb.frame.EvaluateExpression("(char*)0x56039e6d71b0").GetValue()
'0x000056039e6d71b0'

创建地址并询问值:

>>> addr = lldb.SBAddress(0x56039e6d71b0,lldb.target)
>>> char = lldb.target.GetBasicType(lldb.eBasicTypeChar)
>>> val  = lldb.target.CreateValueFromAddress("name",addr,char.GetPointerType())
>>> val.GetSummary()
>>> val.GetValue()
>>> val.GetValueAsUnsigned()
0

process.ReadMemory

>>> error = lldb.SBError()
>>> lldb.process.ReadMemory(0x56039e6d71b0,3,error)
>>> error.Success()
False
>>> str(error)
'error: core file does not contain 0x56039e6d71b0'
>>> 

我似乎找不到能在Python中获得此信息的正确API。任何帮助将不胜感激!

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)