Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 65 additions & 0 deletions lldb/test/Shell/Expr/TestObjCHiddenIvars.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
# REQUIRES: system-darwin
#
# Tests that LLDB correctly finds the implementation
# DIE (with a `DW_AT_APPLE_objc_complete_type`)
# given an interface DIE (without said attribute).
#
# RUN: split-file %s %t
# RUN: %clangxx_host %t/lib.m -c -g -o %t/lib.o
# RUN: %clangxx_host %t/main.m -c -g -o %t/main.o
# RUN: %clangxx_host %t/main.o %t/lib.o -o %t/a.out -framework Foundation
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think this needs a REQUIRES: system-darwin.

For science, I also tried to make a version of this test which could run on other systems, but all I managed is to hit an (lldb)assert:

$ cat a.m 
__attribute__((objc_root_class)) @interface  Foo  {
int y;
}
@end

#ifdef DEF
@implementation Foo {
    int i;
}

- (id)init {
  self->i = 1;
  self->y = 2;

  return self;
}
@end
#endif

Foo *foo;
$ clang -c a.m -g -DDEF --target=aarch64-apple-macosx
$ lldb a.o -o "target variable foo[0]"
(lldb) target create "a.o"
Current executable set to '/tmp/a.o' (arm64).
(lldb) target variable foo[0]
warning: trying to determine the size of type @interface Foo{
    int y;
    int i;
}
@end
without a valid ExecutionContext. this is not reliable. please file a bug against LLDB.
backtrace:
 #0 0x00007f117b0ab29e llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) llvm/lib/Support/Unix/Signals.inc:723:22
 #1 0x00007f117af11e90 lldb_private::TypeSystemClang::GetObjCBitSize(clang::QualType, lldb_private::ExecutionContextScope*) lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp:4780:17

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 trying! Yea I'll probably add the Darwin requirement then

#
# RUN: %lldb %t/a.out \
# RUN: -o "breakpoint set -p 'return' -X main" \
# RUN: -o run \
# RUN: -o "expression *f" \
# RUN: -o exit | FileCheck %s

# CHECK: (lldb) expression *f
# CHECK: (Foo) ${{[0-9]+}} = {
# CHECK: y = 2
# CHECK-NEXT: i = 1

#--- main.m
#import <Foundation/Foundation.h>
#import "lib.h"

extern Foo * func();

int main() {
Foo * f = func();
return 0;
}

#--- lib.m
#import <Foundation/Foundation.h>
#import "lib.h"

@implementation Foo {
int i;
}

- (id)init {
self->i = 1;
self->y = 2;

return self;
}
@end

Foo * func() {
return [[Foo alloc] init];
}

#--- lib.h
#ifndef LIB_H_IN
#define LIB_H_IN

#import <Foundation/Foundation.h>

@interface Foo : NSObject {
int y;
}
@end

#endif // _H_IN
Loading