Skip to content

[cross-project] Add tests for LLDB data-formatters for llvm::ArrayRef#173238

Merged
Michael137 merged 4 commits intollvm:mainfrom
Michael137:cross-project-tests/llvm-lldb-formatter-tests
Jan 6, 2026
Merged

[cross-project] Add tests for LLDB data-formatters for llvm::ArrayRef#173238
Michael137 merged 4 commits intollvm:mainfrom
Michael137:cross-project-tests/llvm-lldb-formatter-tests

Conversation

@Michael137
Copy link
Member

@Michael137 Michael137 commented Dec 22, 2025

This patch adds the bare-minimum tests for the LLDB llvm::ArrayRef formatters. Since this would be the first LLVM data fromatter test for LLDB, I wanted to keep the test itself minimal and mainly set up/agree on the infrastructure (i.e., CMake machinery, etc.).

The setup mimicks that of GDB. The main differences are:

  1. the GDB formatter tests put all the test cases in one monolithic test file, whereas I'm planning on having one test-file per LLVM container.
  2. the GDB formatter tests currently only get run if LLVM was built with debug-info. Not sure we have any build-bots out there running this configuration. In this patch we rely on just the debug-info from the LLVM headers (see latest commit). That way the tests get more consistently run (at least our public macOS buildbot runs the cross-project-tests in Release+Asserts).

This patch bare-minimum tests for the LLDB `llvm::ArrayRef` formatters.
I wanted to keep the test itself minimal and mainly set up/agree on the
infrastructure (i.e., CMake machinery, etc.).

The setup mimicks that of GDB. The main difference is that the GDB
formatter tests put all the test cases in one monolithic test file,
whereas I'm planning on having one test-file per LLVM container.

Note, the tests currently only get run if LLVM was built with
debug-info. Not sure we have any buildbots out there runing this
configuration. Though that's what the GDB formatters do too. We could
probably get away with relying on just the debug-info from the LLVM
headers. We could do that in a follow-up patch, or part of this PR,
depending on how reviewers feel.
@github-actions
Copy link

github-actions bot commented Dec 22, 2025

✅ With the latest revision this PR passed the C/C++ code formatter.

@dwblaikie
Copy link
Collaborator

  • the GDB formatter tests put all the test cases in one monolithic test file, whereas I'm planning on having one test-file per LLVM container.
  • the GDB formatter tests currently only get run if LLVM was built with debug-info. Not sure we have any build-bots out there running this configuration. In this patch we rely on just the debug-info from the LLVM headers (see latest commit). That way the tests get more consistently run (at least our public macOS buildbot runs the cross-project-tests in Release+Asserts).

Both those things seem fine by me - given the gdb tests have llvm and mlir coverage, you could consider an extra nested directory to group the llvm ones so mlir ones can go in another directory beside it, etc. But can also cross that bridge if/when we come to it. (I think the llvm one was also named after the library - llvm-support is the tests for the llvm/include/{Support,ADT} directories, for instance - so you could group even further with subdirectories cross-project-tests/debuginfo-tests/llvm-prettyprinters/lldb/llvm/support/array.cpp) But, yeah, no big deal. It'll grow as it grows and can be reorganized as needed.

@bulbazord
Copy link
Member

the GDB formatter tests currently only get run if LLVM was built with debug-info. Not sure we have any build-bots out there running this configuration. In this patch we rely on just the debug-info from the LLVM headers (see latest commit). That way the tests get more consistently run (at least our public macOS buildbot runs the cross-project-tests in Release+Asserts).

Thanks for calling this out. It would be very disappointing if we added the tests but no buildbots were running the right configuration to actually run the test.

+1 on the idea overall. I don't have any strong opinions about where you've placed them and you appear to have done your homework.

Copy link
Collaborator

@adrian-prantl adrian-prantl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

@Michael137 Michael137 merged commit 3eeec29 into llvm:main Jan 6, 2026
10 checks passed
@Michael137 Michael137 deleted the cross-project-tests/llvm-lldb-formatter-tests branch January 6, 2026 18:46
Michael137 added a commit that referenced this pull request Jan 6, 2026
…173261)

Depends on:
* #173238

(only last commit relevant for review)

This patch revives the `llvm::PointerIntPair` LLDB data-formatter. The
previous version was commented out because it relied on expression
evaluation and was hence slow/brittle. The formatter in this PR doesn't
rely on evaluating expressions.

Drive-by change:
* removes the `llvm::PointerUnion` formatter which was also commented
out. A future version of it will look very different than it does now,
so there's no point in keeping it because the diff won't be helpful in a
review.
llvm-sync bot pushed a commit to arm/arm-toolchain that referenced this pull request Jan 6, 2026
…erIntPair (#173261)

Depends on:
* llvm/llvm-project#173238

(only last commit relevant for review)

This patch revives the `llvm::PointerIntPair` LLDB data-formatter. The
previous version was commented out because it relied on expression
evaluation and was hence slow/brittle. The formatter in this PR doesn't
rely on evaluating expressions.

Drive-by change:
* removes the `llvm::PointerUnion` formatter which was also commented
out. A future version of it will look very different than it does now,
so there's no point in keeping it because the diff won't be helpful in a
review.
debuginfo-tests/llvm-prettyprinters/lldb/arrayref.cpp
)
target_link_libraries(check-lldb-llvm-support-arrayref PRIVATE LLVMSupport)
target_compile_options(check-lldb-llvm-support-arrayref PRIVATE -g -O0)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello @Michael137

I noticed that if you compile with -D_FORTIFY_SOURCE=2 we now get

In file included from /app/gcc/14.2.0/include/c++/14.2.0/x86_64-pc-linux-gnu/bits/os_defines.h:39,
                 from /app/gcc/14.2.0/include/c++/14.2.0/x86_64-pc-linux-gnu/bits/c++config.h:680,
                 from /app/gcc/14.2.0/include/c++/14.2.0/type_traits:38,
                 from ../include/llvm/ADT/ADL.h:12,
                 from ../include/llvm/ADT/Hashing.h:47,
                 from ../include/llvm/ADT/ArrayRef.h:12,
                 from ../../cross-project-tests/debuginfo-tests/llvm-prettyprinters/lldb/arrayref.cpp:1:
/usr/include/features.h:381:4: warning: #warning _FORTIFY_SOURCE requires compiling with optimization (-O) [-Wcpp]
  381 | #  warning _FORTIFY_SOURCE requires compiling with optimization (-O)
      |    ^~~~~~~

when compiling cross-project-tests. And if compiling with -Werror, the build then fails.

I suppose it's because of the hardcoded "-O0" in the config above.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the ping. Not sure off the top how to best handle this but I'll have a look

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Downstream I worked around it by undefining _FORTIFY_SOURCE when we add -O0 like

-target_compile_options(check-lldb-llvm-support-arrayref PRIVATE -g -O0)
+target_compile_options(check-lldb-llvm-support-arrayref PRIVATE -g -O0 -U_FORTIFY_SOURCE)

but I don't know if there is anything better that can be done.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Heh yea maybe that's worth a shot, thanks! I'll put up a review

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


#--- checks
# CHECK: (lldb) p ArrayRef
# CHECK-NEXT: (llvm::ArrayRef<int>) size=3 {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @Michael137

I randomly see this testcase failing on a downstream build bot. I've seen failures like this:

/repo/llvm/build-all-builtins/projects/cross-project-tests/debuginfo-tests/llvm-prettyprinters/lldb/Output/arrayref.test.tmp/checks:2:15: error: CHECK-NEXT: is not on the line after the previous match
# CHECK-NEXT: (llvm::ArrayRef<int>) size=3 {
              ^
<stdin>:20:1: note: 'next' match was here
(llvm::ArrayRef<int>) size=3 {
^
<stdin>:18:18: note: previous match ended here
(lldb) p ArrayRef
                 ^
<stdin>:19:1: note: non-matching line after previous match is here
1 location added to breakpoint 1
^

Input file: <stdin>
Check file: /repo/llvm/build-all-builtins/projects/cross-project-tests/debuginfo-tests/llvm-prettyprinters/lldb/Output/arrayref.test.tmp/checks

-dump-input=help explains the following input dump.

Input was:
<<<<<<
        .
        .
        .
       15:  7  
       16: -> 8 int main() { return 0; } 
       17:  ^ 
       18: (lldb) p ArrayRef 
       19: 1 location added to breakpoint 1 
       20: (llvm::ArrayRef<int>) size=3 { 
next:2     !~~~~~~~~~~~~~~~~~~~~~~~~~~~~~  error: match on wrong line
       21:  [0] = 1 
       22:  [1] = 2 
       23:  [2] = 3 
       24: } 
       25: (lldb) p MutableArrayRef 
        .
        .
        .
>>>>>>

--

********************
Testing:  0.. 10.. 20.. 30.. 40.. 50.. 60.. 70.. 80.. 90.. 

1 warning(s) in tests
********************
Failed Tests (1):
  cross-project-tests :: debuginfo-tests/llvm-prettyprinters/lldb/arrayref.test

so there something unexpected between the expected lines in the output.
It happens now and then. Any idea what the problem is and if it can be fixed?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm interesting, looks like it's this:

1 location added to breakpoint 1

That would happen on Linux when LLDB finds the breakpoint on main when the process is launched. Might be due to machine load/LLDB sluggishness that the output is printed later than expected. We can probably remove the check for p ArrayRef. Or not make it a CHECK-NEXT.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. I'll keep an eye on our build bot and get back if we see any more flakiness after that.

Michael137 added a commit that referenced this pull request Jan 8, 2026
See #173238 (comment)

On some downstream CI this was flakey because LLDB's `location added to breakpoint` notification would appear after the commands. Simply remove checking for the command for now.
llvm-sync bot pushed a commit to arm/arm-toolchain that referenced this pull request Jan 8, 2026
…tatement

See llvm/llvm-project#173238 (comment)

On some downstream CI this was flakey because LLDB's `location added to breakpoint` notification would appear after the commands. Simply remove checking for the command for now.
navaneethshan pushed a commit to qualcomm/cpullvm-toolchain that referenced this pull request Jan 8, 2026
…#173261)

Depends on:
* llvm/llvm-project#173238

(only last commit relevant for review)

This patch revives the `llvm::PointerIntPair` LLDB data-formatter. The
previous version was commented out because it relied on expression
evaluation and was hence slow/brittle. The formatter in this PR doesn't
rely on evaluating expressions.

Drive-by change:
* removes the `llvm::PointerUnion` formatter which was also commented
out. A future version of it will look very different than it does now,
so there's no point in keeping it because the diff won't be helpful in a
review.
kshitijvp pushed a commit to kshitijvp/llvm-project that referenced this pull request Jan 9, 2026
See llvm#173238 (comment)

On some downstream CI this was flakey because LLDB's `location added to breakpoint` notification would appear after the commands. Simply remove checking for the command for now.
navaneethshan pushed a commit to qualcomm/cpullvm-toolchain that referenced this pull request Jan 9, 2026
…#173261)

Depends on:
* llvm/llvm-project#173238

(only last commit relevant for review)

This patch revives the `llvm::PointerIntPair` LLDB data-formatter. The
previous version was commented out because it relied on expression
evaluation and was hence slow/brittle. The formatter in this PR doesn't
rely on evaluating expressions.

Drive-by change:
* removes the `llvm::PointerUnion` formatter which was also commented
out. A future version of it will look very different than it does now,
so there's no point in keeping it because the diff won't be helpful in a
review.

(cherry picked from commit 9471f53)
navaneethshan pushed a commit to qualcomm/cpullvm-toolchain that referenced this pull request Jan 14, 2026
See llvm/llvm-project#173238 (comment)

On some downstream CI this was flakey because LLDB's `location added to breakpoint` notification would appear after the commands. Simply remove checking for the command for now.

(cherry picked from commit 85f5007)
Priyanshu3820 pushed a commit to Priyanshu3820/llvm-project that referenced this pull request Jan 18, 2026
See llvm#173238 (comment)

On some downstream CI this was flakey because LLDB's `location added to breakpoint` notification would appear after the commands. Simply remove checking for the command for now.
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

Successfully merging this pull request may close these issues.

5 participants