[Lldb-commits] [PATCH] D117074: [lldb/Plugins] Enrich ScriptedThreads Stop Reasons with Exceptions
Med Ismail Bennani via Phabricator via lldb-commits
lldb-commits at lists.llvm.org
Tue Jan 11 18:22:48 PST 2022
mib created this revision.
mib added a reviewer: JDevlieghere.
mib added a project: LLDB.
Herald added a subscriber: kristof.beyls.
mib requested review of this revision.
Herald added a subscriber: lldb-commits.
This patch adds Exceptions to the list of supported stop reasons for
Scripted Threads.
The main motivation for this is that breakpoints are triggered as a
special exception class on ARM platforms, so adding it as a stop reason
allows the ScriptedProcess to selected the ScriptedThread that stopped at
a breakpoint (or crashed :p).
rdar://87430376
Signed-off-by: Med Ismail Bennani <medismail.bennani at gmail.com>
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D117074
Files:
lldb/source/Plugins/Process/scripted/ScriptedProcess.cpp
lldb/source/Plugins/Process/scripted/ScriptedThread.cpp
lldb/test/API/functionalities/scripted_process/stack_core_scripted_process.py
Index: lldb/test/API/functionalities/scripted_process/stack_core_scripted_process.py
===================================================================
--- lldb/test/API/functionalities/scripted_process/stack_core_scripted_process.py
+++ lldb/test/API/functionalities/scripted_process/stack_core_scripted_process.py
@@ -117,9 +117,21 @@
return StackCoreScriptedThread.__name__ + ".thread-" + str(self.id)
def get_stop_reason(self) -> Dict[str, Any]:
- return { "type": lldb.eStopReasonSignal, "data": {
- "signal": signal.SIGINT
- } }
+ stop_reason = { "type": lldb.eStopReasonInvalid, "data": { }}
+
+ if self.corefile_thread and self.corefile_thread.IsValid:
+ stop_reason["type"] = self.corefile_thread.GetStopReason()
+
+ if self.corefile_thread.GetStopReasonDataCount() > 0:
+ if stop_reason["type"] == lldb.eStopReasonBreakpoint:
+ stop_reason["data"]["break_id"] = self.corefile_thread.GetStopReasonDataAtIndex(0)
+ stop_reason["data"]["break_loc_id"] = self.corefile_thread.GetStopReasonDataAtIndex(1)
+ elif stop_reason["type"] == lldb.eStopReasonSignal:
+ stop_reason["data"]["signal"] = signal.SIGINT
+ elif stop_reason["type"] == lldb.eStopReasonException:
+ stop_reason["data"]["desc"] = self.corefile_thread.GetStopDescription(100)
+
+ return stop_reason
def get_stackframes(self):
class ScriptedStackFrame:
Index: lldb/source/Plugins/Process/scripted/ScriptedThread.cpp
===================================================================
--- lldb/source/Plugins/Process/scripted/ScriptedThread.cpp
+++ lldb/source/Plugins/Process/scripted/ScriptedThread.cpp
@@ -148,6 +148,11 @@
StructuredData::DictionarySP dict_sp = GetInterface()->GetStopReason();
Status error;
+ if (!dict_sp)
+ return GetInterface()->ErrorWithMessage<bool>(
+ LLVM_PRETTY_FUNCTION, "Failed to get scripted thread stop info.", error,
+ LIBLLDB_LOG_THREAD);
+
lldb::StopInfoSP stop_info_sp;
lldb::StopReason stop_reason_type;
@@ -161,7 +166,7 @@
if (!dict_sp->GetValueForKeyAsDictionary("data", data_dict))
return GetInterface()->ErrorWithMessage<bool>(
LLVM_PRETTY_FUNCTION,
- "Couldn't find value for key 'type' in stop reason dictionary.", error,
+ "Couldn't find value for key 'data' in stop reason dictionary.", error,
LIBLLDB_LOG_THREAD);
switch (stop_reason_type) {
@@ -169,8 +174,11 @@
break;
case lldb::eStopReasonBreakpoint: {
lldb::break_id_t break_id;
+ lldb::break_id_t break_loc_id;
data_dict->GetValueForKeyAsInteger("break_id", break_id,
LLDB_INVALID_BREAK_ID);
+ data_dict->GetValueForKeyAsInteger("break_loc_id", break_loc_id,
+ LLDB_INVALID_BREAK_ID);
stop_info_sp =
StopInfo::CreateStopReasonWithBreakpointSiteID(*this, break_id);
} break;
@@ -183,6 +191,13 @@
stop_info_sp =
StopInfo::CreateStopReasonWithSignal(*this, signal, description.data());
} break;
+ case lldb::eStopReasonException: {
+ llvm::StringRef description;
+ data_dict->GetValueForKeyAsString("desc", description);
+
+ stop_info_sp =
+ StopInfo::CreateStopReasonWithException(*this, description.data());
+ } break;
default:
return GetInterface()->ErrorWithMessage<bool>(
LLVM_PRETTY_FUNCTION,
Index: lldb/source/Plugins/Process/scripted/ScriptedProcess.cpp
===================================================================
--- lldb/source/Plugins/Process/scripted/ScriptedProcess.cpp
+++ lldb/source/Plugins/Process/scripted/ScriptedProcess.cpp
@@ -357,7 +357,14 @@
void ScriptedProcess::RefreshStateAfterStop() {
// Let all threads recover from stopping and do any clean up based on the
// previous thread state (if any).
- m_thread_list.RefreshStateAfterStop();
+ // TODO: Update
+ lldb::StopInfoSP stop_info;
+
+ lldb::tid_t selected_tid = 0;
+ m_thread_list.SetSelectedThreadByID(selected_tid);
+
+ lldb::ThreadSP stop_thread = m_thread_list.GetSelectedThread();
+ stop_thread->SetStopInfo(stop_info);
}
bool ScriptedProcess::GetProcessInfo(ProcessInstanceInfo &info) {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D117074.399158.patch
Type: text/x-patch
Size: 4341 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20220112/d3e35a8b/attachment-0001.bin>
More information about the lldb-commits
mailing list