Show Environment Variable while Debugging in Visual Studio 2005? - c++

I would like to examine the contents of an environment variable while I am debugging a C++ program in visual studio. Have googled lots but have not found the procedure to do so... any advice on how I can do this? Thanks!

None of the suggested methods worked for me... I do not know why (though I'm sure I was just missing something simple). I wound up using Process Explorer to examine the environment for the process, gave me the info I required.

Adding a watch that calls the C getenv function (e.g. getenv("PATH")) seems to work.

Related

I don't see the "Publish" button. How to make standalone exe-file from C++ code?

Problem is the same as here:
Visual Studio 2017 - Not Able to see Publish - Missing Profile / Deployment Options
https://developercommunity.visualstudio.com/content/problem/129404/missing-publish-menu-in-netcore-web-project-right.html
except the fact that I didn't see the button earlier (I've started coding in Visual Studio just recently). I've installed some packages, which were adviced in mentioned topics, like "Azure" and "ASP.NET", but it didn't solve the problem. I don't understand, how it could help (I code on C++ and have not to use these packages, do I?) and what exactly I should do (maybe I've downloaded something wrong).
Thank you in advance!
Update
If I understand right, there is no way to "publish" C++ code, according to:
https://social.msdn.microsoft.com/Forums/en-US/6998eadb-36fb-4a97-bba5-0de49d533732/how-can-i-publish-a-visual-c-project-?forum=vsclassdesigner
Then, how to make standalone exe-file, that doesn't require something other like .pdb, .ipdb and .iobj and can be run on another coumputer without Visual Studio?
The command that creates the binary is called "Build".
I can't say for sure, but I think that "Debug" builds to run on another computer need vcredist, while "Release" builds can run without anything else. Again, I am not sure.

Can't see boost::optional contents when debugging with Visual Studio

If I try to look at the variable directly, I see a ? sign. If I create a watch calling the is_initialized function, I get the following error:
CXX0033: Error: error in OMF type information
I didn't find much info about this error related to Boost using Google.
Anybody else experienced this? It's a hassle using OutputDebugString everywhere and rebuilding...
EDIT: Using Visual Studio 2010 SP1 with all hotfixes in Windows XP SP3 idem, and Boost 1.49.0
UPDATE: This issue comes and goes, it doesn't happen consistently; Debugger Visualizers are a great solution, I've adopted them as my brand new tool
You can use DebuggerVisualizers.
Use DebuggerVisualizers to make this transition:
Before
After
P.S. I tried to add these images to clarify the accepted answer but my edit was rejected.
Try this: for a variable boost::optional<Category> category, create a watch on: category.get()

Tool for debugging Borland & Visual Studio applications

sometimes I have to debug an application that was written with Borland C++ Builder. This application loads dlls compiled with Visual C++. Is there a debugger that can debug both parts of the application? Currently I have to decide - either I can easily set break points and see the source in Visual Studio or I have to start Borland C++, but I can't work with the source from the Visual-Studio compiled dll.
thank you for your help,
Tobias
You could try OllyDbg - version 1.x does not seem to support the latest Win version but there is also the 2.0 although it's still in alpha state(haven't tried myself that one yet).
EDIT - clarification:
Source debugging OllyDbg reads debugging information in Borland and
Microsoft formats. This information includes source code and names of
functions, labels, global and static variables. Support for dynamical
(stack) variables and structures is very limited.
The above is take from here.
UPDATE:
I'm not familiar with the Borland C++ Builder but at this link you can find some articles explaining how to deal with some interoperability issues between Borland and MS that might be of help.
if both parts built using ulink linker and have debug info you could try cdb32 debugger (from the ulink linker author)
cdb32 is still in its alpha stage though and I personally never tried such "mixed" debugging
Have you tried loading the DLL code in VS, loading the app code in BCB, and having both debuggers attached to the same running process at the same time? Not sure if Windows will allow that, but it might be worth a try.
I suspect there is no perfect answer to your question, you are going to have to compromise in some way, as I'm sure you are already doing.
I have a similar problem to yours at work. The applications that I work on are written in Python instead of Borland C++, but like your situation, these apps rely on a rather large Visual Studio compiled DLL for some functions.
My method of debugging these applications involves a combination of two debugging strategies: the use of an interactive debugger and the so called "printf" debugging technique.
What I basically do is pick one of the two areas as my main debug focus, and that determines my debugging approach:
If for a given situation I decide that I need to debug the DLL with greater detail, then I work with the VS debugger. I set the executable to run in the DLL project as my python script and that enables full debugging of the DLL code. If I need debugging support from the Python side, then I add print statements. If I need a breakpoint on the Python side to inspect some values, I just print all those values and immediately after call a C++ function that does nothing, but that has a breakpoint set in VS.
When I need to concentrate more on the Python side more I use a Python interactive debugger, but I have VS with the DLL project loaded on the side so that I can quickly add any necessary printfs on the DLL and recompile, so essentially the reverse of the above.
I know it's not the answer you expect, but it is a decent solution in my opinion.
It looks that it is possible to convert the debugging information generated by C++ Builder to a format understood by WinDbg (link to discussion). If so you could use it to debug both parts of your application (I haven't tried this though).
you can convert the .map files to Microsoft's debug file format
http://code.google.com/p/map2dbg/
now you can use Windebug; there is also a tool mentioned to convert to pdb format, so you could try the vc++ debugger

Does the visual studio 2008 profiler work with unmanaged C++?

I know that VS 2008 Team Edition has a profiler, but I'm also aware of the recent trend they have at Microsoft of completely ignoring unmanaged languages (what's the last time unmanaged C++ got something cool in the IDE?!).. For example I know for a fact that the IDE "Unit Tests" and "Code Metrics" features don't work with unmanaged code.
I tried to google but didn't find any info; so, does anyone know if it works or not?
Yes, it works with native code.
Well I tried it and it does not produce any useful info. For example, in the "Functions" view the source file name is shown as for everything. And yes I am building the release version and have turned on debug info (tried both /Z7 and /Zi). I also tried both Instrumentation and Sampling methods with the same (non) results.
My previous comment last something as stuff in < > was lost. Source files are shown as "Unknown" and I can only see the relative time in each module. This is not a lot of use. How do I get decent output? (Give me TrueTime for VS2008!!)

Tools, Visual Studio Setting to check uninitialized class members

I am porting a big and complex c++ server from Solaris to Windows. I am facing lots of trouble due to uninitialized member variables. On Solaris they get set to 0 value by default hence things work fine. But, on windows those member variables get garbage values assigned creating mayhem in the system.
Code base is too huge to manually check each class. Are you aware of any tool or Visual Studio settings that would issue warning if the member variables are not initialized in the constructor?
Thanks in advance!
cppcheck does a very good job at finding uninitialized variables.
You can also use an external tool for such task, like PCLint.
You can enable the Code Analysis in Visual Studio (C++ Projects):
Project Propertys --> C/C++ --> Enable Code Analysis for C/C++ on build