24int __asan_report_present();
25void *__asan_get_report_pc();
26void *__asan_get_report_bp();
27void *__asan_get_report_sp();
28void *__asan_get_report_address();
29const char *__asan_get_report_description();
30int __asan_get_report_access_type();
31size_t __asan_get_report_access_size();
44 const char *description;
47t.present = __asan_report_present();
48t.access_type = __asan_get_report_access_type();
49t.pc = __asan_get_report_pc();
50t.bp = __asan_get_report_bp();
51t.sp = __asan_get_report_sp();
52t.address = __asan_get_report_address();
53t.access_size = __asan_get_report_access_size();
54t.description = __asan_get_report_description();
64 process_sp->GetThreadList().GetExpressionExecutionThread();
80 options.
SetTimeout(process_sp->GetUtilityExpressionTimeout());
87 frame_sp->CalculateExecutionContext(exe_ctx);
93 ss <<
"cannot evaluate AddressSanitizer expression:\n";
95 ss << return_value_sp->GetError().AsCString();
97 process_sp->GetTarget().GetDebugger().GetID());
101 int present = return_value_sp->GetValueForExpressionPath(
".present")
102 ->GetValueAsUnsigned(0);
107 return_value_sp->GetValueForExpressionPath(
".pc")->GetValueAsUnsigned(0);
109 return_value_sp->GetValueForExpressionPath(
".bp")->GetValueAsUnsigned(0);
111 return_value_sp->GetValueForExpressionPath(
".sp")->GetValueAsUnsigned(0);
112 addr_t address = return_value_sp->GetValueForExpressionPath(
".address")
113 ->GetValueAsUnsigned(0);
115 return_value_sp->GetValueForExpressionPath(
".access_type")
116 ->GetValueAsUnsigned(0);
118 return_value_sp->GetValueForExpressionPath(
".access_size")
119 ->GetValueAsUnsigned(0);
121 return_value_sp->GetValueForExpressionPath(
".description")
122 ->GetValueAsUnsigned(0);
123 std::string description;
125 process_sp->ReadCStringFromMemory(description_ptr, description,
error);
127 auto dict = std::make_shared<StructuredData::Dictionary>();
131 dict->AddStringItem(
"instrumentation_class",
"AddressSanitizer");
132 dict->AddStringItem(
"stop_type",
"fatal_error");
133 dict->AddIntegerItem(
"pc",
pc);
134 dict->AddIntegerItem(
"bp", bp);
135 dict->AddIntegerItem(
"sp",
sp);
136 dict->AddIntegerItem(
"address", address);
137 dict->AddIntegerItem(
"access_type", access_type);
138 dict->AddIntegerItem(
"access_size", access_size);
139 dict->AddStringItem(
"description", description);
146 std::string description = std::string(report->GetAsDictionary()
147 ->GetValueForKey(
"description")
150 return llvm::StringSwitch<std::string>(description)
151 .Case(
"heap-use-after-free",
"Use of deallocated memory")
152 .Case(
"heap-buffer-overflow",
"Heap buffer overflow")
153 .Case(
"stack-buffer-underflow",
"Stack buffer underflow")
154 .Case(
"initialization-order-fiasco",
"Initialization order problem")
155 .Case(
"stack-buffer-overflow",
"Stack buffer overflow")
156 .Case(
"stack-use-after-return",
"Use of stack memory after return")
157 .Case(
"use-after-poison",
"Use of poisoned memory")
158 .Case(
"container-overflow",
"Container overflow")
159 .Case(
"stack-use-after-scope",
"Use of out-of-scope stack memory")
160 .Case(
"global-buffer-overflow",
"Global buffer overflow")
161 .Case(
"unknown-crash",
"Invalid memory access")
162 .Case(
"stack-overflow",
"Stack space exhausted")
163 .Case(
"null-deref",
"Dereference of null pointer")
164 .Case(
"wild-jump",
"Jump to non-executable address")
165 .Case(
"wild-addr-write",
"Write through wild pointer")
166 .Case(
"wild-addr-read",
"Read from wild pointer")
167 .Case(
"wild-addr",
"Access through wild pointer")
168 .Case(
"signal",
"Deadly signal")
169 .Case(
"double-free",
"Deallocation of freed memory")
170 .Case(
"new-delete-type-mismatch",
171 "Deallocation size different from allocation size")
172 .Case(
"bad-free",
"Deallocation of non-allocated memory")
173 .Case(
"alloc-dealloc-mismatch",
174 "Mismatch between allocation and deallocation APIs")
175 .Case(
"bad-malloc_usable_size",
"Invalid argument to malloc_usable_size")
176 .Case(
"bad-__sanitizer_get_allocated_size",
177 "Invalid argument to __sanitizer_get_allocated_size")
178 .Case(
"param-overlap",
179 "Call to function disallowing overlapping memory ranges")
180 .Case(
"negative-size-param",
"Negative size used when accessing memory")
181 .Case(
"bad-__sanitizer_annotate_contiguous_container",
182 "Invalid argument to __sanitizer_annotate_contiguous_container")
183 .Case(
"odr-violation",
"Symbol defined in multiple translation units")
185 "invalid-pointer-pair",
186 "Comparison or arithmetic on pointers from different memory regions")
188 .Default(
"AddressSanitizer detected: " + description);
199 if (process_sp->GetModIDRef().IsLastResumeForUserExpression())
209 thread_sp->SetStopInfo(
211 *thread_sp, description, report));
214 process_sp->GetTarget().GetDebugger().GetOutputStreamSP()))
215 stream_sp->Printf(
"AddressSanitizer report breakpoint hit. Use 'thread "
216 "info -s' to get extended information about the "
226 if (!module_sp || !process_sp)
230 module_sp->FindFirstSymbolWithNameAndType(symbol_name,
eSymbolTypeCode);
232 if (symbol ==
nullptr)
238 Target &target = process_sp->GetTarget();
244 const bool internal =
true;
245 const bool hardware =
false;
static llvm::raw_ostream & error(Stream &strm)
const char * address_sanitizer_retrieve_report_data_command
const char * address_sanitizer_retrieve_report_data_prefix
lldb::addr_t GetOpcodeLoadAddress(Target *target, AddressClass addr_class=AddressClass::eInvalid) const
Get the load address as an opcode load address.
bool IsValid() const
Check if the object state is valid.
General Outline: A breakpoint has four main parts, a filter, a resolver, the list of breakpoint locat...
Target & GetTarget()
Accessor for the breakpoint Target.
A uniqued constant string class.
static void ReportWarning(std::string message, std::optional< lldb::user_id_t > debugger_id=std::nullopt, std::once_flag *once=nullptr)
Report warning events.
void SetUnwindOnError(bool unwind=false)
void SetLanguage(lldb::LanguageType language_type)
void SetPrefix(const char *prefix)
void SetTryAllThreads(bool try_others=true)
void SetTimeout(const Timeout< std::micro > &timeout)
void SetAutoApplyFixIts(bool b)
void SetStopOthers(bool stop_others=true)
void SetIgnoreBreakpoints(bool ignore=false)
lldb::ThreadSP GetThreadSP() const
Get accessor that creates a strong reference from the weak thread reference contained in this object.
lldb::ProcessSP GetProcessSP() const
Get accessor that creates a strong reference from the weak process reference contained in this object...
"lldb/Target/ExecutionContext.h" A class that contains an execution context.
static lldb::StopInfoSP CreateStopReasonWithInstrumentationData(Thread &thread, std::string description, StructuredData::ObjectSP additional_data)
static StructuredData::ObjectSP RetrieveReportData(const lldb::ProcessSP process_sp)
static bool NotifyBreakpointHit(lldb::ProcessSP process_sp, StoppointCallbackContext *context, lldb::user_id_t break_id, lldb::user_id_t break_loc_id)
static std::string FormatDescription(StructuredData::ObjectSP report)
static Breakpoint * SetupBreakpoint(lldb::ModuleSP, lldb::ProcessSP, ConstString)
General Outline: When we hit a breakpoint we need to package up whatever information is needed to eva...
ExecutionContextRef exe_ctx_ref
llvm::StringRef GetString() const
std::shared_ptr< Object > ObjectSP
bool ValueIsAddress() const
Address & GetAddressRef()
lldb::BreakpointSP CreateBreakpoint(const FileSpecList *containingModules, const FileSpec &file, uint32_t line_no, uint32_t column, lldb::addr_t offset, LazyBool check_inlines, LazyBool skip_prologue, bool internal, bool request_hardware, LazyBool move_to_nearest_code)
static lldb::ExpressionResults Evaluate(ExecutionContext &exe_ctx, const EvaluateExpressionOptions &options, llvm::StringRef expr_cstr, llvm::StringRef expr_prefix, lldb::ValueObjectSP &result_valobj_sp, std::string *fixed_expression=nullptr, ValueObject *ctx_obj=nullptr)
Evaluate one expression in the scratch context of the target passed in the exe_ctx and return its res...
#define LLDB_INVALID_ADDRESS
@ DoNoSelectMostRelevantFrame
A class that represents a running process on the host machine.
std::shared_ptr< lldb_private::StackFrame > StackFrameSP
std::shared_ptr< lldb_private::Thread > ThreadSP
std::shared_ptr< lldb_private::ValueObject > ValueObjectSP
@ eLanguageTypeObjC_plus_plus
Objective-C++.
ExpressionResults
The results of expression evaluation.
std::shared_ptr< lldb_private::Process > ProcessSP
std::shared_ptr< lldb_private::StreamFile > StreamFileSP
@ eStructuredDataTypeDictionary
std::shared_ptr< lldb_private::Module > ModuleSP