34 if (!process_sp.get())
37 Target &target = process_sp->GetTarget();
40 const Symbol *symbol = module_sp->FindFirstSymbolWithNameAndType(
43 if (symbol !=
nullptr)
47 return MemoryHistorySP();
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);
72 void *alloc_trace[256];
76 void *free_trace[256];
86 t.alloc_count = __asan_get_alloc_stack((void *)0x%)" PRIx64
87 R"(, t.alloc_trace, 256, &t.alloc_tid);
88 t.free_count = __asan_get_free_stack((void *)0x%)" PRIx64
89 R"(, t.free_trace, 256, &t.free_tid);
95 ValueObjectSP return_value_sp,
97 const char *thread_name,
99 std::string count_path =
"." + std::string(type) +
"_count";
100 std::string tid_path =
"." + std::string(type) +
"_tid";
101 std::string trace_path =
"." + std::string(type) +
"_trace";
103 ValueObjectSP count_sp =
104 return_value_sp->GetValueForExpressionPath(count_path.c_str());
105 ValueObjectSP tid_sp =
106 return_value_sp->GetValueForExpressionPath(tid_path.c_str());
108 if (!count_sp || !tid_sp)
111 int count = count_sp->GetValueAsUnsigned(0);
112 tid_t tid = tid_sp->GetValueAsUnsigned(0) + 1;
117 ValueObjectSP trace_sp =
118 return_value_sp->GetValueForExpressionPath(trace_path.c_str());
123 std::vector<lldb::addr_t> pcs;
124 for (
int i = 0; i < count; i++) {
125 addr_t pc = trace_sp->GetChildAtIndex(i,
true)->GetValueAsUnsigned(0);
134 bool pcs_are_call_addresses =
true;
136 new HistoryThread(*process_sp, tid, pcs, pcs_are_call_addresses);
137 ThreadSP new_thread_sp(history_thread);
138 std::ostringstream thread_name_with_number;
139 thread_name_with_number << thread_name <<
" Thread " << tid;
140 history_thread->
SetThreadName(thread_name_with_number.str().c_str());
143 process_sp->GetExtendedThreadList().AddThread(new_thread_sp);
144 result.push_back(new_thread_sp);
155 process_sp->GetThreadList().GetExpressionExecutionThread();
159 StackFrameSP frame_sp = thread_sp->GetSelectedFrame();
164 ValueObjectSP return_value_sp;
174 options.
SetTimeout(process_sp->GetUtilityExpressionTimeout());
180 exe_ctx, options, expr.
GetString(),
"", return_value_sp, eval_error);
183 ss <<
"cannot evaluate AddressSanitizer expression:\n";
186 process_sp->GetTarget().GetDebugger().GetID());
190 if (!return_value_sp)
194 "Memory deallocated by", result);
196 "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 SetLanguage(lldb::LanguageType language)
void SetUnwindOnError(bool unwind=false)
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
A class that represents a running process on the host machine.
std::vector< lldb::ThreadSP > HistoryThreads
@ eLanguageTypeObjC_plus_plus
Objective-C++.
ExpressionResults
The results of expression evaluation.