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

Mariusz Borsa via llvm-commits llvm-commits at lists.llvm.org
Wed Dec 17 00:07:16 PST 2025


================
@@ -161,31 +177,73 @@ 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;
+
+  // Parse one line of input (i.e. one frame).
+  //
+  // When symbolize_inline_frames=true, an empty line
+  // (i.e. \n at the beginning of a line) indicates that the last
+  // frame has been sent.
+  //
+  // When symbolize_inline_frames=false, the symbolizer will send only
+  // one frame (without a empty line), so loop runs exactly once
+  // and hits an early `break`.
+  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;
+    }
+
+    // Parse one line of input (i.e. one frame)
+    // If this succeeds, buf will be updated to point to the first character
+    // after the newline.
+    buf = ParseCommandOutput(buf, addr, &cur->info.function, &cur->info.module,
+                             &cur->info.file, &line, &start_address);
+
+    // Upon failure, ParseCommandOutput returns NULL.
+    if (!buf) {
+      Report("WARNING: atos failed to symbolize buf address \"0x%zx\"\n", addr);
+      break;
+      // return false;
----------------
wrotki wrote:

Delete?

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


More information about the llvm-commits mailing list