This is an archive of the discontinued LLVM Phabricator instance.

[lldb] [Process/FreeBSDRemote] Fix handling user-generated SIGTRAP
ClosedPublic

Authored by mgorny on Nov 7 2020, 9:57 AM.

Details

Summary

Update the SIGTRAP handler to account for the possibility of SIGTRAP
being generated by the user, i.e. not having any specific debugging
event associated with it, as well as receiving unknown SIGTRAPs. These
instances of SIGTRAP are passed to the regular signal handler.

Diff Detail

Event Timeline

mgorny requested review of this revision.Nov 7 2020, 9:57 AM
mgorny created this revision.
emaste accepted this revision.Nov 7 2020, 1:11 PM
This revision is now accepted and ready to land.Nov 7 2020, 1:11 PM

I propose to filter all user induced signals at once and check & 0x10000 and SI_USER.

http://src.illumos.org/source/xref/freebsd-head/sys/sys/signal.h#406

This way we will avoid all future fallout and crashing the debugger on unknown signal.

mgorny updated this revision to Diff 303676.Nov 7 2020, 2:31 PM

Updated to treat generic SIGTRAP as a fallback as requested by @krytarowski. This happens either if si_code >= SI_USER, or there is no siginfo and no other flag is set.

krytarowski accepted this revision.Nov 7 2020, 3:41 PM
labath added inline comments.Nov 9 2020, 12:34 AM
lldb/source/Plugins/Process/FreeBSDRemote/NativeProcessFreeBSD.cpp
287

What will happen in case this returns? Will the process auto-resume or just hang stopped? It sounds like it would still be useful to report this as "SIGTRAP" even if we are unable to give any details about it...

mgorny added inline comments.Nov 9 2020, 12:42 AM
lldb/source/Plugins/Process/FreeBSDRemote/NativeProcessFreeBSD.cpp
287

Good catch. Should it be reported as an arbitrary SIGTRAP then or maybe as a trace trap?

labath added inline comments.Nov 9 2020, 1:01 AM
lldb/source/Plugins/Process/FreeBSDRemote/NativeProcessFreeBSD.cpp
287

I don't have a strong opinion there. I'd probably just go with a regular SIGTRAP.

mgorny planned changes to this revision.Nov 9 2020, 1:58 AM
mgorny updated this revision to Diff 303817.Nov 9 2020, 4:01 AM
mgorny edited the summary of this revision. (Show Details)

Pass unknown SIGTRAPs to the user too.

This revision is now accepted and ready to land.Nov 9 2020, 4:01 AM
mgorny updated this revision to Diff 304135.Nov 10 2020, 4:29 AM

clang-format

labath accepted this revision.Nov 10 2020, 5:00 AM
Herald added a project: Restricted Project. · View Herald TranscriptNov 10 2020, 5:18 AM