[PATCH] D67671: compiler-rt/lib/tsan: allow the Go runtime to return multiple stack frames for a single PC

Keith Randall via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 17 12:29:13 PDT 2019


randall77 updated this revision to Diff 220554.
randall77 added a comment.
Herald added a subscriber: dexonsmith.

Upload right patch this time.


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

https://reviews.llvm.org/D67671

Files:
  lib/tsan/go/tsan_go.cpp


Index: lib/tsan/go/tsan_go.cpp
===================================================================
--- lib/tsan/go/tsan_go.cpp
+++ lib/tsan/go/tsan_go.cpp
@@ -54,20 +54,31 @@
 };
 
 SymbolizedStack *SymbolizeCode(uptr addr) {
-  SymbolizedStack *s = SymbolizedStack::New(addr);
-  SymbolizeCodeContext cbctx;
-  internal_memset(&cbctx, 0, sizeof(cbctx));
-  cbctx.pc = addr;
-  go_runtime_cb(CallbackSymbolizeCode, &cbctx);
-  if (cbctx.res) {
+  SymbolizedStack *first = SymbolizedStack::New(addr);
+  SymbolizedStack *s = first;
+  for (;;) {
+    SymbolizeCodeContext cbctx;
+    internal_memset(&cbctx, 0, sizeof(cbctx));
+    cbctx.pc = addr;
+    go_runtime_cb(CallbackSymbolizeCode, &cbctx);
+    if (cbctx.res == 0)
+      break;
     AddressInfo &info = s->info;
     info.module_offset = cbctx.off;
     info.function = internal_strdup(cbctx.func ? cbctx.func : "??");
     info.file = internal_strdup(cbctx.file ? cbctx.file : "-");
     info.line = cbctx.line;
     info.column = 0;
+
+    if (cbctx.pc == addr) // outermost (non-inlined) function
+      break;
+    addr = cbctx.pc;
+    // Allocate a stack entry for the parent of the inlined function.
+    SymbolizedStack *s2 = SymbolizedStack::New(addr);
+    s->next = s2;
+    s = s2;
   }
-  return s;
+  return first;
 }
 
 struct SymbolizeDataContext {


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D67671.220554.patch
Type: text/x-patch
Size: 1325 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190917/0f96fc2d/attachment.bin>


More information about the llvm-commits mailing list