This is an archive of the discontinued LLVM Phabricator instance.

[lldb-vscode] Use libOption with tablegen to parse command line options.
ClosedPublic

Authored by ivanhernandez13 on Feb 18 2020, 3:01 PM.

Details

Summary

This change will bring lldb-vscode in line with how several other llvm tools process command line arguments and make it easier to add future options.

Diff Detail

Event Timeline

Herald added a project: Restricted Project. · View Herald TranscriptFeb 18 2020, 3:01 PM
ivanhernandez13 changed the visibility from "Public (No Login Required)" to "No One".Feb 18 2020, 3:11 PM
ivanhernandez13 edited the summary of this revision. (Show Details)Feb 18 2020, 3:34 PM
ivanhernandez13 added reviewers: clayborg, lanza, labath.
ivanhernandez13 changed the visibility from "No One" to "Public (No Login Required)".

Assuming this looks good, can I get some pointers on how and where I should add a test for this?

I based this change on the one for the LLDB driver (https://reviews.llvm.org/D54692) which added lldb/trunk/lit/Driver/TestCommands.test. Should I look into adding something similar or should I be using lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/lldbvscode_testcase.py and adding something in lldb/test/API/tools/lldb-vscode?

This is what the output for help looks like:

~/llvm-project ❯❯❯ build/Debug/bin/lldb-vscode --help                                                                                                                               [INSERT]
OVERVIEW: LLDB VSCode

USAGE: lldb-vscodeoptions

OPTIONS:
  -g                  Alias for --wait-for-debugger
  --help              Prints out the usage information for the LLDB debug adapter tool.
  -h                  Alias for --help
  --port <port>       What port to listen on.
  -p <value>          Alias for --port
  --wait-for-debugger Pause the program at startup.

EXAMPLES:
  The debug adapter can be started in two modes.

  Running lldb-vscode without any arguments will start communicating with the
  parent over stdio. Passing a port number causes lldb-vscode to start listening
  for connections on that port.

    lldb-vscode -p <port>

  Passing --wait-for-debugger will pause the process at startup and wait for a
  debugger to attach to the process.

    lldb-vscode -w
  %

Looks good. I would add a .test file like the command line driver to cover this.

JDevlieghere accepted this revision.Feb 18 2020, 8:31 PM
JDevlieghere added a subscriber: JDevlieghere.

LGTM with the inline comments addressed and a test in Shell/VSCode.

lldb/tools/lldb-vscode/CMakeLists.txt
20

Spurious newline

24

Please use Options.td for consistency with the lldb driver.

This revision is now accepted and ready to land.Feb 18 2020, 8:31 PM
ivanhernandez13 marked 2 inline comments as done.
  • Rename opts to options to be consistent with the lldb driver and add a test case around setting an invalid port.

I added the test file but atm the two existing arguments (--wait-for-debugger and --port) will cause lldb-vscode to hang and await some sort of action from an external process causing the test runner to hang. I added a single test case for handling an invalid port since that will cause the process to exit immediately but not certain on how to handle the other cases.

I added the test file but atm the two existing arguments (--wait-for-debugger and --port) will cause lldb-vscode to hang and await some sort of action from an external process causing the test runner to hang. I added a single test case for handling an invalid port since that will cause the process to exit immediately but not certain on how to handle the other cases.

I think for these particular cases it's sufficient to check the help output and make sure the flags are there.

I added the test file but atm the two existing arguments (--wait-for-debugger and --port) will cause lldb-vscode to hang and await some sort of action from an external process causing the test runner to hang. I added a single test case for handling an invalid port since that will cause the process to exit immediately but not certain on how to handle the other cases.

I think for these particular cases it's sufficient to check the help output and make sure the flags are there.

yeah just test for the options themselves in the help output. --wait-for-debugger is only when you need to debug lldb-vscode's initial packets with a debugger, so it is not a user facing argument. We might choose to hide this option by default. I know LLVM option parsing can do this.

  • Update ldb-vscode options test to simply look for the expected flags when passing the --help option.
JDevlieghere accepted this revision.Feb 19 2020, 2:12 PM
JDevlieghere added inline comments.
lldb/test/Shell/VSCode/TestOptions.test
9

Missing newline

  • Add missing newline.
ivanhernandez13 marked an inline comment as done.Feb 19 2020, 2:21 PM
clayborg accepted this revision.Feb 19 2020, 4:04 PM

LTGM.

Thanks for the guidance!

When there are no additional concerns, would someone mind committing this change for me? I don't have commit access.

Thanks for the guidance!

When there are no additional concerns, would someone mind committing this change for me? I don't have commit access.

Done!

To github.com:llvm/llvm-project.git
   de0dda54d38..c47e0e2d37d  master -> master
This revision was automatically updated to reflect the committed changes.