Solved

simple debugging of a dll/activeX

Posted on 2000-03-23
10
441 Views
Last Modified: 2013-12-14
I have some C++ code that gets compiled into an ActiveX, and run from within a larger program.  My code needs debugging - what is the best way to ouput some logging information?  Is writing to an external file the simplest approach?  How would I do this?

I tried just doing
    cout << "The 'all' string: " << endl;
but got
D:\My Documents\aa Vc\ts1\CNodeView1.cpp(651) : error C2018: unknown character '0xa0'
D:\My Documents\aa Vc\ts1\CNodeView1.cpp(651) : error C2018: unknown character '0xa0'
D:\My Documents\aa Vc\ts1\CNodeView1.cpp(651) : error C2872: 'cout' : ambiguous symbol

Why these errors?  My includes are
#include "stdafx.h"
#include <iostream>
#include <list>
#include <string>
#include<vector>
#include <ctype.h>
using namespace std;

Its probably better I output to a file anyway.  Or to a console?
I am using VC++6
0
Comment
Question by:abulka
  • 5
  • 3
  • 2
10 Comments
 
LVL 22

Expert Comment

by:nietod
ID: 2651864
>>  My code needs debugging
You aren't at the debugging stage, your code isn't even compiling.  First you have to make it compile, then if it doesn't run right, you have to debug it.  Right now it can'be run because it doesn't compile.

in

cout << "The 'all' string: " << endl;

you can't just have a single quote inside a string.  You must palce a \ character before the quote to signal the compiler that you want a single quote to appear in the string, like

cout << "The \'all\' string: " << endl;

If that doesn't fix the problem, you need to post more of the code.
0
 

Author Comment

by:abulka
ID: 2651970
Adjusted points from 20 to 25
0
 

Author Comment

by:abulka
ID: 2651971
The cout << .... code was just included as a potential way of generating debug output.  The question is about the best way of doing that given my context.  I'm happy to forget about using cout << ... and get some code which deals with writing to a file, for example.

P.s. Even
  cout << "got to this point" << endl;
doesn't compile e.g.
D:\My Documents\aa Vc\ts1\CNodeView1.cpp(651) : error C2018: unknown character '0xa0'
D:\My Documents\aa Vc\ts1\CNodeView1.cpp(651) : error C2018: unknown character '0xa0'
D:\My Documents\aa Vc\ts1\CNodeView1.cpp(651) : error C2872: 'cout' : ambiguous symbol
Error executing cl.exe.

The point
0
Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

 
LVL 1

Accepted Solution

by:
tomkeane earned 25 total points
ID: 2652214
You can debug the dll directly.  Go to Project Settings->Debug tab.  In the field "Executable for debug session" put in the path to an executable that loads your dll.  The application can be any executable, it does not have to be a program you have source code to.  Set the breakpoints in your dll where you and hit F5.

HTH,

Tom
0
 

Author Comment

by:abulka
ID: 2652327
I'd love to debug 'live' - will this above technique work when my dll is an activeX?  The main app is a delphi app which loads some activeX's which then load my VC++ active X.

0
 
LVL 1

Expert Comment

by:tomkeane
ID: 2652380
I can't think of any reason why it would not work.  It doesn't really matter what the exe is - as long as it loads your dll and makes calls into it.  It doesn't really matter whether it is loading your dll via implicit linking, by using LoadLibrary, or through a call to COM.

Tom
0
 

Author Comment

by:abulka
ID: 2652582
tomkeane - it worked - unbelievable.  thanks.  Just one last question before I accept:  When I exit my app I get an exception violation/crash at some address in my dll.  The source code does not come up for me though - so I'm in the dark as to where it is crashing... Any idea on getting the debugger to show me?

thanks
0
 
LVL 1

Expert Comment

by:tomkeane
ID: 2652617
Hmmmmm.  Those can be tough.  The first thing I'd try would be setting breakpoints on functions in your dll that get called right at the end of its life.  For an ActiveX dll you could try any or all of the following: The Release method of your object, your COM object's destructor, your dll's DllCanUnloadNow() function, your dll's DllMain() function.
You also might want to take a look at any static or file scope objects you have, if any.
Is this something that only happens when you run it in the debugger, or does it also happen if you launch the program normally?  If it only happens in the debugger it may be that DevStudio and the Delphi runtime are disagreeing about something....

Tom
0
 

Author Comment

by:abulka
ID: 2655903
Thanks.

By the way, I also found a way to do debug logging:

#include <iostream>
#include <fstream>

    std::ofstream  zout("e:/debuglog.txt");
    zout << "Hello, world\n";
    zout << "RectWidth is " << RectWidth << "\n";
    zout << endl;
0
 
LVL 22

Expert Comment

by:nietod
ID: 2656418
>> I also found a way to do debug logging:
You might find that using OutputDebugString() is even better for this.
0

Featured Post

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Jaspersoft Studio is a plugin for Eclipse that lets you create reports from a datasource.  In this article, we'll go over creating a report from a default template and setting up a datasource that connects to your database.
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…

776 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