Skip to content

Commit 000febd

Browse files
authored
[lldb][test] Add test-coverage for DW_AT_APPLE_objc_complete_type parsing (#120279)
When given a DIE for an Objective-C interface (which doesn't have a `DW_AT_APPLE_objc_complete_type`), the `DWARFASTParserClang` will try to find the DIE which corresponds to the implementation to complete the interface DIE. The code is here: https://github.com/llvm/llvm-project/blob/d2e7ee77d33e8b3be3b1d4e9bc5bc4c60b62b554/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp#L1718-L1738 However, this was currently not exercised in our test-suite (removing the code above didn't fail any LLDB test). This patch adds a test which exercises this codepath (it will fail if we don't fetch the implementation DIE in the `DWARFASTParserClang`). Something that's not currently clear to me is why `frame var *f` succeeds even without the `DW_AT_APPLE_objc_complete_type` infrastructure. If it's using the ObjC runtime, we should make `expr` do the same, in which case we can remove this code from `DWARFASTParserClang`.
1 parent d7ddc97 commit 000febd

File tree

1 file changed

+65
-0
lines changed

1 file changed

+65
-0
lines changed
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
# REQUIRES: system-darwin
2+
#
3+
# Tests that LLDB correctly finds the implementation
4+
# DIE (with a `DW_AT_APPLE_objc_complete_type`)
5+
# given an interface DIE (without said attribute).
6+
#
7+
# RUN: split-file %s %t
8+
# RUN: %clangxx_host %t/lib.m -c -g -o %t/lib.o
9+
# RUN: %clangxx_host %t/main.m -c -g -o %t/main.o
10+
# RUN: %clangxx_host %t/main.o %t/lib.o -o %t/a.out -framework Foundation
11+
#
12+
# RUN: %lldb %t/a.out \
13+
# RUN: -o "breakpoint set -p 'return' -X main" \
14+
# RUN: -o run \
15+
# RUN: -o "expression *f" \
16+
# RUN: -o exit | FileCheck %s
17+
18+
# CHECK: (lldb) expression *f
19+
# CHECK: (Foo) ${{[0-9]+}} = {
20+
# CHECK: y = 2
21+
# CHECK-NEXT: i = 1
22+
23+
#--- main.m
24+
#import <Foundation/Foundation.h>
25+
#import "lib.h"
26+
27+
extern Foo * func();
28+
29+
int main() {
30+
Foo * f = func();
31+
return 0;
32+
}
33+
34+
#--- lib.m
35+
#import <Foundation/Foundation.h>
36+
#import "lib.h"
37+
38+
@implementation Foo {
39+
int i;
40+
}
41+
42+
- (id)init {
43+
self->i = 1;
44+
self->y = 2;
45+
46+
return self;
47+
}
48+
@end
49+
50+
Foo * func() {
51+
return [[Foo alloc] init];
52+
}
53+
54+
#--- lib.h
55+
#ifndef LIB_H_IN
56+
#define LIB_H_IN
57+
58+
#import <Foundation/Foundation.h>
59+
60+
@interface Foo : NSObject {
61+
int y;
62+
}
63+
@end
64+
65+
#endif // _H_IN

0 commit comments

Comments
 (0)