Debugging Trick

My colleague Kang Su (that's his first name) came by my office yesterday to borrow a book. You might think a story that starts like this couldn't possibly lead to anything interesting. This tale is compelling though so hang tight. So the book in question was Debugging Applications for Microsoft .NET and Microsoft Windows (what a mouthful!). It's supposedly a classic and Kang Su could not find his copy. As we were chatting, he decided to bring up the issue for which he wanted to borrow the book in the first place. Kang Su, being the most technical PM to grace the halls of Visual C++, wanted to debug Phoenix (the next generation compiler) using Visual Studio. The problem lies in the fact that he does not have a solution and the executable relies on a bunch of environment variables. He asked me for a way to launch the app, in the debugger, with the environment set, all in one fell swoop. Instead of letting him leaf through the 800+ pages of the tome he was taking, I decided to take a look at the command-line switches for devenv.exe. Lo and behold, the answer was simple.

> set ENV_VARIABLE=value

> devenv /useenv /debugexe myapp.exe [ <myapp arguments> ]


That's all folks!

Comments (2)
  1. BlakeHandler says:

    So I guess that RTFM doesn’t always work — RTFCL? (^_^)

  2. Boris says:

    I’d have to say yes and no. The size of our products (and software products in the industry at large) have yielded ridiculous amounts of functionality, which in turn have lead to super-sized documentation. Google, Wikipedia all help on the path to bringing that wealth of knowledge to the forefront but I think there’s a real problem in discoverability. At some point, it’s nice to go command-line, type devenv /? | findstr "debug" 🙂 Clearly, something I should chat about in a blog post.

Comments are closed.

Skip to main content