This is an archive of the discontinued LLVM Phabricator instance.

[LLDB] Fix the use of "platform process launch" with no extra arguments
ClosedPublic

Authored by DavidSpickett on Jun 23 2023, 8:13 AM.

Details

Summary

This fixes #62068.

After 8d1de7b34af46a089eb5433c700419ad9b2923ee the following issue appeared:

$ ./bin/lldb /tmp/test.o
(lldb) target create "/tmp/test.o"
Current executable set to '/tmp/test.o' (aarch64).
(lldb) platform process launch -s
error: Cannot launch '': Nothing to launch

Previously would call target->GetRunArguments when there were no extra
arguments, so we could find out what target.run-args might be.

Once that change started relying on the first arg being the exe,
the fact that that call clears the existing argument list caused the bug.

Instead, have it set a local arg list and append that to the existing
one. Which in this case will just contain the exe name.

Since there's no existing tests for this command I've added a new file
that covers enough to check this issue.

Diff Detail

Event Timeline

DavidSpickett created this revision.Jun 23 2023, 8:13 AM
Herald added a project: Restricted Project. · View Herald TranscriptJun 23 2023, 8:13 AM
DavidSpickett requested review of this revision.Jun 23 2023, 8:13 AM
Herald added a project: Restricted Project. · View Herald TranscriptJun 23 2023, 8:13 AM
labath accepted this revision.Jun 26 2023, 11:48 PM

Thanks for fixing this.

This revision is now accepted and ready to land.Jun 26 2023, 11:48 PM

I think this may have caused an LLDB test to fail:
https://green.lab.llvm.org/green/view/LLDB/job/lldb-cmake/56977/execution/node/74/log/

runCmd: platform process launch --stdout /Users/buildslave/jenkins/workspace/lldb-cmake/lldb-build/lldb-test-build.noindex/commands/platform/process/launch/TestPlatformProcessLaunch.test_process_launch_no_args/stdio.log -s
runCmd failed!
error: process launch failed

Looking at the list of eight commits between the last good run and the bad run, this seems to be related.

Do you or anyone else have a Mac they can reproduce this on? I don't. I know it works on Linux so far, unfortunately our Windows bot is down temporarily. I looked around similar tests and didn't see any skips for Mac.

Sometimes the packet log will tell us more, I could reland with that enabled for tracing and revert as soon as the build is done.

I will try to reproduce.

kastiglione added inline comments.Jun 27 2023, 2:11 PM
lldb/test/API/commands/platform/process/launch/TestPlatformProcessLaunch.py
51

@DavidSpickett did you mean for this command to use the -s flag too?

Thanks to @jingham's help in identifying this issue, I have opened https://reviews.llvm.org/D153922 as a potential fix for the issue on macOS.

kastiglione added inline comments.Jun 27 2023, 3:35 PM
lldb/test/API/commands/platform/process/launch/TestPlatformProcessLaunch.py
51

I have merged D153922, which fails with this test as-is. Before re-committing, this test will need to use -s like the other invocations, or remove the "continue" command on the next line.

DavidSpickett added inline comments.Jun 28 2023, 1:44 AM
lldb/test/API/commands/platform/process/launch/TestPlatformProcessLaunch.py
51

Will do. The missing -s was a mistake, in fact some of them failed on Linux without it. Perhaps a timing issue and I just got lucky on my local machine.