Adds a check to ensure that a process exists before attempting to get its ABI to prevent lldb from crash due to trying to read from page zero.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
lldb/source/Commands/CommandObjectMemory.cpp | ||
---|---|---|
597–598 | Should memory read emit an error if there's no process (and no core file or any other memory to read from)? |
LGTM with some minor feedbacks :) !
lldb/source/Commands/CommandObjectMemory.cpp | ||
---|---|---|
597 | Nit: I don't think this is formatted properly | |
597–598 | @kastiglione On Apple's lldb, we get this: (lldb) x 0 error: error reading data from section __PAGEZERO (lldb) target delete 0 1 targets deleted. (lldb) x 0 error: invalid target, create a target using the 'target create' command (lldb) Might be an oversight. | |
lldb/test/Shell/Driver/TestPageZeroRead.test | ||
3 | You probably want to check the error string |
lldb/source/Commands/CommandObjectMemory.cpp | ||
---|---|---|
597–598 | Right now running memory read without a target indicates that there's no target. The input that can cause lldb to crash is x 0 (such as ./bin/lldb -o 'x 0' ./bin/count. |
More generally, you can tell which elements of the exe_ctx you need to check in any given command by looking at requirements for the command which are passed into the constructor for the command. Any entity that's required there, you don't need to check for, but otherwise, you do have to check. "CommandObjectMemoryRead" has:
eCommandRequiresTarget | eCommandProcessMustBePaused
so you should not need to check the target, but any references to the process, thread or frame in the exe_ctx must be checked. And if there is a process, you don't need to check whether it is paused or not.
Nit: I don't think this is formatted properly