MCPcopy Create free account
hub / github.com/Vector35/debugger / GetFramesOfThread

Method GetFramesOfThread

core/adapters/dbgengadapter.cpp:1490–1552  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1488
1489
1490std::vector<DebugFrame> DbgEngAdapter::GetFramesOfThread(uint32_t tid)
1491{
1492 std::vector<DebugFrame> result;
1493 // Due to https://github.com/Vector35/debugger/issues/304 and that we pause the target before killing it, we would
1494 // not be able to even kill or restart a GUI app on Windows. That is really bad. To mitigate the issue, I created
1495 // this boolean, which help skip any update on thread information when the target is about to be killed, thus
1496 // allowing the target to be killed or restarted normally. This needs to be reworked later.
1497 if (m_aboutToBeKilled)
1498 return result;
1499
1500 DebugThread activeThead = GetActiveThread();
1501
1502 SetActiveThreadId(tid);
1503
1504 const size_t numFrames = 16;
1505 PDEBUG_STACK_FRAME_EX frames = new DEBUG_STACK_FRAME_EX[numFrames];
1506 unsigned long framesFilled = 0;
1507 if (m_debugControl->GetStackTraceEx(0, 0, 0, frames, numFrames, &framesFilled) != S_OK)
1508 return result;
1509
1510 for (size_t i = 0; i < framesFilled; i++)
1511 {
1512 DebugFrame frame;
1513 auto engineFrame = frames[i];
1514 frame.m_index = i;
1515 frame.m_fp = engineFrame.FrameOffset;
1516 frame.m_sp = engineFrame.StackOffset;
1517 frame.m_pc = engineFrame.InstructionOffset;
1518 frame.m_functionStart = engineFrame.FuncTableEntry;
1519
1520 // Get module info
1521 ULONG moduleIndex = 0;
1522 uint64_t moduleBase = 0;
1523 m_debugSymbols->GetModuleByOffset(engineFrame.InstructionOffset, 0, &moduleIndex, &moduleBase);
1524
1525 char name[1024];
1526 char short_name[1024];
1527 char loaded_image_name[1024];
1528 if (this->m_debugSymbols->GetModuleNames(moduleIndex, 0,
1529 name, 1024, nullptr,
1530 short_name, 1024, nullptr,
1531 loaded_image_name, 1024, nullptr) == S_OK)
1532 {
1533 frame.m_module = short_name;
1534 }
1535
1536 // Get function info
1537 char functionName[1024];
1538 unsigned long functionNameLen = 0;
1539 uint64_t displacement = 0;
1540 if (S_OK == m_debugSymbols->GetNameByOffset(engineFrame.InstructionOffset,
1541 functionName, sizeof(functionName),
1542 &functionNameLen, &displacement))
1543 {
1544 frame.m_functionName = functionName;
1545 }
1546
1547 result.push_back(frame);

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected