Skip to content

Commit 91c07ee

Browse files
committed
[lldb][test] Add test-coverage for DW_AT_APPLE_objc_complete_type parsing
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, which should make `expr` do the same, in which case we can remove this code from `DWARFASTParserClang`.
1 parent fbbf1be commit 91c07ee

File tree

1 file changed

+63
-0
lines changed

1 file changed

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

0 commit comments

Comments
 (0)