This is an archive of the discontinued LLVM Phabricator instance.

Update the lldb driver to support the -O and -S options when passing --repl
ClosedPublic

Authored by nathawes on Mar 21 2019, 5:29 PM.

Details

Summary

At the moment when --repl is passed to lldb it silently ignores any commands passed via the options below:

--one-line-before-file <command>
                     Tells the debugger to execute this one-line lldb command before any file provided on the command line has been loaded.
--one-line <command> 
                     Tells the debugger to execute this one-line lldb command after any file provided on the command line has been loaded.  
--source-before-file <file>
                     Tells the debugger to read in and execute the lldb commands in the given file, before any file has been loaded.
--source <file>
                     Tells the debugger to read in and execute the lldb commands in the given file, after any file has been loaded.
-O <value>           Alias for --one-line-before-file
-o <value>           Alias for --one-line
-S <value>           Alias for --source-before-file
-s <value>           Alias for --source

The -O and -S options are quite useful when writing tests for the REPL though, e.g. to change settings prior to entering REPL mode. This patch updates the driver to still respect the commands supplied via -O and -S when passing --repl instead of silently ignoring them. As -s and -o don't really make sense in REPL mode, commands supplied via those options are still ignored, but the driver now emits a warning to make that clear to the user.

Diff Detail

Repository
rLLDB LLDB

Event Timeline

nathawes created this revision.Mar 21 2019, 5:29 PM
Herald added a project: Restricted Project. · View Herald TranscriptMar 21 2019, 5:29 PM
Herald added a subscriber: abidh. · View Herald Transcript
aprantl accepted this revision.Mar 22 2019, 8:42 AM

Thanks! LGTM with one tiny change to the test.

lldb/lit/Driver/TestRepl.test
2 ↗(On Diff #191796)

I think the REPL by default echoes all comments, so this may actually be matching the comment in the input file rather than the warning?

I think this should do the trick:

# CHECK: {{w}}arning: commands specified to run after file load (via -o or -s) are ignored in REPL mode

This revision is now accepted and ready to land.Mar 22 2019, 8:42 AM
nathawes marked an inline comment as done.Mar 22 2019, 10:07 AM
nathawes added inline comments.
lldb/lit/Driver/TestRepl.test
2 ↗(On Diff #191796)

Good catch! I think this patch actually changes that behavior because the %lldb expansion includes -S path/to/lldb/lit/lit-lldb-init which sets echo-comment-commands false and isn't ignored anymore, but if we ever regress and stop respecting -S this test would still pass...

nathawes updated this revision to Diff 191904.Mar 22 2019, 10:11 AM

Updated the test based on feedback from @aprantl and also to specifically check we don't see the output from the -o and -s commands.

nathawes marked an inline comment as done.Mar 22 2019, 10:12 AM
This revision was automatically updated to reflect the committed changes.