[Solved] Debugging CEGUI 0.8.X strings in Visual Studio
Moderators: CEGUI MVP, CEGUI Team
[Solved] Debugging CEGUI 0.8.X strings in Visual Studio
It is difficult for me to see the contents of a CEGUI::String in visual studio. I basically have to add something like this to the watch window and then expand it and ignore every other letter:
(wchar_t *)(stringVar).d_quickbuff,50
There must be an easier way. Is there some way to get Visual Studio to recognize a UTF-32 string?
Joe
(wchar_t *)(stringVar).d_quickbuff,50
There must be an easier way. Is there some way to get Visual Studio to recognize a UTF-32 string?
Joe
- CrazyEddie
- CEGUI Project Lead
- Posts: 6760
- Joined: Wed Jan 12, 2005 12:06
- Location: England
- Contact:
Hi,
Apologies for the lateness of this response; I have been unwell.
I agree dedbugging without seeing the strings can be a pain. It is possible to extend Visual C++ to display the string "normally". The way you do this is dependent upon the version of VC++ in use. Way back in the distant past a guy here on the forum provided such a thing for VC++ 2003.
As I understand it, the process is much easier in VC++ 2005 and higher. I don't think anyone has done a data visualizer for this already, though my memory could be fuzzy.
The following video on MSDN might be useful, it shows how to create a visualizer: http://msdn.microsoft.com/en-us/visualc/bb684927.aspx
HTH
CE.
Apologies for the lateness of this response; I have been unwell.
I agree dedbugging without seeing the strings can be a pain. It is possible to extend Visual C++ to display the string "normally". The way you do this is dependent upon the version of VC++ in use. Way back in the distant past a guy here on the forum provided such a thing for VC++ 2003.
As I understand it, the process is much easier in VC++ 2005 and higher. I don't think anyone has done a data visualizer for this already, though my memory could be fuzzy.
The following video on MSDN might be useful, it shows how to create a visualizer: http://msdn.microsoft.com/en-us/visualc/bb684927.aspx
HTH
CE.
Nice CE,
That eeaddin sample was a bit tricky, when i did as follows I got it working.
This is how i did it in VS2008.
Create an empty win32 (.dll) project. I called it CEGUIDbg.
Remove unicode setting for the project in properties.
Add the preprocessor define CEGUI_STATIC.
Add CEGUIString.h and CEGUIString.cpp to the project.
Remove precompiled header usage on CEGUIString.cpp.
Add the search path to CEGUI\inc directory, CEGUIBase.h needs to be in that search path.
add this postbuild event, this will copy ceguidbg.dll to the same folder as devenv.exe, usually C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE
(There might be security issue with this copy in Windows Vista, can be done manually.)
This is the file: CEGUIDbg.cpp
Find the file autoexp.dat, usually in this path
C:\Program Files\Microsoft Visual Studio 9.0\Common7\Packages\Debugger
Add this line under the section [AutoExpand]
Now build and you will see the strings as utf8 encoded strings in VStudio.
HTH,
Gring
That eeaddin sample was a bit tricky, when i did as follows I got it working.
This is how i did it in VS2008.
Create an empty win32 (.dll) project. I called it CEGUIDbg.
Remove unicode setting for the project in properties.
Add the preprocessor define CEGUI_STATIC.
Add CEGUIString.h and CEGUIString.cpp to the project.
Remove precompiled header usage on CEGUIString.cpp.
Add the search path to CEGUI\inc directory, CEGUIBase.h needs to be in that search path.
add this postbuild event
Code: Select all
copy $(TargetPath) "$(DevEnvDir)"
(There might be security issue with this copy in Windows Vista, can be done manually.)
This is the file: CEGUIDbg.cpp
Code: Select all
// CEGUIDbg.cpp : Defines the exported functions for the DLL application.
//
#include "stdafx.h"
#include "tchar.h"
#include "ceguistring.h"
#define ADDIN_API __declspec(dllexport)
typedef struct tagDEBUGHELPER
{
DWORD dwVersion;
HRESULT (WINAPI *ReadDebuggeeMemory)( struct tagDEBUGHELPER *pThis, DWORD dwAddr,
DWORD nWant, VOID* pWhere, DWORD *nGot );
// from here only when dwVersion >= 0x20000
DWORDLONG (WINAPI *GetRealAddress)( struct tagDEBUGHELPER *pThis );
HRESULT (WINAPI *ReadDebuggeeMemoryEx)( struct tagDEBUGHELPER *pThis, DWORDLONG qwAddr,
DWORD nWant, VOID* pWhere, DWORD *nGot );
int (WINAPI *GetProcessorType)( struct tagDEBUGHELPER *pThis );
} DEBUGHELPER;
static void CEGUI_print(char *pResult, int max, int len, const char *pbuf)
{
try
{
sprintf_s(pResult, max, "%d,\"%s\"", len, pbuf);
}
catch(...)
{
sprintf_s(pResult, max, "%d,\"%10s<Err>", len, pbuf);
}
}
ADDIN_API HRESULT WINAPI CEGUIDbg_String(DWORD dwAddress, DEBUGHELPER *pHelper,
int nBase, BOOL bUniStrings, char *pResult,
size_t max, DWORD reserved )
{
CEGUI::String s;
DWORD nGot;
if (pHelper->ReadDebuggeeMemory(pHelper,dwAddress,sizeof(s),&s,&nGot) != S_OK)
return E_FAIL;
int len = s.length();
if (!len)
{
CEGUI_print(pResult, max, len, "");
}
else if (s.capacity() < STR_QUICKBUFF_SIZE)
{
CEGUI_print(pResult, max, len, s.c_str());
}
else
{
UINT32 *buf = new UINT32[len + 1];
CEGUI::String s1;
if (pHelper->ReadDebuggeeMemory(pHelper, (DWORD)s.ptr(), sizeof(UINT32) * len, buf, &nGot) != S_OK)
{
delete [] buf;
return E_FAIL;
}
for (int i = 0; i < len; i++)
s1 += buf[i];
delete[] buf;
CEGUI_print(pResult, max, len, s1.c_str());
}
return S_OK;
}
Find the file autoexp.dat, usually in this path
C:\Program Files\Microsoft Visual Studio 9.0\Common7\Packages\Debugger
Add this line under the section [AutoExpand]
Code: Select all
CEGUI::String=$ADDIN(ceguidbg.dll,?CEGUIDbg_String@@YGJKPAUtagDEBUGHELPER@@HHPADIK@Z)
Now build and you will see the strings as utf8 encoded strings in VStudio.
HTH,
Gring
- CrazyEddie
- CEGUI Project Lead
- Posts: 6760
- Joined: Wed Jan 12, 2005 12:06
- Location: England
- Contact:
Re: Debugging CEGUI strings in Visual Studio
Just wanted to mention I followed these instructions using Visual Studio 2010 on Windows 7 and it worked great. A couple notes - as mentioned in the instructions, running VS with standard user permissions caused copying the dll as a post build step to fail. I just copied via Windows Explorer and confirmed admin permissions in the process. The directory was "C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE" in my case, as indicated by the failure warning in the VS output window when trying to execute the post build step. I assume running VS as administrator would allow the copy to succeed, but I didn't bother trying.
I also didn't need to change any unicode settings in the project properties as instructed. Also, that step is pretty vague, so I'm not exactly sure what was meant anyway.
Thanks a ton @gring for the instructions. Not being able to see assert text in the debugger was driving me particularly crazy.
I also didn't need to change any unicode settings in the project properties as instructed. Also, that step is pretty vague, so I'm not exactly sure what was meant anyway.
Thanks a ton @gring for the instructions. Not being able to see assert text in the debugger was driving me particularly crazy.
-
- Just popping in
- Posts: 18
- Joined: Sat Aug 04, 2012 16:35
Re: Debugging CEGUI strings in Visual Studio
Thanks for bumping this thread, was exactly what i was looking for (and it works wonderfully) but couldn't find a way to do it Was bugging the hell out of me i couldn't see strings under debugging.
- CrazyEddie
- CEGUI Project Lead
- Posts: 6760
- Joined: Wed Jan 12, 2005 12:06
- Location: England
- Contact:
Re: Debugging CEGUI strings in Visual Studio
Guys, just a heads up that the above code has a bug in it I draw your attention to another forum topic where I've posted a fixed version of the function: viewtopic.php?p=22009#p22009
I'm not sure why or how we ended up with two separate topics each with a bit of the solution, but still, at least now I have finally back linked this topic to the other one
I can confirm my fixed code also does work in MSVC++ 2010, since I had cause to provide a running version to somebody a few weeks ago.
CE.
I'm not sure why or how we ended up with two separate topics each with a bit of the solution, but still, at least now I have finally back linked this topic to the other one
I can confirm my fixed code also does work in MSVC++ 2010, since I had cause to provide a running version to somebody a few weeks ago.
CE.
Useful Links: Forum Guidelines | Documentation | Tutorials | HOWTO | Videos | Donate to CEGUI | CEGUI Twitter
-
- Just popping in
- Posts: 18
- Joined: Sat Aug 04, 2012 16:35
Re: Debugging CEGUI strings in Visual Studio
Thanks.
I updated it to your code and works fine.
I updated it to your code and works fine.
Re: Debugging CEGUI strings in Visual Studio
What I usually do is to drag and drop the variable that contains the string into the watch window and then edit the variable ariable name adding ".c_str()" which gives me the string content as if it was a normal C string.
Re: Debugging CEGUI strings in Visual Studio
Hello!
Sorry if I bump this old thread, but is this dll working with newer visuals studio (2015) / CEGUI 0.8.7?
As a newbie I really can't understand how to come up with those:
1) Add CEGUIString.h and CEGUIString.cpp to the project.
2) Remove precompiled header usage on CEGUIString.cpp.
3) Add the search path to CEGUI\inc directory, CEGUIBase.h needs to be in that search path.
Could someone please point me out in the right direction?
Many thanks in advance!
Sorry if I bump this old thread, but is this dll working with newer visuals studio (2015) / CEGUI 0.8.7?
As a newbie I really can't understand how to come up with those:
1) Add CEGUIString.h and CEGUIString.cpp to the project.
2) Remove precompiled header usage on CEGUIString.cpp.
3) Add the search path to CEGUI\inc directory, CEGUIBase.h needs to be in that search path.
Could someone please point me out in the right direction?
Many thanks in advance!
Re: Debugging CEGUI strings in Visual Studio
Try this: https://bitbucket.org/cegui/cegui/downl ... _0-8-X.zip
Description is in the readme
Description is in the readme
CrazyEddie: "I don't like GUIs"
Re: Debugging CEGUI strings in Visual Studio
Thank you,
Worked pefectly in VS 2015!
Worked pefectly in VS 2015!
Re: [Solved] Debugging CEGUI 0.8.X strings in Visual Studio
Hey,
Lubens String debugger is unstable for me on VS2015, but after some fiddling i managed to create a simpler natvis for VS2015.
Please also report back if this works for you
https://bitbucket.org/snippets/Flonor/ojpLAX
Lubens String debugger is unstable for me on VS2015, but after some fiddling i managed to create a simpler natvis for VS2015.
Please also report back if this works for you
https://bitbucket.org/snippets/Flonor/ojpLAX
Re: [Solved] Debugging CEGUI 0.8.X strings in Visual Studio
FluXy wrote:Hey,
Lubens String debugger is unstable for me on VS2015, but after some fiddling i managed to create a simpler natvis for VS2015.
Please also report back if this works for you
https://bitbucket.org/snippets/Flonor/ojpLAX
I tested the natvis file and added it to the downloads: https://bitbucket.org/cegui/cegui/downloads/
CrazyEddie: "I don't like GUIs"
Return to “Modifications / Integrations / Customisations”
Who is online
Users browsing this forum: No registered users and 9 guests