PDB debugger improved

git-svn-id: svn://ultimatepp.org/upp/trunk@13735 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
cxl 2019-12-05 17:22:12 +00:00
parent 5580b940c0
commit bb765843bb
4 changed files with 22 additions and 21 deletions

View file

@ -384,7 +384,6 @@ struct Pdb : Debugger, ParentCtrl {
Val At(Pdb::Val val, int i);
Val At(Pdb::Val record, const char *id, int i);
int IntAt(Pdb::Val record, const char *id, int i);
String IntFormat(int64 i, dword flags = 0);
void CatInt(Visual& result, int64 val, dword flags = 0);
enum { MEMBER = 1, RAW = 2 };

View file

@ -214,7 +214,11 @@ void Pdb::PrettyValue(Pdb::Val val, const Vector<String>&, int64 from, int count
static VectorMap<int, String> single {
{ 20, "Upp::Complex" }, { 40, "Upp::Font" },
{ 48, "Upp::Painting" }, { 49, "Upp::Drawing" }, { 150, "Upp::Image" }
{ 48, "Upp::Painting" }, { 49, "Upp::Drawing" }, { 150, "Upp::Image" },
{ POINT64_V, "Upp::Point_<__int64>" }, { POINTF_V, "Upp::Point_<double>" },
{ SIZE64_V, "Upp::Size_<__int64>" }, { SIZEF_V, "Upp::Size_<double>" },
{ RECT_V, "Upp::Rect_<int>" },
{ RECT64_V, "Upp::Rect_<__int64>" }, { RECTF_V, "Upp::Rect_<double>" },
};
String t = single.Get(st, Null);
@ -231,7 +235,8 @@ void Pdb::PrettyValue(Pdb::Val val, const Vector<String>&, int64 from, int count
}
static VectorMap<int, String> single {
{ 1, "int" }, { 2, "double" }, { 4, "Upp::Date" }, { 5, "Upp::Time" }, { 10, "int64" },
{ 11, "bool" }, {39, "Upp::Color" }
{ 11, "bool" }, {39, "Upp::Color" },
{ POINT_V, "Upp::Point_<int>" }, { SIZE_V, "Upp::Size_<int>" }
};
String t = single.Get(st, Null);
if(t.GetCount())

View file

@ -186,7 +186,7 @@ BOOL CALLBACK Pdb::EnumLocals(PSYMBOL_INFO pSym, ULONG SymbolSize, PVOID UserCon
if(pSym->Tag == SymTagFunction)
return TRUE;
Val& v = (pSym->Flags & IMAGEHLP_SYMBOL_INFO_PARAMETER ? c.param : c.local).GetAdd(pSym->Name);
Val& v = (pSym->Flags & IMAGEHLP_SYMBOL_INFO_PARAMETER ? c.param : c.local).Add(pSym->Name);
v.address = (adr_t)pSym->Address;
if(pSym->Flags & IMAGEHLP_SYMBOL_INFO_REGISTER)
v.address = pSym->Register;
@ -209,13 +209,14 @@ BOOL CALLBACK Pdb::EnumLocals(PSYMBOL_INFO pSym, ULONG SymbolSize, PVOID UserCon
c.pdb->TypeVal(v, pSym->TypeIndex, (adr_t)pSym->ModBase);
v.reported_size = pSym->Size;
v.context = c.context;
LLOG("LOCAL " << pSym->Name << ": " << Format64Hex(v.address));
DLOG("LOCAL " << pSym->Name << ": " << Format64Hex(v.address));
return TRUE;
}
void Pdb::GetLocals(Frame& frame, Context& context, VectorMap<String, Pdb::Val>& param,
VectorMap<String, Pdb::Val>& local)
{
DLOG("============ GetLocals");
static IMAGEHLP_STACK_FRAME f;
f.InstructionOffset = frame.pc;
SymSetContext(hProcess, &f, 0);
@ -226,6 +227,7 @@ void Pdb::GetLocals(Frame& frame, Context& context, VectorMap<String, Pdb::Val>&
SymEnumSymbols(hProcess, 0, 0, &EnumLocals, &c);
param = pick(c.param);
local = pick(c.local);
DLOG("...");
}
BOOL CALLBACK Pdb::EnumGlobals(PSYMBOL_INFO pSym, ULONG SymbolSize, PVOID UserContext)

View file

@ -84,23 +84,16 @@ int Pdb::IntAt(Pdb::Val record, const char *id, int i)
return (int)GetInt(At(record, id, i));
}
String Pdb::IntFormat(int64 i, dword flags)
{
String r;
if(i < 0)
r << '-' << Format64(-i);
else
r << Format64(i);
if(i >= 32 && i < 128)
r << " \'" << (char)i << '\'';
return r;
}
void Pdb::CatInt(Visual& result, int64 val, dword flags)
{
result.Cat(IntFormat(val), SRed);
if(val < 0)
result.Cat("-" + Format64(-val), SRed);
else
result.Cat(Format64(val), SRed);
if(flags & MEMBER)
return;
if(val >= 32 && val < 128)
result.Cat(String() << " \'" << (char)val << '\'', SRed);
result.Cat(" 0x" + Format64Hex(val), SMagenta);
}
@ -212,9 +205,11 @@ void Pdb::Visualise(Visual& result, Pdb::Val val, dword flags)
if(!(flags & RAW) && !raw)
try {
if(VisualisePretty(result, val, flags) && (flags & MEMBER))
return;
result.Cat(" ");
if(VisualisePretty(result, val, flags)) {
if(flags & MEMBER)
return;
result.Cat(", raw: ", SGray);
}
}
catch(CParser::Error e) {} // if failed, display as raw data