问题描述
根据lldb联机帮助,memory find
应该像这样工作:
According to the lldb online help, memory find
should work like this:
Find a value in the memory of the process being debugged.
Syntax: memory find <cmd-options> <address> <value> [<value> [...]]
Command Options Usage:
memory find <address> <value> [<value> [...]]
memory find [-e <expr>] [-s <name>] [-c <count>] [-o <offset>] <address> <value> [<value> [...]]
-c <count> ( --count <count> )
How many times to perform the search.
-e <expr> ( --expression <expr> )
Evaluate an expression to obtain a byte pattern.
-o <offset> ( --dump-offset <offset> )
When dumping memory for a match, an offset from the match location
to start dumping from.
-s <name> ( --string <name> )
Use text to find a byte pattern.
This command takes options and free-form arguments. If your arguments
resemble option specifiers (i.e., they start with a - or --), you must use
' -- ' between the end of the command options and the beginning of the
arguments.
我怀疑该实现与帮助信息不匹配,因为无论使用哪种语法,我似乎都会收到各种隐式错误消息之一,例如:
I suspect that the implementation does not match the help info, as whatever syntax I use I seem to get one of various cryptic error messages, e.g.:
error: two addresses needed for memory find
或
error: do not know how to deal with larger than 8 byte result types. pass a string instead
或
error: please pass either a block of text, or an expression to evaluate.
我已经用Google搜索了用法示例,但一无所获.如果有人有一个可行的例子,我将不胜感激.特别是,我想从一个指针所标识的块的开头开始搜索给定的字节数,以查找特定(字节)值(在这种情况下为255)的首次出现.
I've Googled for usage examples and come up with nothing. If anyone has an example that works I'd be grateful. In particular I want to search from the start of a block identified by a pointer, for a given no of bytes, to find the first occurrence of a particular (byte) value (255 in this case).
我在OS X上使用Xcode 7.0.1,并且lldb版本是lldb-340.4.70
.
I'm using Xcode 7.0.1 on OS X and the lldb version is lldb-340.4.70
.
我发现-s
选项可以工作,例如像这样:
I've found that the -s
option can be made to work, e.g. like this:
(lldb) me fi -s "f" -- ptr ptr+8192*256
Your data was found at location: 0x11033e20c
0x11033e20c: 66 bb 58 07 d0 b7 32 7d ff 7f 00 00 66 5b e7 82 f.X...2}....f[..
可能只是-e
选项(在这种情况下我需要的)被破坏了,例如:
It may just be that the -e
option (which is what I need in this instance) is broken, e.g.:
(lldb) me fi -e 255 -- ptr ptr+8191*256
error: expression evaluation failed. pass a string instead?
不幸的是,试图哄骗-s
选项接受转义的十六进制或十进制值似乎也不起作用:
Trying to coax the -s
option into accepting an escaped hex or decimal value doesn't seem to work either, unfortunately:
(lldb) me fi -s "\xff" -- ptr ptr+8191*256
Your data was not found within the range.
(lldb) me fi -s "\255" -- ptr ptr+8191*256
Your data was not found within the range.
推荐答案
此问题已在开源LLDB中得到解决,修订版为243893( http://llvm.org/viewvc/llvm-project?view=revision&revision=243893 )
This issue has been fixed in open source LLDB, as revision 243893 (http://llvm.org/viewvc/llvm-project?view=revision&revision=243893)
我无法对Xcode中此修复程序的可用性发表任何评论,但是您可以尝试的一件事是从源代码编译LLDB并将该手工构建的LLDB与该修复程序一起使用来调试问题
I cannot make any comments as to the availability of this fix in Xcode, but one thing you can try is to compile LLDB from source and use that hand-built LLDB with the fix to debug your issue
这篇关于如何使用lldb“内存查找"命令?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!