|
|
Home » U++ TheIDE » U++ TheIDE: Compiling, Linking, Debugging of your packages » Problems debugging with Visual C++
Problems debugging with Visual C++ [message #43591] |
Thu, 11 September 2014 08:32 |
frankdeprins
Messages: 99 Registered: September 2008 Location: Antwerp - Belgium
|
Member |
|
|
Hello Mirek,
After a very long time, I just started to do some c++ again and, hence, use theIDE. But I had quite some problems debugging with Visual C++ (2010/32 bit).
Amongst the problems are crashing (I just upgraded to rev 7655 yesterday, but did not test that one a lot) and inability to watch variables (also with 7655). All my variables are either 0 (numeric ones) or marked with '??'.
Are there any added preconditions for debugging with VC now?
Best regards,
Frank
[Updated on: Thu, 11 September 2014 10:52] Report message to a moderator
|
|
|
Re: Problems debugging with Visual C++ [message #43632 is a reply to message #43591] |
Tue, 16 September 2014 14:12 |
|
mirek
Messages: 14105 Registered: November 2005
|
Ultimate Member |
|
|
frankdeprins wrote on Thu, 11 September 2014 08:32Hello Mirek,
After a very long time, I just started to do some c++ again and, hence, use theIDE. But I had quite some problems debugging with Visual C++ (2010/32 bit).
Amongst the problems are crashing (I just upgraded to rev 7655 yesterday, but did not test that one a lot) and inability to watch variables (also with 7655). All my variables are either 0 (numeric ones) or marked with '??'.
Are there any added preconditions for debugging with VC now?
Best regards,
Frank
Debugger was going through intense development lately. Currently, it works better than "before" for me, but it is definitely possible that something is still a bit broken. Anyway, for now I recommend testing with latest svn version (or night build).
One possible precondition could be 'current' version of dbghelp.dll. What is your OS?
It should be possible to get latest dbghelp.dll somewhere, I guess it is even in SDK, but it is possible that your OS is e.g. winxp and you have no dbghelp.dll in theide.exe dir (and thus it links with old version in system32).
Mirek
|
|
|
|
|
|
Re: Problems debugging with Visual C++ [message #43646 is a reply to message #43645] |
Wed, 17 September 2014 15:41 |
|
mirek
Messages: 14105 Registered: November 2005
|
Ultimate Member |
|
|
Just to clarify, the change is with this method:
BOOL CALLBACK Pdb::EnumLocals(PSYMBOL_INFO pSym, ULONG SymbolSize, PVOID UserContext)
{
LocalsCtx& c = *(LocalsCtx *)UserContext;
if(pSym->Tag == SymTagFunction)
return TRUE;
Val& v = (pSym->Flags & IMAGEHLP_SYMBOL_INFO_PARAMETER ? c.param : c.local).GetAdd(pSym->Name);
v.address = (adr_t)pSym->Address;
if(pSym->Flags & IMAGEHLP_SYMBOL_INFO_REGISTER)
v.address = pSym->Register;
else
if(pSym->Flags & IMAGEHLP_SYMBOL_INFO_REGRELATIVE) {
if(pSym->Register == CV_ALLREG_VFRAME) {
#ifdef CPU_64
if(c.pdb->win64)
v.address += c.pdb->GetCpuRegister(*c.context, CV_AMD64_RBP);
else
#endif
v.address += (adr_t)c.pdb->GetCpuRegister(*c.context, CV_REG_EBP);
}
else
v.address += (adr_t)c.pdb->GetCpuRegister(*c.context, pSym->Register);
}
else
if(pSym->Flags & IMAGEHLP_SYMBOL_INFO_FRAMERELATIVE)
v.address += c.frame;
c.pdb->TypeVal(v, pSym->TypeIndex, (adr_t)pSym->ModBase);
LLOG("LOCAL " << pSym->Name << ": " << Format64Hex(v.address));
return TRUE;
}
- and I believe the problems you are enduring is in there too. So perhaps if you have a bit of time and energy and my change does not work, could you please test with some RDUMPs put there, like
BOOL CALLBACK Pdb::EnumLocals(PSYMBOL_INFO pSym, ULONG SymbolSize, PVOID UserContext)
{
LocalsCtx& c = *(LocalsCtx *)UserContext;
if(pSym->Tag == SymTagFunction)
return TRUE;
Val& v = (pSym->Flags & IMAGEHLP_SYMBOL_INFO_PARAMETER ? c.param : c.local).GetAdd(pSym->Name);
v.address = (adr_t)pSym->Address;
RLOG("-------------------------");
RDUMP(Format64Hex(v.address));
if(pSym->Flags & IMAGEHLP_SYMBOL_INFO_REGISTER)
v.address = pSym->Register;
else
if(pSym->Flags & IMAGEHLP_SYMBOL_INFO_REGRELATIVE) {
if(pSym->Register == CV_ALLREG_VFRAME) {
#ifdef CPU_64
if(c.pdb->win64)
v.address += c.pdb->GetCpuRegister(*c.context, CV_AMD64_RBP);
else
#endif
v.address += (adr_t)c.pdb->GetCpuRegister(*c.context, CV_REG_EBP);
RDUMP(Format64Hex(v.address));
}
else
v.address += (adr_t)c.pdb->GetCpuRegister(*c.context, pSym->Register);
}
else
if(pSym->Flags & IMAGEHLP_SYMBOL_INFO_FRAMERELATIVE) {
RDUMP(Format64Hex(c.frame));
v.address += c.frame;
}
c.pdb->TypeVal(v, pSym->TypeIndex, (adr_t)pSym->ModBase);
RLOG("LOCAL " << pSym->Name << ": " << Format64Hex(v.address));
return TRUE;
}
|
|
|
|
|
|
Re: Problems debugging with Visual C++ [message #43657 is a reply to message #43650] |
Thu, 18 September 2014 08:48 |
frankdeprins
Messages: 99 Registered: September 2008 Location: Antwerp - Belgium
|
Member |
|
|
Hello Mirek,
The extra logging lines added the next content to theide.log:
pSym->Flags & IMAGEHLP_SYMBOL_INFO_REGRELATIVE = 16
pSym->Register == CV_ALLREG_VFRAME = false
pSym->Register = 22
These log lines occurred several times, of course, but always with exactly the same values.
After that, I changed if(pSym->Register == CV_ALLREG_VFRAME) to: if(true)
But even then, the result was that I only got i and i64 and both watches were still 0.
I guess commenting out the register test will not change it, as we already know the else block is executed because of the presence of the new logging lines put in it.
Anyway, this is the final state of the code as I ran it:
BOOL CALLBACK Pdb::EnumLocals(PSYMBOL_INFO pSym, ULONG SymbolSize, PVOID UserContext)
{
LocalsCtx& c = *(LocalsCtx *)UserContext;
if(pSym->Tag == SymTagFunction)
return TRUE;
Val& v = (pSym->Flags & IMAGEHLP_SYMBOL_INFO_PARAMETER ? c.param : c.local).GetAdd(pSym->Name);
v.address = (adr_t)pSym->Address;
RLOG("-------------------------");
RDUMP(Format64Hex(v.address));
if(pSym->Flags & IMAGEHLP_SYMBOL_INFO_REGISTER)
v.address = pSym->Register;
else {
RDUMP(pSym->Flags & IMAGEHLP_SYMBOL_INFO_REGRELATIVE);
RDUMP(pSym->Register == CV_ALLREG_VFRAME);
RDUMP(pSym->Register);
if(pSym->Flags & IMAGEHLP_SYMBOL_INFO_REGRELATIVE) {
if(true/*pSym->Register == CV_ALLREG_VFRAME*/) {
#ifdef CPU_64
if(c.pdb->win64)
v.address += c.pdb->GetCpuRegister(*c.context, CV_AMD64_RBP);
else
#endif
v.address += (adr_t)c.pdb->GetCpuRegister(*c.context, CV_REG_EBP);
}
else
v.address += (adr_t)c.pdb->GetCpuRegister(*c.context, pSym->Register);
RDUMP(v.address);
}
}
if(pSym->Flags & IMAGEHLP_SYMBOL_INFO_FRAMERELATIVE) {
RDUMP(Format64Hex(c.frame));
v.address += c.frame;
}
c.pdb->TypeVal(v, pSym->TypeIndex, (adr_t)pSym->ModBase);
RLOG("LOCAL " << pSym->Name << ": " << Format64Hex(v.address));
return TRUE;
}
Attached, you find the log file.
Frank
-
Attachment: theide.log
(Size: 1.96KB, Downloaded 284 times)
[Updated on: Thu, 18 September 2014 08:48] Report message to a moderator
|
|
|
|
|
Re: Problems debugging with Visual C++ [message #43660 is a reply to message #43659] |
Thu, 18 September 2014 11:31 |
frankdeprins
Messages: 99 Registered: September 2008 Location: Antwerp - Belgium
|
Member |
|
|
What do you mean by backtrace?
Is it this ('Debug/Copy backtrace' menu item) what you mean:
ConsoleMainFn_()
Upp::AppExecute__(app=??)
main(argc=0, argv=??)
__tmainCRTStartup()
mainCRTStartup()
76faee1c (kernel32.dll)
77ac37eb (ntdll.dll)
77ac37be (ntdll.dll)
As a sidenote: I did pass 4 parameters via the 'Run Options' dialog, so argc should not be 0
Again, I attached the new log file.
PS: The disapearance of the double variable is only in the 'Autos' tab; in the 'Locals' tab it is still there (with '??').
-
Attachment: theide.log
(Size: 3.34KB, Downloaded 282 times)
[Updated on: Thu, 18 September 2014 11:34] Report message to a moderator
|
|
|
Re: Problems debugging with Visual C++ [message #43661 is a reply to message #43660] |
Thu, 18 September 2014 12:55 |
|
mirek
Messages: 14105 Registered: November 2005
|
Ultimate Member |
|
|
Interesting. May I ask for more logs?
uint64 Pdb::GetCpuRegister(const Context& ctx, int sym)
{
int q = GetRegisterList().Find(sym);
RLOG("== GetCpuRegister =========");
RDUMP(sym);
RDUMP(q);
if(q < 0)
return 0;
const CpuRegister& r = GetRegisterList()[q];
RDUMP(r.name);
RDUMP(r.kind);
RDUMP(r.sym);
#ifdef CPU_64
uint64 val = win64 ? GetRegister64(ctx, sym) : GetRegister32(ctx, sym);
#else
uint64 val = GetRegister32(ctx, sym);
#endif
RDUMP(Format64Hex(val));
switch(r.kind) {
case REG_L:
return LOBYTE(val);
case REG_H:
return HIBYTE(val);
case REG_X:
return LOWORD(val);
case REG_E:
return LODWORD(val);
}
return val;
}
BOOL CALLBACK Pdb::EnumLocals(PSYMBOL_INFO pSym, ULONG SymbolSize, PVOID UserContext)
{
LocalsCtx& c = *(LocalsCtx *)UserContext;
if(pSym->Tag == SymTagFunction)
return TRUE;
RLOG("=== EnumLocals ========");
RDUMP(UserContext);
RDUMP(c.context);
RDUMP(pSym->Register);
Val& v = (pSym->Flags & IMAGEHLP_SYMBOL_INFO_PARAMETER ? c.param : c.local).GetAdd(pSym->Name);
v.address = (adr_t)pSym->Address;
if(pSym->Flags & IMAGEHLP_SYMBOL_INFO_REGISTER)
v.address = pSym->Register;
else
if(pSym->Flags & IMAGEHLP_SYMBOL_INFO_REGRELATIVE) {
if(pSym->Register == CV_ALLREG_VFRAME) {
#ifdef CPU_64
if(c.pdb->win64)
v.address += c.pdb->GetCpuRegister(*c.context, CV_AMD64_RBP);
else
#endif
v.address += (adr_t)c.pdb->GetCpuRegister(*c.context, CV_REG_EBP);
}
else
v.address += (adr_t)c.pdb->GetCpuRegister(*c.context, pSym->Register);
}
else
if(pSym->Flags & IMAGEHLP_SYMBOL_INFO_FRAMERELATIVE)
v.address += c.frame;
c.pdb->TypeVal(v, pSym->TypeIndex, (adr_t)pSym->ModBase);
LLOG("LOCAL " << pSym->Name << ": " << Format64Hex(v.address));
return TRUE;
}
Thanks a lot, I feel we are really very close now.
Mirek
[Updated on: Thu, 18 September 2014 12:56] Report message to a moderator
|
|
|
Re: Problems debugging with Visual C++ [message #43662 is a reply to message #43661] |
Thu, 18 September 2014 13:06 |
|
mirek
Messages: 14105 Registered: November 2005
|
Ultimate Member |
|
|
Ops, no need.
I guess I have found it. Such a stupid bug...
Please try to replace this method:
const VectorMap<int, Pdb::CpuRegister>& Pdb::GetRegisterList()
{
static VectorMap<int, CpuRegister> r32;
ONCELOCK {
#define CPU_REG(sym_, context_var, kind_, name_, flags_) { CpuRegister& r = r32.Add(sym_); r.sym = sym_; r.kind = kind_; r.name = name_; r.flags = flags_; }
#include "i386.cpu"
#undef CPU_REG
}
#ifdef CPU_64
static VectorMap<int, CpuRegister> r64;
ONCELOCK {
#define CPU_REG(sym_, context_var, kind_, name_, flags_) { CpuRegister& r = r64.Add(sym_); r.sym = sym_; r.kind = kind_; r.name = name_; r.flags = flags_; }
#include "amd64.cpu"
#undef CPU_REG
}
return win64 ? r64 : r32;
#else
return r32;
#endif
}
|
|
|
|
|
|
|
|
Goto Forum:
Current Time: Fri Nov 01 01:15:03 CET 2024
Total time taken to generate the page: 0.02677 seconds
|
|
|