This is an archive of the discontinued LLVM Phabricator instance.

Improve error messages for command that need a stopped process
ClosedPublic

Authored by jasonmolenda on Feb 25 2022, 3:40 PM.

Details

Summary

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.

Diff Detail

Event Timeline

jasonmolenda created this revision.Feb 25 2022, 3:40 PM
jasonmolenda requested review of this revision.Feb 25 2022, 3:40 PM

Nit: can we use a colon instead of dash? We have a bunch of places already where we're "concatenating" errors with a colon so I'd like to keep that consistent.

Nit: can we use a colon instead of dash? We have a bunch of places already where we're "concatenating" errors with a colon so I'd like to keep that consistent.

Using a dash is definitely the kind of thing I would do, but I don't think I did here? I'm really not wedded to my specific wording in this patch.

Nit: can we use a colon instead of dash? We have a bunch of places already where we're "concatenating" errors with a colon so I'd like to keep that consistent.

Using a dash is definitely the kind of thing I would do, but I don't think I did here? I'm really not wedded to my specific wording in this patch.

Ah sorry, I missed them down in the CommandObjectDisassemler changes.

Integrate Jonas' suggestion, update the disassemble shell test to match the new error messages.

Herald added a project: Restricted Project. · View Herald TranscriptMar 1 2022, 4:18 PM
This revision is now accepted and ready to land.Mar 2 2022, 10:38 AM
This revision was automatically updated to reflect the committed changes.