Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 8f5f94b

Browse files
authored
Merge pull request swiftlang#7014 from medismailben/scripted-process-trace-log
[lldb] Add support for eStopReasonTrace in Scripted Process
2 parents a667597 + 85ec3b4 commit 8f5f94b

File tree

4 files changed

+15
-12
lines changed

4 files changed

+15
-12
lines changed

lldb/source/Plugins/Process/scripted/ScriptedThread.cpp

+3
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,9 @@ bool ScriptedThread::CalculateStopInfo() {
257257
stop_info_sp =
258258
StopInfo::CreateStopReasonWithSignal(*this, signal, description.data());
259259
} break;
260+
case lldb::eStopReasonTrace: {
261+
stop_info_sp = StopInfo::CreateStopReasonToTrace(*this);
262+
} break;
260263
case lldb::eStopReasonException: {
261264
#if defined(__APPLE__)
262265
StructuredData::Dictionary *mach_exception;

lldb/source/Target/Process.cpp

+10-10
Original file line numberDiff line numberDiff line change
@@ -1174,13 +1174,13 @@ bool Process::SetExitStatus(int status, const char *cstr) {
11741174
std::lock_guard<std::mutex> guard(m_exit_status_mutex);
11751175

11761176
Log *log(GetLog(LLDBLog::State | LLDBLog::Process));
1177-
LLDB_LOG(log, "(plugin = %s status=%i (0x%8.8x), description=%s%s%s)",
1177+
LLDB_LOGF(log, "(plugin = %s status=%i (0x%8.8x), description=%s%s%s)",
11781178
GetPluginName().data(), status, status, cstr ? "\"" : "",
11791179
cstr ? cstr : "NULL", cstr ? "\"" : "");
11801180

11811181
// We were already in the exited state
11821182
if (m_private_state.GetValue() == eStateExited) {
1183-
LLDB_LOG(log,
1183+
LLDB_LOGF(log,
11841184
"(plugin = %s) ignoring exit status because state was already set "
11851185
"to eStateExited",
11861186
GetPluginName().data());
@@ -1467,7 +1467,7 @@ void Process::SetPublicState(StateType new_state, bool restarted) {
14671467
}
14681468

14691469
Log *log(GetLog(LLDBLog::State | LLDBLog::Process));
1470-
LLDB_LOG(log, "(plugin = %s, state = %s, restarted = %i)",
1470+
LLDB_LOGF(log, "(plugin = %s, state = %s, restarted = %i)",
14711471
GetPluginName().data(), StateAsCString(new_state), restarted);
14721472
const StateType old_state = m_public_state.GetValue();
14731473
m_public_state.SetValue(new_state);
@@ -1477,15 +1477,15 @@ void Process::SetPublicState(StateType new_state, bool restarted) {
14771477
// program to run.
14781478
if (!StateChangedIsExternallyHijacked()) {
14791479
if (new_state == eStateDetached) {
1480-
LLDB_LOG(log,
1480+
LLDB_LOGF(log,
14811481
"(plugin = %s, state = %s) -- unlocking run lock for detach",
14821482
GetPluginName().data(), StateAsCString(new_state));
14831483
m_public_run_lock.SetStopped();
14841484
} else {
14851485
const bool old_state_is_stopped = StateIsStoppedState(old_state, false);
14861486
if ((old_state_is_stopped != new_state_is_stopped)) {
14871487
if (new_state_is_stopped && !restarted) {
1488-
LLDB_LOG(log, "(plugin = %s, state = %s) -- unlocking run lock",
1488+
LLDB_LOGF(log, "(plugin = %s, state = %s) -- unlocking run lock",
14891489
GetPluginName().data(), StateAsCString(new_state));
14901490
m_public_run_lock.SetStopped();
14911491
}
@@ -1496,10 +1496,10 @@ void Process::SetPublicState(StateType new_state, bool restarted) {
14961496

14971497
Status Process::Resume() {
14981498
Log *log(GetLog(LLDBLog::State | LLDBLog::Process));
1499-
LLDB_LOG(log, "(plugin = %s) -- locking run lock", GetPluginName().data());
1499+
LLDB_LOGF(log, "(plugin = %s) -- locking run lock", GetPluginName().data());
15001500
if (!m_public_run_lock.TrySetRunning()) {
15011501
Status error("Resume request failed - process still running.");
1502-
LLDB_LOG(log, "(plugin = %s) -- TrySetRunning failed, not resuming.",
1502+
LLDB_LOGF(log, "(plugin = %s) -- TrySetRunning failed, not resuming.",
15031503
GetPluginName().data());
15041504
return error;
15051505
}
@@ -1573,7 +1573,7 @@ void Process::SetPrivateState(StateType new_state) {
15731573
Log *log(GetLog(LLDBLog::State | LLDBLog::Process | LLDBLog::Unwind));
15741574
bool state_changed = false;
15751575

1576-
LLDB_LOG(log, "(plugin = %s, state = %s)", GetPluginName().data(),
1576+
LLDB_LOGF(log, "(plugin = %s, state = %s)", GetPluginName().data(),
15771577
StateAsCString(new_state));
15781578

15791579
std::lock_guard<std::recursive_mutex> thread_guard(m_thread_list.GetMutex());
@@ -1615,14 +1615,14 @@ void Process::SetPrivateState(StateType new_state) {
16151615
if (!m_mod_id.IsLastResumeForUserExpression())
16161616
m_mod_id.SetStopEventForLastNaturalStopID(event_sp);
16171617
m_memory_cache.Clear();
1618-
LLDB_LOG(log, "(plugin = %s, state = %s, stop_id = %u",
1618+
LLDB_LOGF(log, "(plugin = %s, state = %s, stop_id = %u",
16191619
GetPluginName().data(), StateAsCString(new_state),
16201620
m_mod_id.GetStopID());
16211621
}
16221622

16231623
m_private_state_broadcaster.BroadcastEvent(event_sp);
16241624
} else {
1625-
LLDB_LOG(log, "(plugin = %s, state = %s) state didn't change. Ignoring...",
1625+
LLDB_LOGF(log, "(plugin = %s, state = %s) state didn't change. Ignoring...",
16261626
GetPluginName().data(), StateAsCString(new_state));
16271627
}
16281628
}

lldb/test/API/functionalities/scripted_process/TestScriptedProcess.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ def cleanup():
214214
self.assertTrue(thread, "Invalid thread.")
215215
self.assertEqual(thread.GetThreadID(), 0x19)
216216
self.assertEqual(thread.GetName(), "DummyScriptedThread.thread-1")
217-
self.assertStopReason(thread.GetStopReason(), lldb.eStopReasonSignal)
217+
self.assertStopReason(thread.GetStopReason(), lldb.eStopReasonTrace)
218218

219219
self.assertGreater(thread.GetNumFrames(), 0)
220220

lldb/test/API/functionalities/scripted_process/dummy_scripted_process.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ def get_state(self) -> int:
6969
return lldb.eStateStopped
7070

7171
def get_stop_reason(self) -> Dict[str, Any]:
72-
return {"type": lldb.eStopReasonSignal, "data": {"signal": signal.SIGINT}}
72+
return { "type": lldb.eStopReasonTrace, "data": {} }
7373

7474
def get_register_context(self) -> str:
7575
return struct.pack(

0 commit comments

Comments
 (0)