Solved

simple debugging of a dll/activeX

Posted on 2000-03-23
10
433 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
Comment Utility
>>  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
Comment Utility
Adjusted points from 20 to 25
0
 

Author Comment

by:abulka
Comment Utility
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
 
LVL 1

Accepted Solution

by:
tomkeane earned 25 total points
Comment Utility
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
Comment Utility
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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 1

Expert Comment

by:tomkeane
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
>> I also found a way to do debug logging:
You might find that using OutputDebugString() is even better for this.
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Introduction This article is the first in a series of articles about the C/C++ Visual Studio Express debugger.  It provides a quick start guide in using the debugger. Part 2 focuses on additional topics in breakpoints.  Lastly, Part 3 focuses on th…
This article will show you some of the more useful Standard Template Library (STL) algorithms through the use of working examples.  You will learn about how these algorithms fit into the STL architecture, how they work with STL containers, and why t…
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…
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.

762 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now