★ wanayoo — archive 1999 http://codeguru.developer.com/tips/CustomizingDebug.shtmlNouvelle recherche | Portail wanayoo
EarthWeb
Developer.com Click Here!
Click Here!
Find:
 

EXPERT SEARCH
-----
Site
visual c++
java
visual basic
javascripts
recommend it
 
Shopping
codeguru store
 
Contest
mfc codeguru
submission guidelines
 
Book
thinking in c++
stl programmer's guide
reviews
 
Interact
forums
newsgroups
guest book
jobs
jokes
open faq
what's new
 
Other
about
links
newsletters
privacy
tools
 

-----
Visual C++ by E-mail:

Get the weekly e-mail highlights on
Visual C++!
-----



EarthWeb Sites:
CROSSNODES
DATAMATION
DEVELOPER.COM
DICE
DISCUSSIONS
EARTHWEB.COM
EARTHWEB DIRECT
EARTHWEB EVENTS
ERP HUB
GAMELAN
GOCERTIFY
HTML GOODIES
INTRANET JOURNAL
ITKNOWLEDGE
ITLIBRARY
JARS
JAVA GOODIES
JAVASCRIPTS.COM
OPEN SOURCE IT
PERL JOURNAL
ROADCODERS
SYSOPT.COM
SUPPORTSOURCE
Y2KINFO

EarthWeb Worldwide

   

Customizing the appearence of your own classes in debug windows


This article was contributed by Ville Herva.

Environment: Visual C++ 6

You may have noticed that for example CString instaces do not show up as `{...}´ in debug windows (watch, variable, etc. and in tooltip when you move the pointer on a variable). Rather, CString "smartly" shows up as `{"string"}´. This feature can be customized to make your own classes appear smartly while debugging, so that you can see the most crucial member varibles at first glance rather than having to expand the non-meaningful `{...}´ at first.

The definitions for the custom formatting reside in autoexp.dat in Common\MSDev98\Bin directory. The file has a fairly good documentation in it, and some good examples as well (including the CString one.) As with the usertype.dat (that has been dealt with in another article here), you'll have to restart MSVC to have the changes take effect.

This is a snippet from the file itself - it explains the syntax quite well.


; type=[text]...
;
; type Name of the type (may be followed by <*> for template
; types such as the ATL types listed below).
;
; text Any text.Usually the name of the member to display, 
; or a shorthand name for the member.
;
; member Name of a member to display.
;
; format Watch format specifier. One of the following:
;
; Letter Description Sample Display
; ------ -------------------------- ------------ -------------
; d,i Signed decimal integer 0xF000F065,d -268373915
; u Unsigned decimal integer 0x0065,u 101
; o Unsigned octal integer 0xF065,o 0170145
; x,X Hexadecimal integer 61541,X 0X0000F065
; l,h long or short prefix for 00406042,hx 0x0c22
; d, i, u, o, x, X
; f Signed floating-point 3./2.,f 1.500000
; e Signed scientific-notation 3./2.,e 1.500000e+000
; g Shorter of e and f 3./2.,g 1.5
; c Single character 0x0065,c 'e'
; s Zero-terminated string 0x0012fde8,s "Hello world"
; su Unicode string 0x007200c4,su "Hello world"
; st String in ANSI or Unicode depending on current setting
;
; The special format <,t> specifies the name of the most-derived 
; type of the object. This is especially useful with pointers or
; references to a base class.
;
; If there is no rule for a class, the base classes are checked for
; a matching rule.

For example, the line for CString is

CString =<m_pchData,st>

If you have a class like this,

class Goo
{
int width;
double height;
char* name;
};

you might define the apperance as follows:

Goo =<name,s> width: <width,i> height: <height,g> 

which would result in the following outlook in the debug window:

{"a goo" width: 5 height: 3.1}

Date Last Updated: April 18, 1999

Comments:

Add Comment

   

Give them a visit Click Here!

Click Here!

INSTANT EXPERTS!
Savvy IT Pros report on SupportSource. Take a look inside the largest vault of multi-vendor computing specs ever assembled. Click here for an In-depth Report,.

Learn about Free & Open Source software at the Bazaar Conference & Expo!,
December 14-16, 1999 in New York City! Click here for more information.

For tons of Windows technology resources, check out the Windows Programming directory.

Go to Fatbrain for the NEWEST and BEST technical books for IT professionals.

Get Linux Utilities for ONLY $34.95 at EarthWeb Direct.

Give them a visit Click Here!

Click Here!

Click Here!

Click Here!

Home About Us Search Subscribe Advertising Info Contact Us FAQs
Use of this site is subject to certain Terms & Conditions.
Earthweb's statement regarding our users' right to privacy.
Copyright ©1996-2000 EarthWeb Inc.. All rights reserved. Reproduction in whole or in part in any form or medium without express written permission of EarthWeb is prohibited.