Michael137 created this revision. Michael137 added reviewers: aprantl, jingham. Herald added a project: All. Michael137 requested review of this revision. Herald added a project: LLDB. Herald added a subscriber: lldb-commits.
The `UBSAN`/`ASAN` plugins would previously call the internal helper structure injected into the source expression `struct data { ... };` This occasionally collided with user-defined types of the same (quite common) name and lead to failures running the injected `InstrumentationRuntime` expressions or simply crash during `ASTImport`. This patch makes these structures anonymous so there's not chance of clashing with other types in the program. This is already the approach taken in `UBSan/InstrumentationRuntimeABSan.cpp`. **Testing** - API tests still pass Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D145569 Files: lldb/source/Plugins/InstrumentationRuntime/UBSan/InstrumentationRuntimeUBSan.cpp lldb/source/Plugins/MemoryHistory/asan/MemoryHistoryASan.cpp Index: lldb/source/Plugins/MemoryHistory/asan/MemoryHistoryASan.cpp =================================================================== --- lldb/source/Plugins/MemoryHistory/asan/MemoryHistoryASan.cpp +++ lldb/source/Plugins/MemoryHistory/asan/MemoryHistoryASan.cpp @@ -67,8 +67,11 @@ size_t __asan_get_alloc_stack(void *addr, void **trace, size_t size, int *thread_id); size_t __asan_get_free_stack(void *addr, void **trace, size_t size, int *thread_id); } +)"; - struct data { +const char *memory_history_asan_command_format = + R"( + struct { void *alloc_trace[256]; size_t alloc_count; int alloc_tid; @@ -76,12 +79,7 @@ void *free_trace[256]; size_t free_count; int free_tid; - }; -)"; - -const char *memory_history_asan_command_format = - R"( - data t; + } t; t.alloc_count = __asan_get_alloc_stack((void *)0x%)" PRIx64 R"(, t.alloc_trace, 256, &t.alloc_tid); Index: lldb/source/Plugins/InstrumentationRuntime/UBSan/InstrumentationRuntimeUBSan.cpp =================================================================== --- lldb/source/Plugins/InstrumentationRuntime/UBSan/InstrumentationRuntimeUBSan.cpp +++ lldb/source/Plugins/InstrumentationRuntime/UBSan/InstrumentationRuntimeUBSan.cpp @@ -67,19 +67,18 @@ const char **OutMessage, const char **OutFilename, unsigned *OutLine, unsigned *OutCol, char **OutMemoryAddr); } +)"; -struct data { +static const char *ub_sanitizer_retrieve_report_data_command = R"( +struct { const char *issue_kind; const char *message; const char *filename; unsigned line; unsigned col; char *memory_addr; -}; -)"; +} t; -static const char *ub_sanitizer_retrieve_report_data_command = R"( -data t; __ubsan_get_current_report_data(&t.issue_kind, &t.message, &t.filename, &t.line, &t.col, &t.memory_addr); t;
Index: lldb/source/Plugins/MemoryHistory/asan/MemoryHistoryASan.cpp =================================================================== --- lldb/source/Plugins/MemoryHistory/asan/MemoryHistoryASan.cpp +++ lldb/source/Plugins/MemoryHistory/asan/MemoryHistoryASan.cpp @@ -67,8 +67,11 @@ size_t __asan_get_alloc_stack(void *addr, void **trace, size_t size, int *thread_id); size_t __asan_get_free_stack(void *addr, void **trace, size_t size, int *thread_id); } +)"; - struct data { +const char *memory_history_asan_command_format = + R"( + struct { void *alloc_trace[256]; size_t alloc_count; int alloc_tid; @@ -76,12 +79,7 @@ void *free_trace[256]; size_t free_count; int free_tid; - }; -)"; - -const char *memory_history_asan_command_format = - R"( - data t; + } t; t.alloc_count = __asan_get_alloc_stack((void *)0x%)" PRIx64 R"(, t.alloc_trace, 256, &t.alloc_tid); Index: lldb/source/Plugins/InstrumentationRuntime/UBSan/InstrumentationRuntimeUBSan.cpp =================================================================== --- lldb/source/Plugins/InstrumentationRuntime/UBSan/InstrumentationRuntimeUBSan.cpp +++ lldb/source/Plugins/InstrumentationRuntime/UBSan/InstrumentationRuntimeUBSan.cpp @@ -67,19 +67,18 @@ const char **OutMessage, const char **OutFilename, unsigned *OutLine, unsigned *OutCol, char **OutMemoryAddr); } +)"; -struct data { +static const char *ub_sanitizer_retrieve_report_data_command = R"( +struct { const char *issue_kind; const char *message; const char *filename; unsigned line; unsigned col; char *memory_addr; -}; -)"; +} t; -static const char *ub_sanitizer_retrieve_report_data_command = R"( -data t; __ubsan_get_current_report_data(&t.issue_kind, &t.message, &t.filename, &t.line, &t.col, &t.memory_addr); t;
_______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits