[Lldb-commits] [PATCH] D71487: [LLDB] Fix address computation for member function linked with lld

Johannes Altmanninger via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Fri Dec 13 12:51:08 PST 2019


johannes updated this revision to Diff 233856.
johannes edited the summary of this revision.
johannes added a comment.

typo


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D71487/new/

https://reviews.llvm.org/D71487

Files:
  lldb/source/Expression/IRExecutionUnit.cpp
  lldb/test/Shell/Expr/Inputs/function-address-lib.cpp
  lldb/test/Shell/Expr/Inputs/function-address-main.cpp
  lldb/test/Shell/Expr/Inputs/function-address-shared.h
  lldb/test/Shell/Expr/TestFunctionAddress.lldb


Index: lldb/test/Shell/Expr/TestFunctionAddress.lldb
===================================================================
--- /dev/null
+++ lldb/test/Shell/Expr/TestFunctionAddress.lldb
@@ -0,0 +1,9 @@
+# RUN: %clangxx_host %p/Inputs/function-address-main.cpp %p/Inputs/function-address-lib.cpp -g -fuse-ld=lld -o %t
+# RUN: %lldb %t -s %s 2>&1 | FileCheck %s
+b main
+run
+next
+expr argv.four()
+# CHECK: expr argv.four()
+# CHECK-NEXT: (int) $0 = 4
+# CHECK-NOT: SIGSEGV
Index: lldb/test/Shell/Expr/Inputs/function-address-shared.h
===================================================================
--- /dev/null
+++ lldb/test/Shell/Expr/Inputs/function-address-shared.h
@@ -0,0 +1,23 @@
+#ifndef function_address_shared_h
+#define function_address_shared_h
+namespace llvm_namespace {
+struct TinyVectorBase {
+  int SomeInlineInitializedMember = 0;
+};
+struct TinyVector : TinyVectorBase {
+  TinyVector *Self;
+
+  TinyVector() : Self(getFirstEl()) {}
+  TinyVector(bool) : TinyVector() { nop(four()); }
+  int four() const { return 4; }
+  TinyVector *getFirstEl() { return this; }
+  char *begin() { return nullptr; }
+  char *end() { return begin() + four(); }
+  void clear() { nop(begin()), nop(end()); }
+
+  void nop(void *) {}
+  void nop(int) {}
+};
+} // end namespace llvm_namespace
+using llvm_namespace::TinyVector;
+#endif // function_address_shared_h
Index: lldb/test/Shell/Expr/Inputs/function-address-main.cpp
===================================================================
--- /dev/null
+++ lldb/test/Shell/Expr/Inputs/function-address-main.cpp
@@ -0,0 +1,4 @@
+#include "function-address-shared.h"
+int main() {
+    TinyVector argv(true);
+}
Index: lldb/test/Shell/Expr/Inputs/function-address-lib.cpp
===================================================================
--- /dev/null
+++ lldb/test/Shell/Expr/Inputs/function-address-lib.cpp
@@ -0,0 +1,4 @@
+#include "function-address-shared.h"
+void (*ErrorHandler)();
+void LLVMErrorHandler() { TinyVector().clear(); }
+void SetErrorHandler() { ErrorHandler = LLVMErrorHandler; }
Index: lldb/source/Expression/IRExecutionUnit.cpp
===================================================================
--- lldb/source/Expression/IRExecutionUnit.cpp
+++ lldb/source/Expression/IRExecutionUnit.cpp
@@ -830,6 +830,9 @@
 
         if (load_address != LLDB_INVALID_ADDRESS) {
           if (is_external) {
+            // Keep looking for a function entry with a symbol.
+            if (candidate_sc.function && !candidate_sc.symbol)
+                continue;
             return true;
           } else if (best_internal_load_address == LLDB_INVALID_ADDRESS) {
             best_internal_load_address = load_address;
@@ -844,8 +847,8 @@
         load_address = 0;
         return true;
       }
-      
-      return false;
+
+      return load_address != LLDB_INVALID_ADDRESS;
     };
 
     if (sc.module_sp) {


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D71487.233856.patch
Type: text/x-patch
Size: 2890 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20191213/f2e132c5/attachment-0001.bin>


More information about the lldb-commits mailing list