34 if (!process_sp.get())
37 Target &target = process_sp->GetTarget();
40 const Symbol *symbol = module_sp->FindFirstSymbolWithNameAndType(
43 if (symbol !=
nullptr)
67 size_t __asan_get_alloc_stack(void *addr, void **trace, size_t size, int *thread_id);
68 size_t __asan_get_free_stack(void *addr, void **trace, size_t size, int *thread_id);
75 void *alloc_trace[256];
79 void *free_trace[256];
84 t.alloc_count = __asan_get_alloc_stack((void *)0x%)" PRIx64
85 R"(, t.alloc_trace, 256, &t.alloc_tid);
86 t.free_count = __asan_get_free_stack((void *)0x%)" PRIx64
87 R"(, t.free_trace, 256, &t.free_tid);
95 const char *thread_name,
97 std::string count_path =
"." + std::string(type) +
"_count";
98 std::string tid_path =
"." + std::string(type) +
"_tid";
99 std::string trace_path =
"." + std::string(type) +
"_trace";
102 return_value_sp->GetValueForExpressionPath(count_path.c_str());
104 return_value_sp->GetValueForExpressionPath(tid_path.c_str());
106 if (!count_sp || !tid_sp)
109 int count = count_sp->GetValueAsUnsigned(0);
110 lldb::tid_t tid = tid_sp->GetValueAsUnsigned(0) + 1;
116 return_value_sp->GetValueForExpressionPath(trace_path.c_str());
121 std::vector<lldb::addr_t> pcs;
122 for (
int i = 0; i < count; i++) {
123 addr_t pc = trace_sp->GetChildAtIndex(i)->GetValueAsUnsigned(0);
132 bool pcs_are_call_addresses =
true;
134 new HistoryThread(*process_sp, tid, pcs, pcs_are_call_addresses);
135 ThreadSP new_thread_sp(history_thread);
136 std::ostringstream thread_name_with_number;
137 thread_name_with_number << thread_name <<
" Thread " << tid;
138 history_thread->
SetThreadName(thread_name_with_number.str().c_str());
141 process_sp->GetExtendedThreadList().AddThread(new_thread_sp);
142 result.push_back(new_thread_sp);
153 process_sp->GetThreadList().GetExpressionExecutionThread();
173 options.
SetTimeout(process_sp->GetUtilityExpressionTimeout());
179 exe_ctx, options, expr.
GetString(),
"", return_value_sp, eval_error);
182 ss <<
"cannot evaluate AddressSanitizer expression:\n";
185 process_sp->GetTarget().GetDebugger().GetID());
189 if (!return_value_sp)
193 "Memory deallocated by", result);
195 "Memory allocated by", result);
static void CreateHistoryThreadFromValueObject(ProcessSP process_sp, ValueObjectSP return_value_sp, const char *type, const char *thread_name, HistoryThreads &result)
const char * memory_history_asan_command_prefix
const char * memory_history_asan_command_format
#define LLDB_PLUGIN_DEFINE(PluginName)
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/Target/ExecutionContext.h" A class that contains an execution context.
A thread object representing a backtrace from a previous point in the process execution.
void SetThreadName(const char *name)
MemoryHistoryASan(const lldb::ProcessSP &process_sp)
lldb_private::HistoryThreads GetHistoryThreads(lldb::addr_t address) override
static llvm::StringRef GetPluginNameStatic()
static lldb::MemoryHistorySP CreateInstance(const lldb::ProcessSP &process_sp)
lldb::ProcessWP m_process_wp
ModuleIterable Modules() const
static bool RegisterPlugin(llvm::StringRef name, llvm::StringRef description, ABICreateInstance create_callback)
static bool UnregisterPlugin(ABICreateInstance create_callback)
const char * AsCString(const char *default_error_str="unknown error") const
Get the error string associated with the current error.
llvm::StringRef GetString() const
size_t Printf(const char *format,...) __attribute__((format(printf
Output printf formatted output to the stream.
const ModuleList & GetImages() const
Get accessor for the images for this process.
static lldb::ExpressionResults Evaluate(ExecutionContext &exe_ctx, const EvaluateExpressionOptions &options, llvm::StringRef expr_cstr, llvm::StringRef expr_prefix, lldb::ValueObjectSP &result_valobj_sp, Status &error, 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::vector< lldb::ThreadSP > HistoryThreads
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++.
std::shared_ptr< lldb_private::MemoryHistory > MemoryHistorySP
ExpressionResults
The results of expression evaluation.
std::shared_ptr< lldb_private::Process > ProcessSP
std::shared_ptr< lldb_private::Module > ModuleSP