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

Alexey Samsonov vonosmas at gmail.com
Mon Sep 8 17:16:58 PDT 2014


================
Comment at: lib/asan/asan_globals.cc:85
@@ -84,2 +84,3 @@
 
-bool DescribeAddressIfGlobal(uptr addr, uptr size) {
+bool DescribeOrGetInfoIfGlobal(uptr addr, uptr size, bool only_get_info,
+                               char *name, uptr name_size, uptr *region_address,
----------------
Can you make this function do one of the following:
(1) print the address description (what it does now) if "print" input parameter is true
(2) set __asan_global output parameter to the structure describing the global.
Then you won't need GetInfoForAddressRelativeToGlobal at all.

================
Comment at: lib/asan/asan_globals.cc:108
@@ +107,3 @@
+bool DescribeAddressIfGlobal(uptr addr, uptr size) {
+  return DescribeOrGetInfoIfGlobal(addr, size, /* only_get_info */ false, 0, 0,
+                                   0, 0);
----------------
See above: passing a pack of fake parameters is ugly. Instead you can call this function in two modes:
  DescrineOrGetInfoForGlobal(addr, size, /*print*/true, /*global*/nullptr);
or
  Global g;
  DescribeOrGetInfoForGlobal(addr, 1, /*print*/false, &g);

================
Comment at: lib/asan/asan_report.cc:294
@@ +293,3 @@
+    if (name_len > name_size - 1) name_len = name_size - 1;
+    memcpy(name, g.name, name_len);
+    name[name_len] = '\0';
----------------
Consider using internal_strncpy here.

================
Comment at: lib/asan/asan_report.cc:308
@@ -273,2 +307,3 @@
   if (AddrIsInShadowGap(addr)) {
-    Printf(kAddrInShadowReport, addr, "shadow gap area");
+    if (shadow_type) *shadow_type = "shadow-gap";
+    if (print) Printf(kAddrInShadowReport, addr, "shadow gap area");
----------------
Can you use the identical strings in the output and in shadow_type variable? That is, make shadow_type equal to "shadow gap", or "high shadow", or "low shadow".

================
Comment at: lib/asan/asan_report.cc:990
@@ +989,3 @@
+
+  ScopedInErrorReport in_report;
+
----------------
Why have you moved ScopedInErrorReport here?

================
Comment at: lib/asan/asan_report.cc:1058
@@ +1057,3 @@
+uptr __asan_get_report_access_size() {
+  return report_data.access_size;
+}
----------------
Any specific reason to not expose report_data structure layout in the interface header? This pack of functions doesn't look nice.

http://reviews.llvm.org/D4527






More information about the llvm-commits mailing list