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

Alexey Samsonov vonosmas at gmail.com
Thu Sep 11 15:09:12 PDT 2014


================
Comment at: lib/asan/asan_debugging.cc:38
@@ +37,3 @@
+        uptr var_name_len = vars[i].name_len;
+        if (vars[i].name_len > name_size - 1) var_name_len = name_size - 1;
+        memcpy(name, vars[i].name_pos, var_name_len);
----------------
internal_strncpy?

================
Comment at: lib/asan/asan_debugging.cc:121
@@ +120,3 @@
+                                  uptr *region_address, uptr *region_size) {
+  return AsanLocateAddress(addr, name, name_size, region_address, region_size);
+}
----------------
Consider introducing a struct for address description instead of passing quadruple (name, name_size, region_address, region_size) around. It would be much easier to modify it later. You can also add region_kind ("global", "stack" etc.) string there.

================
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 print,
+                               Global *output_global) {
----------------
This function can be static.

================
Comment at: lib/asan/asan_globals.cc:98
@@ +97,3 @@
+      if (IsAddressNearGlobal(addr, g)) {
+        if (output_global) *output_global = g;
+        return true;
----------------
I believe output_global should always be nonnull in this case. Remove the if() and optionally add a CHECK.

================
Comment at: lib/asan/asan_interface_internal.h:97
@@ +96,3 @@
+
+  // The following functions extract various information from a report (if a
+  // report has already been printed out or is currently being generated).
----------------
Don't duplicate the comments here.

================
Comment at: lib/asan/asan_report.cc:253
@@ -241,1 +252,3 @@
+
+bool IsAddressNearGlobal(uptr addr, const __asan_global &g) {
   if (addr <= g.beg - kMinimalDistanceFromAnotherGlobal) return false;
----------------
This clearly belongs to asan_globals.cc

================
Comment at: lib/asan/asan_report.cc:298
@@ -283,1 +297,3 @@
+    if (print) Printf(kAddrInShadowReport, addr, area_type);
+    if (output_type) *output_type = area_type;
     return true;
----------------
I guess that if print() is false, output_type should be nonnull.

================
Comment at: lib/asan/asan_report.cc:961
@@ +960,3 @@
+  report_happened = true;
+  report_data.description = bug_descr;
+  report_data.pc = pc;
----------------
Can you use aggregate assignment here?
  report_data = { ... };

http://reviews.llvm.org/D4527






More information about the lldb-commits mailing list