Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
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 Go to next message
frankdeprins is currently offline  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 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 14105
Registered: November 2005
Ultimate Member
frankdeprins wrote on Thu, 11 September 2014 08:32
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


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 #43635 is a reply to message #43632] Tue, 16 September 2014 16:02 Go to previous messageGo to next message
frankdeprins is currently offline  frankdeprins
Messages: 99
Registered: September 2008
Location: Antwerp - Belgium
Member
Hello Mirek,

I am working on Windows 7 32-bit.
I will try finding a newer dbghelp.dll and keep you informed.

Thanks,

Frank
Re: Problems debugging with Visual C++ [message #43637 is a reply to message #43632] Wed, 17 September 2014 07:50 Go to previous messageGo to next message
frankdeprins is currently offline  frankdeprins
Messages: 99
Registered: September 2008
Location: Antwerp - Belgium
Member
Hello,

Found a newer version of the dll (6.5.xxx -> 6.12.xxx), but it made no difference.
I attached a screenshot with a simplified test scenario.

Frank
Re: Problems debugging with Visual C++ [message #43645 is a reply to message #43637] Wed, 17 September 2014 15:36 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 14105
Registered: November 2005
Ultimate Member
I have just spotted one issue that might cause this, can you check with latest svn please?

Other than that, I have to admit I never tested with 32-bit OS (but I did have tested theide compiled as 32 bit .exe).
Re: Problems debugging with Visual C++ [message #43646 is a reply to message #43645] Wed, 17 September 2014 15:41 Go to previous messageGo to next message
mirek is currently offline  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 #43647 is a reply to message #43646] Wed, 17 September 2014 16:36 Go to previous messageGo to next message
frankdeprins is currently offline  frankdeprins
Messages: 99
Registered: September 2008
Location: Antwerp - Belgium
Member
Thanks Mirek,

I'm afraid it did not solve the issue, but something changed: the double variable that you can see in the screenshot, is now not listed anymore at all. Only the two integers are listed and they are still both 0.

Anyway, here are the contents of theide.log:

* C:\Frank\upp\theide.exe 17.09.2014 16:30:42, user: FDP

-------------------------
Format64Hex(v.address) = ffffffffffffffe8
LOCAL i64: bc
-------------------------
Format64Hex(v.address) = fffffffffffffff0
LOCAL d: c4
-------------------------
Format64Hex(v.address) = fffffffffffffffc
LOCAL i: d0
-------------------------
Format64Hex(v.address) = 8
LOCAL app: 104
-------------------------
Format64Hex(v.address) = 8
LOCAL argc: 10
-------------------------
Format64Hex(v.address) = c
LOCAL argv: 14
-------------------------
Format64Hex(v.address) = ffffffffffffffdc
LOCAL mainret: 30
-------------------------
Format64Hex(v.address) = ffffffffffffffe0
LOCAL managedapp: 34
-------------------------
Format64Hex(v.address) = ffffffffffffffe4
LOCAL initret: 38


Frank
Re: Problems debugging with Visual C++ [message #43649 is a reply to message #43647] Wed, 17 September 2014 19:53 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 14105
Registered: November 2005
Ultimate Member
Well, believe or not, I think we are getting somewhere!

Normally, local variables take this path:

if(pSym->Flags & IMAGEHLP_SYMBOL_INFO_REGRELATIVE) {
if(pSym->Register == CV_ALLREG_VFRAME) {

(because they are relative to ebp). Obviously, it does not happen for you.

To check the theory, please

a) check both conditions: RDUMP(pSym->Flags & IMAGEHLP_SYMBOL_INFO_REGRELATIVE); RDUMP(pSym->Register == CV_ALLREG_VFRAME); RDUMP(pSym->Register) before first if
b) just for test, change them to 'true'

Thanks for help!

Mirek
Re: Problems debugging with Visual C++ [message #43650 is a reply to message #43649] Wed, 17 September 2014 19:56 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 14105
Registered: November 2005
Ultimate Member
PS.: If changing to true does not help, we might also try to comment out the test for register...

//	if(pSym->Flags & IMAGEHLP_SYMBOL_INFO_REGISTER)
//		v.address = pSym->Register;
//	else


Mirek

Re: Problems debugging with Visual C++ [message #43657 is a reply to message #43650] Thu, 18 September 2014 08:48 Go to previous messageGo to next message
frankdeprins is currently offline  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 #43658 is a reply to message #43657] Thu, 18 September 2014 10:51 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 14105
Registered: November 2005
Ultimate Member
Well, that is interesting, because 22 is CV_REG_EBP, so it essentially seems to do the very same and correct thing... but it looks like the value fetched from the register is for some reason wrong.

Can we check?

	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);
		RDUMP(Format64Hex((adr_t)c.pdb->GetCpuRegister(*c.context, pSym->Register)));
		RDUMP(Format64Hex(v.address));
	}

Re: Problems debugging with Visual C++ [message #43659 is a reply to message #43658] Thu, 18 September 2014 11:02 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 14105
Registered: November 2005
Ultimate Member
BTW, is backtrace OK (except perhaps parameter values)?

[Updated on: Thu, 18 September 2014 11:08]

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 Go to previous messageGo to next message
frankdeprins is currently offline  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 Go to previous messageGo to next message
mirek is currently offline  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 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 14105
Registered: November 2005
Ultimate Member
Ops, no need.

I guess I have found it. Such a stupid bug... Sad

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
}
Re: Problems debugging with Visual C++ [message #43665 is a reply to message #43662] Thu, 18 September 2014 13:48 Go to previous messageGo to next message
frankdeprins is currently offline  frankdeprins
Messages: 99
Registered: September 2008
Location: Antwerp - Belgium
Member
Since a picture says more than a 1000 words...
Please check new screenshot.

It seems you nailed it: congratulations Cool
Re: Problems debugging with Visual C++ [message #43666 is a reply to message #43665] Thu, 18 September 2014 13:50 Go to previous messageGo to next message
frankdeprins is currently offline  frankdeprins
Messages: 99
Registered: September 2008
Location: Antwerp - Belgium
Member
And here is the latest log file
  • Attachment: theide.log
    (Size: 2.97KB, Downloaded 276 times)
Re: Problems debugging with Visual C++ [message #43667 is a reply to message #43666] Thu, 18 September 2014 13:53 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 14105
Registered: November 2005
Ultimate Member
Thanks a lot with helping me with this. It was very stochastic error (unintialized data with only 1/256 chance of bad behaviour), in theory I could have got it here too, but was not).
Re: Problems debugging with Visual C++ [message #43668 is a reply to message #43667] Thu, 18 September 2014 14:04 Go to previous messageGo to next message
frankdeprins is currently offline  frankdeprins
Messages: 99
Registered: September 2008
Location: Antwerp - Belgium
Member
No problem at all; it's the least I can do to thank for such a great environment.

By the way: I understand you are using Upp for 64 bit windows development.
Since I got my new machine, yesterday, I wonder if the conversion from 32 bit is a smooth ride.
Are you using Visual Studio 13?

Regards,

Frank
Re: Problems debugging with Visual C++ [message #43670 is a reply to message #43668] Thu, 18 September 2014 23:20 Go to previous messageGo to previous message
mirek is currently offline  mirek
Messages: 14105
Registered: November 2005
Ultimate Member
frankdeprins wrote on Thu, 18 September 2014 14:04
No problem at all; it's the least I can do to thank for such a great environment.

By the way: I understand you are using Upp for 64 bit windows development.
Since I got my new machine, yesterday, I wonder if the conversion from 32 bit is a smooth ride.


I guess it always was. Well, before last batch of changes in debugger, you had to use 32-bit theide and was only able to debug 32-bit apps (but you could compile 64-bits even then). Now you can use 32-bit compiled theide.exe in the same mode as before and 64-bit for both 32-bit and 64-bit debugging.


Are you using Visual Studio 13?
[/quote]

I am only using the free SDK, usually, it includes all you need for U++.

Mirek
Previous Topic: Debugger support for enum values would be nice
Next Topic: Need help compiling UPP tarball on Linux Mint 17 Qiana
Goto Forum:
  


Current Time: Fri Nov 01 01:15:03 CET 2024

Total time taken to generate the page: 0.02677 seconds