[Lldb-commits] [PATCH] [compiler-rt] ASan debugging API for report info extraction and locating addresses

Alexey Samsonov vonosmas at gmail.com
Fri Sep 12 16:42:54 PDT 2014


Getting closer.

================
Comment at: lib/asan/asan_debugging.cc:35
@@ +34,3 @@
+      descr->name[0] = 0;
+      internal_strncat(descr->name, vars[i].name_pos,
+                         Min(descr->name_size, vars[i].name_len));
----------------
Why not internal_strncpy(descr->name, vars[i].name_pos, Min(descr->name_size - 1, vars[i].name_len)) ?

================
Comment at: lib/asan/asan_debugging.cc:40
@@ +39,3 @@
+      descr->region_kind = "stack";
+      break;
+    }
----------------
s/break/return

================
Comment at: lib/asan/asan_debugging.cc:48
@@ +47,3 @@
+  const char *stack_address_type = nullptr;
+  if (DescribeAddressIfShadow(addr, &stack_address_type, /* print */ false)) {
+    descr->region_kind = stack_address_type;
----------------
See another comment about passing AddressDescription into DescribeAddressIfShadow()

================
Comment at: lib/asan/asan_debugging.cc:55
@@ +54,3 @@
+  if (GetInfoForAddressIfGlobal(addr, descr)) {
+    descr->region_kind = "global";
+    return;
----------------
This should be filled by GtInfoForAddressIfGlobal

================
Comment at: lib/asan/asan_debugging.cc:69
@@ +68,3 @@
+  // Let's assume addr is a heap address.
+  AsanChunkView chunk = FindHeapChunkByAddress(addr);
+  if (!chunk.IsValid()) {
----------------
Consider factoring out filling heap address description into a separate routine. AsanLocateAddress would then be really straightforward.

================
Comment at: lib/asan/asan_globals.cc:105
@@ +104,3 @@
+    } else {
+      CHECK(output_global);
+      if (IsAddressNearGlobal(addr, g)) {
----------------
put CHECK() under if()

================
Comment at: lib/asan/asan_globals.cc:126
@@ +125,3 @@
+    descr->region_size = g.size;
+    return true;
+  }
----------------
You can (and probably should) fill descr->region_type here.

================
Comment at: lib/asan/asan_report.h:44
@@ +43,3 @@
+bool GetInfoForAddressIfGlobal(uptr addr, AddressDescription *descr);
+bool DescribeAddressIfShadow(uptr addr, const char **shadow_type = 0,
+                             bool print = true);
----------------
Why not pass AddressDescription here as well?

http://reviews.llvm.org/D4527






More information about the lldb-commits mailing list