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

Add LLDB pretty-printing #8460

Merged
merged 6 commits into from
Nov 22, 2024
Merged

Add LLDB pretty-printing #8460

merged 6 commits into from
Nov 22, 2024

Conversation

alexreinking
Copy link
Member

Pulling out changes from my rfactor work...

This PR adds some features for visualizing Halide's types in LLDB, which my IDE (CLion) uses. The IR printer supports a "summary" mode that replaces certain subexpressions / blocks with ellipses. This has greatly improved my debugging experience. I encourage others to add to this and tweak it.

@steven-johnson
Copy link
Contributor

Any idea how this works with "naked" LLDB? If so, adding a comment would be nice.

@alexreinking
Copy link
Member Author

This just installs pretty printers. So after loading the script via command script import ./tools/lldbhalide.py, it should just start using the IRPrinter functions to render Exprs and Stmts

.lldbinit Show resolved Hide resolved
@zvookin
Copy link
Member

zvookin commented Nov 5, 2024

Can you add some documentation mention so folks know it exists? Perhaps in the README or maybe an added page in the Doxygen? I guess it's Halide internal devr only, but having a couple lines on it in docs means it will get used. Probably also worth writing down the command line flags to use it with straight command line lldb.

@alexreinking
Copy link
Member Author

Can you add some documentation mention so folks know it exists? Perhaps in the README or maybe an added page in the Doxygen? I guess it's Halide internal devr only, but having a couple lines on it in docs means it will get used. Probably also worth writing down the command line flags to use it with straight command line lldb.

Of course -- I'll do that as I fix the indents I broke

@abadams
Copy link
Member

abadams commented Nov 5, 2024

Can you post some example lldb output with this enabled?

@steven-johnson
Copy link
Contributor

Status?

@alexreinking
Copy link
Member Author

Still in progress. I added a bunch more rules in a private branch and will need to update this PR

@alexreinking
Copy link
Member Author

Can you post some example lldb output with this enabled?

I added some to the Testing readme in this PR, but here's a direct comparison. Let's debug correctness/bounds.cpp. I'll set a breakpoint at line 18:

image

Without the helpers, this is what I see in the debugger when inspecting the definition of h:

image

As you can see, this is completely useless. It is also the direct result of parsing frame variable h:

(lldb) frame variable h
(Halide::Func) h = {
  func = {
    contents = {
      strong = (ptr = 0x0000600003252f80)
      weak = nullptr
      idx = 0
    }
  }
  pipeline_ = {
    contents = (ptr = 0x0000000000000000)
  }
}

Now, if I do this again, but with the helpers loaded, I see something much more useful:

image

And indeed I can drill further down and see useful summaries of its definitions:

image

This is accessible from the command line, of course:

(lldb) frame variable h
(Halide::Internal::FunctionContents) $20 = {
  name = "h"
  origin_name = "h"
  output_types = size=1 {
    [0] = {
      type = halide_type_int bits=32 ' ' lanes=1
      handle_type = nullptr
    }
  }
  required_types = size=0 {}
  required_dims = -1
  args = size=2 {
    [0] = "x"
    [1] = "y"
  }
... lots more output ...

@alexreinking alexreinking merged commit 31335b4 into main Nov 22, 2024
12 of 14 checks passed
@alexreinking alexreinking deleted the lldb-pretty-print branch November 22, 2024 21:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants