Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

debug from command line

Posted on 2001-06-08
10
Medium Priority
?
331 Views
Last Modified: 2010-04-02
I'm using VC++6.  One of my classes is throwing an exception, but only if I run the program from the command line, not if I run it from the IDE.  

How do I debug when I'm running the program from the command line?
0
Comment
Question by:codeghost
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
  • 2
  • +1
10 Comments
 
LVL 86

Expert Comment

by:jkr
ID: 6168283
The easiest way it to hard-code an 'EXCEPTION_BREAKPOINT', which will make the debugger attach to your program when executed. Just insert

__asm { int 3};

at an appropriate line...
0
 
LVL 30

Expert Comment

by:Axter
ID: 6168674
Are you testing it in NT or Win9x?
0
 
LVL 30

Expert Comment

by:Axter
ID: 6168709
If you're using NT, you can try changing your "Executable for Debug Session" to "C:\WINNT\system32\cmd.exe"

The cmd.exe program will launch the Dos window.
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 

Author Comment

by:codeghost
ID: 6169875
I am running on Windows 98.

jkr, can you give me an example here of how to use

                     __asm { int 3};

                     at an appropriate line...

What should I expect to see as that code is executed?
0
 
LVL 86

Accepted Solution

by:
jkr earned 200 total points
ID: 6169940
>jkr, can you give me an example here of how to use

Well, it's an example itself :o)

No, to be serious, you could just place that statement at any place in your code that is executed before the exception takes place.

>>What should I expect to see as that code is executed?

Your application will be loaded into the debugger the way it is, and you can just examine that app in 'real life' along with e.g. setting breakpoints and watches.
0
 

Expert Comment

by:robertmitchell_99
ID: 6171647
Hi Codeghost,

You've got a number of options.

1. The simplest and easiest way is to set up your program as a debug executable.
 - Got to Project->Settings->Debug via the main menu.
 - Enter the whole path for your executable in the
     "Executable for debug session" box

 - If you have command line parameters pass them to  
      your exe by putting them in the Program Arguments    
       box.

 - place a breakpoint in your program as usual and hit f5

2. If for any other reason you can't do this then you need to put a DebugBreak(); or __asm { int 3}; in your code at the point from which you wish to begin debugging.

You must compile the program in Debug, invoke your exe  and the program will run, then stop and produce a message box at the point of your DebugBreak();

You can then either press the cancel option which will start an instance of visual studio to debug into your code, or you can attach to the executable while it is stopped from the main menu: Press Build->Start Debug->Attach To Process.

I hope you manage to attach to it okay.  The alternatives to DebugBreak() are ATLASSERT, ASSERTE_ or just put in a MessageBox();

This is just to stop execution at the correct place so you can attach to process.

Best of luck

Robert.


 
0
 
LVL 86

Expert Comment

by:jkr
ID: 6171742
>>Enter the whole path for your executable in the
>>    "Executable for debug session" box


>>2. If for any other reason you can't do this then you
>>need to put a DebugBreak(); or __asm { int 3};
>>in your code at the point from which you wish to begin
>>debugging.

robertmitchell_99, all that has already been proposed. You should definitely take time to read a question's history before posting an answer. You should also spend a few seconds to scroll to the bottom of this page, where the 'Tips on Comments and Answers' are listed...



0
 

Author Comment

by:codeghost
ID: 6172094
I had already tried jkr's solution and it worked for me.
0
 

Author Comment

by:codeghost
ID: 6172096
I had already tried jkr's solution and it worked for me.
0
 

Author Comment

by:codeghost
ID: 6172101
having trouble with the site.... getting a Java error.  Hopefully this will go through this time.
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article shows you how to optimize memory allocations in C++ using placement new. Applicable especially to usecases dealing with creation of large number of objects. A brief on problem: Lets take example problem for simplicity: - I have a G…
Container Orchestration platforms empower organizations to scale their apps at an exceptional rate. This is the reason numerous innovation-driven companies are moving apps to an appropriated datacenter wide platform that empowers them to scale at a …
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

604 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question