This is an archive of the discontinued LLVM Phabricator instance.

Add a few GDB pretty printers for MLIR.
AbandonedPublic

Authored by csigg on Jan 28 2020, 5:53 AM.

Details

Reviewers
nicolasvasilache
Summary

GDB pretty printer script to improve printing for a few MLIR types.

Most printers just remove one layer of indirection when printing an MLIR type that wraps another.

Directly print (only) the first member for the following types:

  • mlir::AbstractOperation
  • mlir::Location
  • mlir::Attribute
  • mlir::NamedAttributeList
  • mlir::Value

Directly print (only) the first base class for the following types:

  • mlir::DictionaryAttr
  • mlir::ElementsAttr
  • mlir::EnumAttr
  • mlir::EnumCaseAttr
  • mlir::LocationAttr
  • mlir::StructAttr

Custom printers for the following types:

  • mlir::Identifier (print identifier string)
  • mlir::OperationName (print name string)
  • mlir::detail::StorageUserBase (cast and print *impl)

Diff Detail

Event Timeline

csigg created this revision.Jan 28 2020, 5:53 AM

Unit tests: pass. 62221 tests passed, 0 failed and 816 were skipped.

clang-tidy: pass.

clang-format: pass.

Build artifacts: diff.json, clang-tidy.txt, clang-format.patch, CMakeCache.txt, console-log.txt, test-results.xml

Pre-merge checks is in beta. Report issue. Please join beta or enable it for your project.

nicolasvasilache requested changes to this revision.Jan 28 2020, 7:44 AM

Sorry I am a bit lost here since there is no commit message :)
What does this do concretely, how is it used, why do we want this in python etc?
Atm the only thing I see is some python file that prints some stuff.

This revision now requires changes to proceed.Jan 28 2020, 7:44 AM

GDB has a python API to customize how values are printed. See here for an introduction. The API documentation is here.

You can load the script from within gdb with source path/to/prettyprinters.py or put that command into ~/.gdbinit.

The current pretty printers are quite simple, they primarily forward to the interesting member or base class for MLIR types that are mere wrappers.

LLVM already provides pretty printers for some of it's common types.

csigg edited the summary of this revision. (Show Details)Jan 28 2020, 11:29 AM
csigg updated this revision to Diff 240957.Jan 28 2020, 11:38 AM
csigg edited the summary of this revision. (Show Details)

No change, but I updated the revision summary.

Unit tests: pass. 62221 tests passed, 0 failed and 816 were skipped.

clang-tidy: pass.

clang-format: pass.

Build artifacts: diff.json, clang-tidy.txt, clang-format.patch, CMakeCache.txt, console-log.txt, test-results.xml

Pre-merge checks is in beta. Report issue. Please join beta or enable it for your project.

That's really nice!

Maybe ping @dblaikie ; I think they worked on the LLVM ones and can maybe review here.

Very cool!

I am absolutely not qualified to review this but I am happy to rubberstamp to unblock you if no one chimes in by mid-next week.
I am not sure whether this is a step towards using gdb with MLIR or whether you already have it working but if you have a way of GDB MLIR please please please give a presentation at the open design meeting (and internally if you get an earlier spot :) ).

Assuming you can also GDB MLIR somehow, would it also work with JIT'ed MLIR?

Assuming you can also GDB MLIR somehow, would it also work with JIT'ed MLIR?

You mean debug the generated code? That requires some changes to execution engine, as well as emission of line information to LLVM IR. I had a patch to add enough support for line stepping JIT'ed code, but it needs to be updated.

csigg added a comment.Feb 3 2020, 5:08 AM

@nicolasvasilache, it's currently blocked on D73609 and D73726. Then I will add tests and send it to @dblaikie for review.

dblaikie added inline comments.Feb 4 2020, 8:26 PM
mlir/utils/gdb-scripts/prettyprinters.py
22–23

What types would not have a default visualizer/what case is this intended to handle?

54–55

When does this code path happen (when does a type's field have a None type?

65–75

Looks easy/simple enough & could be committed separately.

nicolasvasilache resigned from this revision.Mar 7 2020, 10:42 AM
csigg abandoned this revision.Oct 8 2020, 7:48 AM
Herald added a project: Restricted Project. · View Herald TranscriptOct 8 2020, 7:48 AM