[PATCH] D24131: Add NewAddressDescription, which can describe any type of address.
Vitaly Buka via llvm-commits
llvm-commits at lists.llvm.org
Wed Sep 7 10:27:25 PDT 2016
vitalybuka requested changes to this revision.
This revision now requires changes to proceed.
================
Comment at: lib/asan/asan_debugging.cc:87
@@ +86,3 @@
+ if (name && name_size > 0) name[0] = 0;
+ switch (descr.kind) {
+ case kAddressKindWild:
----------------
filcab wrote:
> If we add the default case, we get a clang warning, though. I can add a check that we have one of those, before the switch, but it will end up ugly:
>
> `CHECK(descr.kind == kAddressKindWild || descr.kind == kAddressKindShadow || ...);`
> Should we also fix places like PrintHeapChunkAccess in asan_descriptions.cc, which does the same thing (not have a default case)?
>
We have another internal switch so assert(region_kind) just before return should cover both
================
Comment at: lib/asan/asan_debugging.cc:108
@@ +107,3 @@
+ region_kind = "heap";
+ if (name && name_size > 0) name[0] = 0;
+ region_address = descr.heap.chunk_access.chunk_begin;
----------------
name[0] = 0; is already done at entry
================
Comment at: lib/asan/asan_debugging.cc:115
@@ +114,3 @@
+ if (!descr.stack.frame_descr) {
+ if (name && name_size > 0) name[0] = 0;
+ // region_{address,size} are already 0
----------------
name[0] = 0; is already done at entry
================
Comment at: lib/asan/asan_descriptions.h:185
@@ +184,3 @@
+ // We should be able to do without this struct after we deprecate VS2013.
+ AddressKind kind;
+ union {
----------------
I see.
How about following?
```
struct AddressDescriptionData {
AddressKind kind;
union {
ShadowAddressDescription shadow;
HeapAddressDescription heap;
StackAddressDescription stack;
GlobalAddressDescription global;
uptr addr;
};
// No methods.
}
class AddressDescription {
private:
AddressDescriptionData data;
public:
AddressDescription() {
...
}
uptr Address() const ;
uptr Print() const ;
const ShadowAddressDescription* AsShadowAddress() const {
return "kind is ShadowAddress" ? &shadow : nullptr;
};
}
```
https://reviews.llvm.org/D24131
More information about the llvm-commits
mailing list