Monday, September 10, 2007

Visual Studio 2005 tips & tricks

Here are some tips and trick for Microsoft Visual Studio 2005 (mostly Visual C++ ones).

 

1. Open files in Visual Studio


You can open files from Windows Explorer (or Total Commander, or any similar application) in existing instance of MSVS by specifying shell command for file type:
"...\Microsoft Visual Studio 8\Common7\IDE\devenv.exe" /edit "%1"


 

2. How to Not Step Into Functions using the debugger (article)


Here is my configuration with comments:

Default configuration of MSVC8:

"Security check function"="__security_check_cookie"
"Rpcrt4.dll functions that hinder RPC StepInto"="_ObjectStublessClient.*"
"Rpcrt4.dll function that hinders RPC StepOut"="_Invoke@12"
"Run time check function"="_RTC_CheckEsp"


Don't step into TAO reference counted pointers:

"TAO_vars"="TAO_Objref_Var_T.*\\:\\:in=NoStepInto"
"TAO_seq_var"="TAO_Seq_Var_Base_T.*\\:\\:.*=NoStepInto"


Don't step into STL:

"std_string_c_str"="std\\:\\:basic_string.*\\:\\:.*=NoStepInto"
"std::list"="std\\:\\:list.*\\:\\:.*=NoStepInto"
"std::vector"="std\\:\\:vector.*\\:\\:.*=NoStepInto"
"std::map"="std\\:\\:map.*\\:\\:.*=NoStepInto"
"std::set"="std\\:\\:set.*\\:\\:.*=NoStepInto"


Don't step into boost::foreach and boost::shared_ptr (could be very usefull within code like
foreach(Object& obj, getObject())
'step-into' goes to getObject() instead of boost internals)

"boost_foreach"="boost\\:\\:foreach_detail_\\:\\:.*=NoStepInto"
"boost_shared_ptr"="boost\\:\\:shared_ptr.*\\:\\:.*=NoStepInto"

Don't step into 'dynamic_cast'

"RTDynamicCast"="__RTDynamicCast=NoStepInfo"
Here are my configuration: dbg.reg

 

3. Debugger Visualizers for Qt generic container types



;------------------------------------------------------------------------------
; QList,QQueue
;------------------------------------------------------------------------------
QList<*>|QQueue<*>{
children
(
#array
(
expr : *($T1*)(($c.d->array+$c.d->begin)[$i]),
size : $c.d->end-$c.d->begin
)
)

preview
(
#(
"[",
$e.d->end - $e.d->begin ,
"](",

#array
(
expr : *($T1*)(($c.d->array+$c.d->begin)[$i]),
size : $c.d->end-$c.d->begin
),
")"
)
)


}

;------------------------------------------------------------------------------
; QList::iterator, QQueue::iterator
;------------------------------------------------------------------------------
QList<*>::iterator|QList<*>::const_iterator|QQueue<*>::iterator|QQueue<*>::const_iterator {

preview
(
#(*($T1*)$e.i->v)
)

children
(
#(ptr: *($T1*)$e.i->v)
)

}

;------------------------------------------------------------------------------
; QListIterator
;------------------------------------------------------------------------------
QListIterator<*>|QMutableListIterator<*> {

preview
(
#(*($T1*)$e.i.i->v)
)

children
(
#(ptr: *($T1*)$e.i.i->v)
)

}


;------------------------------------------------------------------------------
; QVector::iterator, QStack::iterator
;------------------------------------------------------------------------------
QVector<*>::iterator|QVector<*>::const_iterator|QStack<*>::iterator|QStack<*>::const_iterator {

preview
(
#($e.i)
)

children
(
#(ptr: $e.i)
)

}

;------------------------------------------------------------------------------
; QVector, QStack
;------------------------------------------------------------------------------
QVector<*>|QStack<*>{
children
(
#array
(
expr : $c.d->array[$i],
size : $c.d->size
)
)

preview
(
#(
"[",
$e.d->size ,
"](",

#array
(
expr : $c.d->array[$i],
size : $c.d->size
),
")"
)
)


}

;------------------------------------------------------------------------------
; QLinkedList
;------------------------------------------------------------------------------
QLinkedList<*>{
children
(
#list
(
head : $c.d->n,
size : $c.d->size,
next : n
) : #( (*(QLinkedListNode<$T1>*)&$e).t )
)

preview
(
#(
"[",
$e.d->size ,
"](",
#list
(
head : $c.d->n,
size : $c.d->size,
next : n
) : ( (*(QLinkedListNode<$T1>*)&amp;amp;amp;$e).t ),
")"
)
)


}

;------------------------------------------------------------------------------
; QLinkedList::iterator
;------------------------------------------------------------------------------
QLinkedList<*>::iterator|QLinkedList<*>::const_iterator{
preview
(
#($e.i->t)
)

children
(
#(ptr: $e.i->t)
)

}

;------------------------------------------------------------------------------
; QMap::Node
;------------------------------------------------------------------------------
QMap<*,*>::Node{
preview
(
#(
"(",
$e.key,
"; ",
$e.value,
")"
)
)

children
(
#(
key: $e.key,
value: $e.value
)
)

}

;------------------------------------------------------------------------------
; QMap::iterator
;------------------------------------------------------------------------------
QMap<*>::iterator|QMap<*>::const_iterator{
preview
(
#(
(QMap<$T1>::Node*)((char*)$e.i - (sizeof(*(QMap<$T1>::PayloadNode*)0) - sizeof(QMapData::Node*)))
)
)

children
(
#(
node: (QMap<$T1>::Node*)((char*)$e.i - (sizeof(*(QMap<$T1>::PayloadNode*)0) - sizeof(QMapData::Node*)))
)
)

}

;------------------------------------------------------------------------------
; QMap
;------------------------------------------------------------------------------

QMap<*>{
children
(
#tree
(
head : $c.d->forward[0],
skip : $c.d,
size : $c.d->size,
left : backward,
right : forward
) : ( (QMap<$T1>::Node*)((char*)&$e - (sizeof(*(QMap<$T1>::PayloadNode*)0) - sizeof(QMapData::Node*))) )
)

preview
(
#(
"[",
$e.d->size,
"](",

#tree
(
head : $c.d->forward,
size : $c.d->size,
left : backward,
right : forward
) : $e,

")"
)
)
}


To use these visualizers they should be pasted into "c:\Program Files\Microsoft Visual Studio 8\Common7\Packages\Debugger\autoexp.dat"

Here are some articles about configuring visualizers for STLport: Garry's Brain Blog

These tips are written in short just not to forget.

Read More...

Denis Dzyubenko shadone