mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-23 10:08:00 +02:00
Debugger fixes
Removing some debugger remote-requests
This commit is contained in:
parent
c2d086fe8e
commit
a32d18d962
21 changed files with 198 additions and 638 deletions
|
@ -8,6 +8,7 @@
|
|||
#include "BeefySysLib/Util/PerfTimer.h"
|
||||
#include "BeefySysLib/Util/Dictionary.h"
|
||||
#include "BeefySysLib/Util/BeefPerf.h"
|
||||
#include "BeefySysLib/platform/PlatformHelper.h"
|
||||
#include "WinDebugger.h"
|
||||
#include "MiniDumpDebugger.h"
|
||||
#include "Linker/BlHash.h"
|
||||
|
@ -6327,14 +6328,44 @@ String COFF::GetOldSourceCommand(const StringImpl& path)
|
|||
if (!matches)
|
||||
break;
|
||||
|
||||
String retVal;
|
||||
retVal = defs["SRCSRVTRG"];
|
||||
retVal += "\n";
|
||||
retVal += defs["SRCSRVCMD"];
|
||||
retVal += "\n";
|
||||
retVal += defs["SRCSRVENV"];
|
||||
_Expand(retVal);
|
||||
String& target = defs["SRCSRVTRG"];
|
||||
String& cmd = defs["SRCSRVCMD"];
|
||||
String& env = defs["SRCSRVENV"];
|
||||
|
||||
_Expand(target);
|
||||
_Expand(cmd);
|
||||
_Expand(env);
|
||||
|
||||
String retVal;
|
||||
if ((cmd.IsEmpty()) && (target.StartsWith("HTTP", StringImpl::CompareKind_OrdinalIgnoreCase)))
|
||||
{
|
||||
String localFile;
|
||||
|
||||
BfpFileResult result;
|
||||
BFP_GETSTR_HELPER(localFile, result, BfpFile_GetTempPath(__STR, __STRLEN, &result));
|
||||
int dotPos = target.IndexOf("://");
|
||||
if (dotPos != -1)
|
||||
{
|
||||
localFile.Append("SymbolCache\\src\\");
|
||||
localFile.Append(StringView(target, dotPos + 3));
|
||||
localFile.Replace("/", "\\");
|
||||
}
|
||||
|
||||
retVal = localFile;
|
||||
retVal += "\n";
|
||||
retVal += target;
|
||||
retVal += "\n";
|
||||
retVal += env;
|
||||
}
|
||||
else if (!cmd.IsWhitespace())
|
||||
{
|
||||
retVal = target;
|
||||
retVal += "\n";
|
||||
retVal += cmd;
|
||||
retVal += "\n";
|
||||
retVal += env;
|
||||
}
|
||||
|
||||
return retVal;
|
||||
}
|
||||
break;
|
||||
|
|
|
@ -1,10 +1,6 @@
|
|||
#include "Profiler.h"
|
||||
#include "DebugManager.h"
|
||||
//#include <Winternl.h>
|
||||
//::NtQuerySystemInformation();
|
||||
#include <mmsystem.h>
|
||||
|
||||
//#include <ntstatus.h>
|
||||
#include <ntsecapi.h> // UNICODE_STRING
|
||||
|
||||
#define STATUS_INFO_LENGTH_MISMATCH 0xc0000004
|
||||
|
@ -120,7 +116,7 @@ static SYSTEM_PROCESS_INFORMATION* CaptureProcessInfo()
|
|||
ntdll = GetModuleHandle(path);
|
||||
if (ntdll == NULL)
|
||||
return NULL;
|
||||
NtQuerySystemInformation = (NtQuerySystemInformation_t) GetProcAddress(ntdll, "NtQuerySystemInformation");
|
||||
NtQuerySystemInformation = (NtQuerySystemInformation_t)GetProcAddress(ntdll, "NtQuerySystemInformation");
|
||||
|
||||
uint allocSize = 1024;
|
||||
uint8* data = NULL;
|
||||
|
@ -180,9 +176,6 @@ void DbgProfiler::ThreadProc()
|
|||
const int maxStackTrace = 1024;
|
||||
addr_target stackTrace[maxStackTrace];
|
||||
|
||||
// Index zero is invalid
|
||||
//mProfileAddrEntries.push_back(NULL);
|
||||
|
||||
DWORD prevSampleTick = timeGetTime();
|
||||
uint32 accumMS = 0;
|
||||
|
||||
|
@ -201,7 +194,7 @@ void DbgProfiler::ThreadProc()
|
|||
mTotalActualSamples = 0;
|
||||
mTotalActiveSamplingMS = 0;
|
||||
|
||||
mAlloc.Clear();
|
||||
mAlloc.Clear();
|
||||
mThreadInfo.Clear();
|
||||
mThreadIdList.Clear();
|
||||
mProfileAddrEntrySet.Clear();
|
||||
|
@ -211,7 +204,7 @@ void DbgProfiler::ThreadProc()
|
|||
mProfileProcEntries.Clear();
|
||||
mProfileAddrToProcMap.Clear();
|
||||
mProcMap.Clear();
|
||||
mUniqueProcSet.Clear();
|
||||
mUniqueProcSet.Clear();
|
||||
mWantsClear = false;
|
||||
|
||||
accumMS = 0;
|
||||
|
@ -221,8 +214,7 @@ void DbgProfiler::ThreadProc()
|
|||
iterations++;
|
||||
DWORD startTick0 = timeGetTime();
|
||||
idleThreadSet.Clear();
|
||||
|
||||
//SYSTEM_PROCESS_INFORMATION* processData = CaptureProcessInfo();
|
||||
|
||||
SYSTEM_PROCESS_INFORMATION* processData = NULL;
|
||||
std::unique_ptr<SYSTEM_PROCESS_INFORMATION> ptrDelete(processData);
|
||||
|
||||
|
@ -585,7 +577,7 @@ void DbgProfiler::HandlePendingEntries()
|
|||
}
|
||||
ProfileProcId* procId = NULL;
|
||||
|
||||
auto subProgram = mDebugger->mDebugTarget->FindSubProgram(addr);
|
||||
auto subProgram = mDebugger->mDebugTarget->FindSubProgram(addr, DbgOnDemandKind_LocalOnly);
|
||||
while (stackTraceProcIdx < maxStackTrace)
|
||||
{
|
||||
if (subProgram != NULL)
|
||||
|
@ -604,7 +596,7 @@ void DbgProfiler::HandlePendingEntries()
|
|||
{
|
||||
String symbolName;
|
||||
addr_target symbolOffset = 0;
|
||||
if ((!mDebugger->mDebugTarget->FindSymbolAt(addr, &symbolName, &symbolOffset)) || (symbolOffset > 64 * 1024))
|
||||
if ((!mDebugger->mDebugTarget->FindSymbolAt(addr, &symbolName, &symbolOffset, NULL, false)) || (symbolOffset > 64 * 1024))
|
||||
{
|
||||
auto dbgModule = mDebugger->mDebugTarget->FindDbgModuleForAddress(addr);
|
||||
if (dbgModule != NULL)
|
||||
|
@ -647,89 +639,11 @@ void DbgProfiler::Process()
|
|||
|
||||
int time = mTotalActiveSamplingMS;
|
||||
|
||||
// const int maxStackTrace = 1024;
|
||||
// ProfileProcId* procStackTrace[maxStackTrace];
|
||||
//
|
||||
// bool reverse = false;
|
||||
|
||||
BF_ASSERT(mProfileAddrEntries.IsEmpty());
|
||||
|
||||
mProfileAddrEntries.Resize(mProfileAddrEntrySet.size() + 1);
|
||||
for (auto& val : mProfileAddrEntrySet)
|
||||
mProfileAddrEntries[val.mEntryIdx] = &val;
|
||||
|
||||
// for (int i = 0; i < (int)mProfileAddrEntries.size(); i++)
|
||||
// mProfileAddrToProcMap.push_back(-1);
|
||||
|
||||
// for (int addrEntryIdx = 0; addrEntryIdx < (int)mProfileAddrEntries.size(); addrEntryIdx++)
|
||||
// {
|
||||
// const ProfileAddrEntry* addrEntry = mProfileAddrEntries[addrEntryIdx];
|
||||
// if (addrEntry == NULL)
|
||||
// continue;
|
||||
//
|
||||
// ProfileProcId** procStackTraceHead = reverse ? (procStackTrace + maxStackTrace) : procStackTrace;
|
||||
// int stackTraceProcIdx = 0;
|
||||
// for (int addrIdx = 0; addrIdx < addrEntry->mSize; addrIdx++)
|
||||
// {
|
||||
// addr_target addr = addrEntry->mData[addrIdx];
|
||||
// if (addrIdx > 0)
|
||||
// {
|
||||
// // To reference from SourcePC (calling address, not return address)
|
||||
// addr--;
|
||||
// }
|
||||
// ProfileProcId* procId = NULL;
|
||||
//
|
||||
// auto subProgram = mDebugger->mDebugTarget->FindSubProgram(addr);
|
||||
// while (stackTraceProcIdx < maxStackTrace)
|
||||
// {
|
||||
// if (subProgram != NULL)
|
||||
// {
|
||||
// ProfileProcId** procIdPtr;
|
||||
// if (mProcMap.TryAdd(subProgram, NULL, &procIdPtr))
|
||||
// {
|
||||
// String procName = subProgram->ToString();
|
||||
// procId = Get(procName);
|
||||
// *procIdPtr = procId;
|
||||
// }
|
||||
// else
|
||||
// procId = *procIdPtr;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// String symbolName;
|
||||
// addr_target symbolOffset = 0;
|
||||
// if ((!mDebugger->mDebugTarget->FindSymbolAt(addr, &symbolName, &symbolOffset)) || (symbolOffset > 64 * 1024))
|
||||
// {
|
||||
// auto dbgModule = mDebugger->mDebugTarget->FindDbgModuleForAddress(addr);
|
||||
// if (dbgModule != NULL)
|
||||
// symbolName += dbgModule->mDisplayName + "!";
|
||||
// symbolName += StrFormat("0x%@", addr);
|
||||
// }
|
||||
//
|
||||
// procId = Get(symbolName);
|
||||
// }
|
||||
//
|
||||
// if (reverse)
|
||||
// *(--procStackTraceHead) = procId;
|
||||
// else
|
||||
// procStackTraceHead[stackTraceProcIdx] = procId;
|
||||
// stackTraceProcIdx++;
|
||||
//
|
||||
// if (subProgram == NULL)
|
||||
// break;
|
||||
// if (subProgram->mInlineeInfo == NULL)
|
||||
// break;
|
||||
// subProgram = subProgram->mInlineeInfo->mInlineParent;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// auto procEntry = AddToSet(mProfileProcEntrySet, procStackTraceHead, stackTraceProcIdx);
|
||||
// if (procEntry->mEntryIdx == -1)
|
||||
// {
|
||||
// procEntry->mEntryIdx = (int)mProfileProcEntrySet.size() - 1; // Start at '0'
|
||||
// }
|
||||
// mProfileAddrToProcMap[addrEntry->mEntryIdx] = procEntry->mEntryIdx;
|
||||
// }
|
||||
|
||||
BF_ASSERT(mProfileProcEntries.IsEmpty());
|
||||
mProfileProcEntries.Resize(mProfileProcEntrySet.size());
|
||||
|
|
|
@ -1399,9 +1399,9 @@ bool WinDebugger::DoUpdate()
|
|||
dbgModule->PreCacheImage();
|
||||
}
|
||||
|
||||
for (auto dbgModule : mPendingDebugInfoLoad)
|
||||
for (auto kv : mPendingDebugInfoLoad)
|
||||
{
|
||||
dbgModule->PreCacheDebugInfo();
|
||||
kv.mKey->PreCacheDebugInfo();
|
||||
}
|
||||
|
||||
while (!mPendingImageLoad.IsEmpty())
|
||||
|
@ -1412,26 +1412,21 @@ bool WinDebugger::DoUpdate()
|
|||
_ModuleChanged(dbgModule);
|
||||
}
|
||||
|
||||
while (!mPendingDebugInfoLoad.IsEmpty())
|
||||
if (!mPendingDebugInfoLoad.IsEmpty())
|
||||
{
|
||||
auto dbgModule = mPendingDebugInfoLoad.back();
|
||||
mPendingDebugInfoLoad.pop_back();
|
||||
dbgModule->RequestDebugInfo();
|
||||
// We do a "_ModuleChanged" even if the load failed, so we rehup the callstack and stop
|
||||
// saying "<Loading...>"
|
||||
_ModuleChanged(dbgModule);
|
||||
}
|
||||
|
||||
/*while (!mPendingDebugInfoRequests.IsEmpty())
|
||||
{
|
||||
if ((!mPendingImageLoad.IsEmpty()) || (!mPendingDebugInfoLoad.IsEmpty()))
|
||||
break;
|
||||
|
||||
auto dbgModule = mPendingDebugInfoRequests.back();
|
||||
mPendingDebugInfoRequests.pop_back();
|
||||
if (LoadDebugInfoForModule(dbgModule) == 1)
|
||||
_ModuleChanged(dbgModule);
|
||||
}*/
|
||||
Array<DbgPendingDebugInfoLoad> pendingList;
|
||||
for (auto kv : mPendingDebugInfoLoad)
|
||||
pendingList.Add(kv.mValue);
|
||||
|
||||
for (auto& entry : pendingList)
|
||||
{
|
||||
auto dbgModule = entry.mModule;
|
||||
entry.mModule->RequestDebugInfo(entry.mAllowRemote);
|
||||
// We do a "_ModuleChanged" even if the load failed, so we rehup the callstack and stop
|
||||
// saying "<Loading...>"
|
||||
_ModuleChanged(entry.mModule);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (IsMiniDumpDebugger())
|
||||
|
@ -10829,7 +10824,7 @@ String WinDebugger::GetStackFrameInfo(int stackFrameIdx, intptr* addr, String* o
|
|||
{
|
||||
*outFlags |= FrameFlags_HasPendingDebugInfo;
|
||||
|
||||
if (mPendingDebugInfoLoad.Contains(dbgModule))
|
||||
if (mPendingDebugInfoLoad.ContainsKey(dbgModule))
|
||||
{
|
||||
String outName = EncodeDataPtr(pcAddress, true);
|
||||
if ((dbgModule != NULL) && (!dbgModule->mDisplayName.empty()))
|
||||
|
@ -11957,12 +11952,15 @@ int WinDebugger::LoadDebugInfoForModule(DbgModule* dbgModule)
|
|||
return 1;
|
||||
}
|
||||
|
||||
if (!mPendingDebugInfoLoad.Contains(dbgModule))
|
||||
DbgPendingDebugInfoLoad* dbgPendingDebugInfoLoad = NULL;
|
||||
if (mPendingDebugInfoLoad.TryAdd(dbgModule, NULL, &dbgPendingDebugInfoLoad))
|
||||
{
|
||||
mPendingDebugInfoLoad.Add(dbgModule);
|
||||
dbgPendingDebugInfoLoad->mModule = dbgModule;
|
||||
dbgPendingDebugInfoLoad->mAllowRemote = true;
|
||||
return 2;
|
||||
}
|
||||
|
||||
dbgPendingDebugInfoLoad->mAllowRemote = true;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -357,6 +357,18 @@ struct WdMemoryBreakpointBind
|
|||
}
|
||||
};
|
||||
|
||||
struct DbgPendingDebugInfoLoad
|
||||
{
|
||||
DbgModule* mModule;
|
||||
bool mAllowRemote;
|
||||
|
||||
DbgPendingDebugInfoLoad()
|
||||
{
|
||||
mModule = NULL;
|
||||
mAllowRemote = false;
|
||||
}
|
||||
};
|
||||
|
||||
class WinDebugger : public Debugger
|
||||
{
|
||||
public:
|
||||
|
@ -431,7 +443,7 @@ public:
|
|||
DbgPendingExpr* mDebugPendingExpr;
|
||||
WdThreadInfo mDebugEvalThreadInfo; // Copy of thread info when eval started
|
||||
Array<DbgModule*> mPendingImageLoad;
|
||||
Array<DbgModule*> mPendingDebugInfoLoad;
|
||||
Dictionary<DbgModule*, DbgPendingDebugInfoLoad> mPendingDebugInfoLoad;
|
||||
Array<DbgModule*> mPendingDebugInfoRequests;
|
||||
HashSet<String> mLiteralSet;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue