https://bugs.llvm.org/show_bug.cgi?id=43760

            Bug ID: 43760
           Summary: gdb cannot break on function that has thunk
           Product: clang
           Version: 9.0
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: C++
          Assignee: unassignedclangb...@nondot.org
          Reporter: manjian2...@gmail.com
                CC: blitzrak...@gmail.com, dgre...@apple.com,
                    erik.pilking...@gmail.com, llvm-bugs@lists.llvm.org,
                    richard-l...@metafoo.co.uk

```
#include <stdio.h>
class BaseClassOne {
public:
  virtual void foo();
};

class BaseClassTwo {
public:
  virtual void bar();
};

class DeriveClass: public BaseClassOne, BaseClassTwo {
public:
  void foo() override;
  void bar() override;
};

void BaseClassOne::foo() {
  printf("This is BaseClassOne: %p\n", this);
}

void BaseClassTwo::bar() {
  printf("This is BaseClassTwo: %p\n", this);
}

void DeriveClass::foo() {
  printf("This is DeriveClass foo: %p\n", this);
}

void DeriveClass::bar() {
  printf("This is DeriveClass bar: %p\n", this);
}
```

gdb can break on DeriveClass::bar, but not_ZThn8_N11DeriveClass3barEv。The
expression static_cast<BaseClassTwo*>(o)->bar() will not trigger the break
point, because thunk do function inline like the following show:

```
; Function Attrs: nounwind uwtable
define dso_local void @_ZThn8_N11DeriveClass3barEv(%class.DeriveClass*)
unnamed_addr #0 align 2 {
  %2 = getelementptr inbounds %class.DeriveClass, %class.DeriveClass* %0, i64
-1, i32 1
  %3 = bitcast %class.BaseClassTwo* %2 to %class.DeriveClass*
  tail call void @_ZN11DeriveClass3barEv(%class.DeriveClass* %3)
  ret void
}


; Function Attrs: nounwind uwtable
define dso_local void @_ZThn8_N11DeriveClass3barEv(%class.DeriveClass*)
unnamed_addr #0 align 2 {
  %2 = getelementptr inbounds %class.DeriveClass, %class.DeriveClass* %0, i64
-1, i32 1
  %3 = bitcast %class.BaseClassTwo* %2 to %class.DeriveClass*
  %4 = tail call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8],
[29 x i8]* @.str.3, i64 0, i64 0), %class.DeriveClass* %3) #2
  ret void
```

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to