Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dumb question: how exactly do you use this? #159

Open
makslevental opened this issue Aug 11, 2021 · 2 comments
Open

dumb question: how exactly do you use this? #159

makslevental opened this issue Aug 11, 2021 · 2 comments

Comments

@makslevental
Copy link

sorry if this is a dumb question but how exactly do i use lldb-eval in tandem with lldb? I've got it built (which wasn't completely straightforward) but e.g.

(pytorch_dev) [mlevental@devgpu019:lldb-eval (master)]$ LLVM_INSTALL_PATH=/data/users/mlevental/llvm-project/llvm bazel run tools:exec -- "(1 + 2) * 42 / 4"
INFO: Analyzed target //tools:exec (0 packages loaded, 0 targets configured).
INFO: Found 1 target...
Target //tools:exec up-to-date:
  bazel-bin/tools/exec
INFO: Elapsed time: 0.133s, Critical Path: 0.00s
INFO: 1 process: 1 internal.
INFO: Build completed successfully, 1 total action
INFO: Running command line: bazel-bin/tools/exec '(1' + '2)' bazel-bin bazel-lldb-eval bazel-out bazel-testlogs BUILD build_defs CONTRIBUTING.md docs LICENSE lldb-eval README.md testdata tools WORKSPACEINFO: Build completed successfully, 1 total action
Can't find the breakpoint location.
(pytorch_dev) [mlevental@devgpu019:lldb-eval (master)]$ 

so it necessitates being run within the context of lldb even for this.

does one need to rebuild lldb,lldb-server linking against liblldb-eval.so or something like that?

@werat
Copy link
Member

werat commented Aug 12, 2021

Hi, thanks for your interest in the project! No dumb questions here :)

I'd be happy to learn more about your use case and help any way I can.

lldb-eval is supposed to be used as a library and it requires lldb to work (it links against liblldb.so|dll). You don't need to rebuild lldb or lldb-server, they don't know anything about lldb-eval.

Typically lldb-eval would be used like this:

  • A "host" application (debugger or an IDE) uses liblldb.so|dll to start a debugging session (e.g. launch a program, run until the breakpoint, etc).
  • A "host" application uses lldb-eval.so|dll to evaluate expressions in the context of the debug session.

tools/exec is a sample application for testing that basically implements the flow described above.

It would be possible to write a dynamic plugin for LLDB for evaluating expressions using lldb-eval, however nobody asked for that yet :)

Which OS are you using? I've tested lldb-eval on Linux (Ubuntu) and Windows, not sure if there are any problems on macos. The command in your example should work, however it says "Can't find the breakpoint location", which suggests something fails very early in the process (link).

I've got it built (which wasn't completely straightforward)

Can you elaborate which steps were problematic? I can imagine building LLDB from scratch can be challenging, but would like to know about other difficulties as well.

@tonkosi
Copy link
Collaborator

tonkosi commented Aug 12, 2021

Hi, in this particular example the issue could be the way your shell processes arguments.

tools/exec should only take a single argument "(1 + 2) * 42 / 4", however, your shell interprets this as a list of arguments (1, +, 2), followed by the content of working dir (multiplication operator * treated as expansion operation).

Maybe your shell passes multi-word arguments in a different way or there are multiple levels of escaping somehow? E.g. what happens if you try to pass the argument as '(1 + 2) * 42 / 4' or "\"(1 + 2) * 42 / 4\""?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants