This is an archive of the discontinued LLVM Phabricator instance.

[llvm-objdump] Implement syntax highlighting
AbandonedPublic

Authored by seiya on Jul 8 2019, 1:11 AM.

Details

Reviewers
None
Summary

This is a prototype implementation of syntax highlighting. I'll split into separate patches, but before that I'd like to discuss the
outline to make sure that I’m on the right track.

Diff Detail

Event Timeline

seiya created this revision.Jul 8 2019, 1:11 AM
Herald added a project: Restricted Project. · View Herald TranscriptJul 8 2019, 1:11 AM

Something to be aware of is that people can change how the output is printed using switches like --x86-asm-syntax. If you're going down the route of parsing the text to identify how to highlight it, your parser needs to be robust enough to cope. Not only that but different architectures have different disassembly output, so there's a similar issue there.

seiya updated this revision to Diff 209420.Jul 12 2019, 1:15 AM
  • Hold the vector of marked up fragments instead of parsing the disassembly (suggested by Michael Spencer on llvm-dev).
seiya added a comment.Jul 12 2019, 1:15 AM

It's still work-in-progress.

seiya marked an inline comment as done.Jul 12 2019, 1:18 AM
seiya added inline comments.
llvm/lib/Target/X86/MCTargetDesc/X86ATTInstPrinter.cpp
42 ↗(On Diff #209420)

I think implementing operator<< would be better.

seiya updated this revision to Diff 209766.EditedJul 15 2019, 12:24 AM
  • Implement raw_ostream &operator<<(...).
  • Support nested marked-up string (e.g., <mem:256(<reg:%rip>)>).
This comment was removed by seiya.
seiya updated this revision to Diff 210031.Jul 16 2019, 12:27 AM
  • Highlight symbol names.
  • Fix some TODOs.
seiya marked an inline comment as done.Jul 16 2019, 12:29 AM
seiya added inline comments.
llvm/lib/Target/X86/MCTargetDesc/X86ATTInstPrinter.cpp
377 ↗(On Diff #210031)

TODO: remove

seiya marked an inline comment as not done.Jul 16 2019, 12:29 AM

I'll add tests and split into separate patches later but before that I'd like to discuss the outline to make sure that I’m on the right track.

seiya retitled this revision from WIP: [llvm-objdump] Implement syntax highlighting to [llvm-objdump] Implement syntax highlighting.Jul 16 2019, 12:42 AM
seiya edited the summary of this revision. (Show Details)

Hi @seiya. As mentioned by email offline, I think this looks quite good. Please go ahead and add some reviewers, and write some tests for it. I'm happy to help out with reviewing it in more detail once it's ready.

seiya abandoned this revision.Jul 23 2019, 11:47 PM

I've uploaded a series of separate patches: https://reviews.llvm.org/D65191