[compiler-rt] [sanitizer_common] [Darwin] Add inline frame support for AtosSymbolizer (PR #170815)

Mariusz Borsa via llvm-commits llvm-commits at lists.llvm.org
Thu Dec 11 12:03:33 PST 2025


================
@@ -161,31 +168,57 @@ bool AtosSymbolizer::SymbolizePC(uptr addr, SymbolizedStack *stack) {
   char command[32];
   internal_snprintf(command, sizeof(command), "0x%zx\n", addr);
   const char *buf = process_->SendCommand(command);
-  if (!buf) return false;
-  uptr line;
-  uptr start_address = AddressInfo::kUnknown;
-  if (!ParseCommandOutput(buf, addr, &stack->info.function, &stack->info.module,
-                          &stack->info.file, &line, &start_address)) {
-    Report("WARNING: atos failed to symbolize address \"0x%zx\"\n", addr);
+  if (!buf)
     return false;
-  }
-  stack->info.line = (int)line;
-
-  if (start_address == AddressInfo::kUnknown) {
-    // Fallback to dladdr() to get function start address if atos doesn't report
-    // it.
-    Dl_info info;
-    int result = dladdr((const void *)addr, &info);
-    if (result)
-      start_address = reinterpret_cast<uptr>(info.dli_saddr);
-  }
 
-  // Only assign to `function_offset` if we were able to get the function's
-  // start address and we got a sensible `start_address` (dladdr doesn't always
-  // ensure that `addr >= sym_addr`).
-  if (start_address != AddressInfo::kUnknown && addr >= start_address) {
-    stack->info.function_offset = addr - start_address;
+  SymbolizedStack* last = stack;
+  bool top_frame = true;
+
+  while (*buf != '\n') {
+    uptr line;
+    uptr start_address = AddressInfo::kUnknown;
+
+    SymbolizedStack* cur;
+    if (top_frame) {
+      cur = stack;
+    } else {
+      cur = SymbolizedStack::New(stack->info.address);
+      cur->info.FillModuleInfo(stack->info.module, stack->info.module_offset,
+                               stack->info.module_arch);
+      last->next = cur;
+      last = cur;
+    }
+
+    if (!ParseCommandOutput(&buf, addr, &cur->info.function, &cur->info.module,
----------------
wrotki wrote:

ParseCommandOutput could return  std::pair<char*, bool> (next buf and return status) - this way you could avoid it to modify buf via this ugly side effect. Look at ParseSymbolizePCOutput you model this off - it calls ParseFileLineInfo(info, str), which return next str and the loop is controlled by that (i.e. it breaks when it has nothing left)

https://github.com/llvm/llvm-project/pull/170815


More information about the llvm-commits mailing list