This is an archive of the discontinued LLVM Phabricator instance.

[Reproducer] Generate LLDB reproducer on crash
ClosedPublic

Authored by JDevlieghere on Nov 19 2019, 5:34 PM.

Details

Summary

This patch hooks the reproducer infrastructure with the signal handlers.
When lldb crashes with reproducers capture enabled, it will now generate
the reproducer and print a short message the standard out. This doesn't
affect the pretty stack traces, which are still printed before.

This patch also introduces a new reproducer sub-command that
intentionally raises a given signal to test the reproducer signal
handling.

Currently the signal handler is doing too much work. Instead of copying
over files into the reproducers in the signal handler, we should
re-invoke ourselves with a special command line flag that looks at the
VFS mapping and performs the copy.

This is a NO-OP when reproducers are disabled.

Diff Detail

Event Timeline

JDevlieghere created this revision.Nov 19 2019, 5:34 PM
Herald added a project: Restricted Project. · View Herald Transcript
JDevlieghere edited the summary of this revision. (Show Details)Nov 19 2019, 5:36 PM

I think this looks pretty good. This is going to do a _lot_ of work in the signal handler, which may or may not work. However, at the point when this code gets invoked, we're already in undefined behavior territory anyway, so we might as well give it a shot. The dumping code can be gradually hardened later if we find that a lot of reproducers are failing to complete the dumping process.

I was expecting that the raise(SIGWHATEVER) stuff will not work on windows, but it looks like it should at least compile. I have no idea what will that do at runtime, but reproducers don't work on windows anyway.

lldb/source/Commands/CommandObjectReproducer.cpp
86

everywhere else we use capital letters for signal names

99–103

What's the reason for the "none" value? Can we remove it? I am assuming noone would ever want to write "reproducer (x)crash -s none"...

153

Maybe also call this xcrash?

lldb/source/Commands/Options.td
441

xcrash?

lldb/tools/driver/Driver.cpp
739–744

I'm thinking if there's a way to centralize the printing of this message. Right now it is duplicated here and in the "reproducer generate" implementation, and it's already accumulating subtle differences (e.g., this copy includes the version string while the other one does not -- it seems like this would be useful everywhere). Maybe if the Generate call takes an SBFile object -- the stream where this message gets written to, and then we have some lldb_private function writing that message?

JDevlieghere marked 4 inline comments as done.

Address review feedback.

Update the tests with uppercase signal names

vsk added a comment.Nov 20 2019, 12:23 PM

This looks good to me.

This revision was not accepted when it landed; it landed in state Needs Review.Nov 20 2019, 1:14 PM
This revision was automatically updated to reflect the committed changes.