jasonmolenda created this revision. jasonmolenda added a reviewer: jingham. jasonmolenda added a project: LLDB. Herald added a subscriber: JDevlieghere. jasonmolenda requested review of this revision. Herald added a subscriber: lldb-commits.
I don't think lldb's error messaging is great when attached to a process -- the command interpreter's commands are asynchronous -- and the user doesn't realize that it is currently executing. They resume execution and they can type more commands while the inferior process is executing. This leads to people getting messages like (lldb) c Process 82784 resuming (lldb) si error: invalid thread (lldb) dis error: Cannot disassemble around the current function without a selected frame. (lldb) reg read pc error: invalid thread (lldb) p/x $pc error: Process is running. Use 'process interrupt' to pause execution. (lldb) That last one was good, but the rest are mystifying unless you work on lldb and know how the command requirements are expressed/tested. This patch changes the error messages, and for the disassembler, adds cases where we have a Process and where we don't (in a way that is messy but all 3 instances print slightly different error messages). There may be suggestions or other ideas for how these could be phrased. I avoided the term "live process" because I was thinking of corefile debugging, but "stopped process" may make people think "well I killed the process, it's stopped now, why can't I disassemble" lol. I'm trying to think less like an lldb programmer and more like an lldb user, and I think these terms get the point across: (lldb) c Process 82784 resuming (lldb) si error: Command requires a process which is currently stopped. (lldb) dis error: Cannot disassemble around the current function without the process being stopped. (lldb) reg read pc error: Command requires a process which is currently stopped. (lldb) lldb/test/Shell/Commands/command-disassemble.s will need to be updated with the final messaging too, before this could be landed. But I suspect there may be some suggestions for edits. Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D120594 Files: lldb/include/lldb/Interpreter/CommandObject.h lldb/source/Commands/CommandObjectDisassemble.cpp
Index: lldb/source/Commands/CommandObjectDisassemble.cpp =================================================================== --- lldb/source/Commands/CommandObjectDisassemble.cpp +++ lldb/source/Commands/CommandObjectDisassemble.cpp @@ -278,11 +278,20 @@ llvm::Expected<std::vector<AddressRange>> CommandObjectDisassemble::GetCurrentFunctionRanges() { + Process *process = m_exe_ctx.GetProcessPtr(); StackFrame *frame = m_exe_ctx.GetFramePtr(); if (!frame) { - return llvm::createStringError(llvm::inconvertibleErrorCode(), - "Cannot disassemble around the current " - "function without a selected frame.\n"); + if (process) { + return llvm::createStringError( + llvm::inconvertibleErrorCode(), + "Cannot disassemble around the current " + "function without the process being stopped.\n"); + } else { + return llvm::createStringError(llvm::inconvertibleErrorCode(), + "Cannot disassemble around the current " + "function without a selected frame -" + "no currently running process.\n"); + } } SymbolContext sc( frame->GetSymbolContext(eSymbolContextFunction | eSymbolContextSymbol)); @@ -301,11 +310,20 @@ llvm::Expected<std::vector<AddressRange>> CommandObjectDisassemble::GetCurrentLineRanges() { + Process *process = m_exe_ctx.GetProcessPtr(); StackFrame *frame = m_exe_ctx.GetFramePtr(); if (!frame) { - return llvm::createStringError(llvm::inconvertibleErrorCode(), - "Cannot disassemble around the current " - "line without a selected frame.\n"); + if (process) { + return llvm::createStringError( + llvm::inconvertibleErrorCode(), + "Cannot disassemble around the current " + "function without the process being stopped.\n"); + } else { + return llvm::createStringError(llvm::inconvertibleErrorCode(), + "Cannot disassemble around the current " + "line without a selected frame -" + "no currently running process.\n"); + } } LineEntry pc_line_entry( @@ -361,11 +379,20 @@ llvm::Expected<std::vector<AddressRange>> CommandObjectDisassemble::GetPCRanges() { + Process *process = m_exe_ctx.GetProcessPtr(); StackFrame *frame = m_exe_ctx.GetFramePtr(); if (!frame) { - return llvm::createStringError(llvm::inconvertibleErrorCode(), - "Cannot disassemble around the current " - "PC without a selected frame.\n"); + if (process) { + return llvm::createStringError( + llvm::inconvertibleErrorCode(), + "Cannot disassemble around the current " + "function without the process being stopped.\n"); + } else { + return llvm::createStringError(llvm::inconvertibleErrorCode(), + "Cannot disassemble around the current " + "PC without a selected frame -" + "no currently running process.\n"); + } } if (m_options.num_instructions == 0) { Index: lldb/include/lldb/Interpreter/CommandObject.h =================================================================== --- lldb/include/lldb/Interpreter/CommandObject.h +++ lldb/include/lldb/Interpreter/CommandObject.h @@ -326,15 +326,20 @@ } virtual const char *GetInvalidProcessDescription() { - return "invalid process"; + return "Command requires a current process."; } - virtual const char *GetInvalidThreadDescription() { return "invalid thread"; } + virtual const char *GetInvalidThreadDescription() { + return "Command requires a process which is currently stopped."; + } - virtual const char *GetInvalidFrameDescription() { return "invalid frame"; } + virtual const char *GetInvalidFrameDescription() { + return "Command requires a process, which is currently stopped."; + } virtual const char *GetInvalidRegContextDescription() { - return "invalid frame, no registers"; + return "invalid frame, no registers, command requires a process which is " + "currently stopped."; } // This is for use in the command interpreter, when you either want the
_______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits