[compiler-rt] r281093 - [asan] Store access_size in the {Stack, Global}AddressDescription objects

Filipe Cabecinhas via llvm-commits llvm-commits at lists.llvm.org
Fri Sep 9 14:09:07 PDT 2016


Author: filcab
Date: Fri Sep  9 16:09:06 2016
New Revision: 281093

URL: http://llvm.org/viewvc/llvm-project?rev=281093&view=rev
Log:
[asan] Store access_size in the {Stack,Global}AddressDescription objects

Summary:
This is important information when we want to describe errors, and should be
part of these descriptions. Otherwise, we need to know the access size when
printing/emitting the description.

Reviewers: kcc, eugenis, vitalybuka

Subscribers: llvm-commits, kubabrecka

Differential Revision: https://reviews.llvm.org/D24387

Modified:
    compiler-rt/trunk/lib/asan/asan_descriptions.cc
    compiler-rt/trunk/lib/asan/asan_descriptions.h

Modified: compiler-rt/trunk/lib/asan/asan_descriptions.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/asan_descriptions.cc?rev=281093&r1=281092&r2=281093&view=diff
==============================================================================
--- compiler-rt/trunk/lib/asan/asan_descriptions.cc (original)
+++ compiler-rt/trunk/lib/asan/asan_descriptions.cc Fri Sep  9 16:09:06 2016
@@ -192,7 +192,8 @@ bool DescribeAddressIfHeap(uptr addr, up
 }
 
 // Stack descriptions
-bool GetStackAddressInformation(uptr addr, StackAddressDescription *descr) {
+bool GetStackAddressInformation(uptr addr, uptr access_size,
+                                StackAddressDescription *descr) {
   AsanThread *t = FindThreadByStackAddress(addr);
   if (!t) return false;
 
@@ -206,6 +207,7 @@ bool GetStackAddressInformation(uptr add
   }
 
   descr->offset = access.offset;
+  descr->access_size = access_size;
   descr->frame_pc = access.frame_pc;
   descr->frame_descr = access.frame_descr;
 
@@ -264,8 +266,8 @@ static void PrintAccessAndVarIntersectio
 
 bool DescribeAddressIfStack(uptr addr, uptr access_size) {
   StackAddressDescription descr;
-  if (!GetStackAddressInformation(addr, &descr)) return false;
-  descr.Print(access_size);
+  if (!GetStackAddressInformation(addr, access_size, &descr)) return false;
+  descr.Print();
   return true;
 }
 
@@ -295,20 +297,22 @@ static void DescribeAddressRelativeToGlo
   Printf("%s", str.data());
 }
 
-bool GetGlobalAddressInformation(uptr addr, GlobalAddressDescription *descr) {
+bool GetGlobalAddressInformation(uptr addr, uptr access_size,
+                                 GlobalAddressDescription *descr) {
   descr->addr = addr;
   int globals_num = GetGlobalsForAddress(addr, descr->globals, descr->reg_sites,
                                          ARRAY_SIZE(descr->globals));
   descr->size = globals_num;
+  descr->access_size = access_size;
   return globals_num != 0;
 }
 
 bool DescribeAddressIfGlobal(uptr addr, uptr access_size,
                              const char *bug_type) {
   GlobalAddressDescription descr;
-  if (!GetGlobalAddressInformation(addr, &descr)) return false;
+  if (!GetGlobalAddressInformation(addr, access_size, &descr)) return false;
 
-  descr.Print(access_size, bug_type);
+  descr.Print(bug_type);
   return true;
 }
 
@@ -316,8 +320,7 @@ void ShadowAddressDescription::Print() c
   Printf("Address %p is located in the %s area.\n", addr, ShadowNames[kind]);
 }
 
-void GlobalAddressDescription::Print(uptr access_size,
-                                     const char *bug_type) const {
+void GlobalAddressDescription::Print(const char *bug_type) const {
   for (int i = 0; i < size; i++) {
     DescribeAddressRelativeToGlobal(addr, access_size, globals[i]);
     if (0 == internal_strcmp(bug_type, "initialization-order-fiasco") &&
@@ -328,7 +331,7 @@ void GlobalAddressDescription::Print(upt
   }
 }
 
-void StackAddressDescription::Print(uptr access_size) const {
+void StackAddressDescription::Print() const {
   Decorator d;
   char tname[128];
   Printf("%s", d.Location());
@@ -431,16 +434,16 @@ AddressDescription::AddressDescription(u
   bool isStackMemory = false;
   if (shouldLockThreadRegistry) {
     ThreadRegistryLock l(&asanThreadRegistry());
-    isStackMemory = GetStackAddressInformation(addr, &data.stack);
+    isStackMemory = GetStackAddressInformation(addr, access_size, &data.stack);
   } else {
-    isStackMemory = GetStackAddressInformation(addr, &data.stack);
+    isStackMemory = GetStackAddressInformation(addr, access_size, &data.stack);
   }
   if (isStackMemory) {
     data.kind = kAddressKindStack;
     return;
   }
 
-  if (GetGlobalAddressInformation(addr, &data.global)) {
+  if (GetGlobalAddressInformation(addr, access_size, &data.global)) {
     data.kind = kAddressKindGlobal;
     return;
   }
@@ -457,14 +460,14 @@ void PrintAddressDescription(uptr addr,
   }
 
   GlobalAddressDescription global_descr;
-  if (GetGlobalAddressInformation(addr, &global_descr)) {
-    global_descr.Print(access_size, bug_type);
+  if (GetGlobalAddressInformation(addr, access_size, &global_descr)) {
+    global_descr.Print(bug_type);
     return;
   }
 
   StackAddressDescription stack_descr;
-  if (GetStackAddressInformation(addr, &stack_descr)) {
-    stack_descr.Print(access_size);
+  if (GetStackAddressInformation(addr, access_size, &stack_descr)) {
+    stack_descr.Print();
     return;
   }
 

Modified: compiler-rt/trunk/lib/asan/asan_descriptions.h
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/asan_descriptions.h?rev=281093&r1=281092&r2=281093&view=diff
==============================================================================
--- compiler-rt/trunk/lib/asan/asan_descriptions.h (original)
+++ compiler-rt/trunk/lib/asan/asan_descriptions.h Fri Sep  9 16:09:06 2016
@@ -132,12 +132,14 @@ struct StackAddressDescription {
   uptr tid;
   uptr offset;
   uptr frame_pc;
+  uptr access_size;
   const char *frame_descr;
 
-  void Print(uptr access_size = 1) const;
+  void Print() const;
 };
 
-bool GetStackAddressInformation(uptr addr, StackAddressDescription *descr);
+bool GetStackAddressInformation(uptr addr, uptr access_size,
+                                StackAddressDescription *descr);
 
 struct GlobalAddressDescription {
   uptr addr;
@@ -145,12 +147,14 @@ struct GlobalAddressDescription {
   static const int kMaxGlobals = 4;
   __asan_global globals[kMaxGlobals];
   u32 reg_sites[kMaxGlobals];
+  uptr access_size;
   u8 size;
 
-  void Print(uptr access_size = 1, const char *bug_type = "") const;
+  void Print(const char *bug_type = "") const;
 };
 
-bool GetGlobalAddressInformation(uptr addr, GlobalAddressDescription *descr);
+bool GetGlobalAddressInformation(uptr addr, uptr access_size,
+                                 GlobalAddressDescription *descr);
 bool DescribeAddressIfGlobal(uptr addr, uptr access_size, const char *bug_type);
 
 // General function to describe an address. Will try to describe the address as




More information about the llvm-commits mailing list