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...

Sunday, January 14, 2007

apt-cacher

Damn! Write a patch to a debian package apt-cacher only to find out that latest version from Etch already support the functionality I need. (g)

though publish the patch here (only to base app, not to the package itself), in case I (or anybody) will need it in Woody.



diff -u apt-cacher.orig/apt-cacher.pl apt-cacher/apt-cacher.pl
--- apt-cacher.orig/apt-cacher.pl 2005-07-30 17:03:00.000000000 +0400
+++ apt-cacher/apt-cacher.pl 2007-01-14 17:00:49.000000000 +0300
@@ -683,7 +683,8 @@

sub usage_error {
print STDERR "--- apt-cacher.pl:Usage error\n";
-
+ my $is_proxy_user = "no";
+ $is_proxy_user = "yes" if ($config{proxy_user});
print <<EOF;
Content-Type: text/html
Expires: 0
@@ -723,6 +724,7 @@
<tr bgcolor="cccccc"><td bgcolor="ccccff"> errorfile </td><td> $config{errorfile} </td></tr>
<tr bgcolor="cccccc"><td bgcolor="ccccff"> expire_hours </td><td> $config{expire_hours} </td></tr>
<tr bgcolor="cccccc"><td bgcolor="ccccff"> http_proxy </td><td> $config{http_proxy} </td></tr>
+<tr bgcolor="cccccc"><td bgcolor="ccccff"> proxy_user </td><td> $is_proxy_user </td></tr>
<tr bgcolor="cccccc"><td bgcolor="ccccff"> use_proxy </td><td> $config{use_proxy} </td></tr>
<tr bgcolor="cccccc"><td bgcolor="ccccff"> debug </td><td> $config{debug} </td></tr>
</table>
@@ -781,6 +783,9 @@
# Check whether a proxy is to be used, and set the appropriate environment variable
if ( $config{use_proxy} eq 1 && $config{http_proxy}) {
push(@elist, "-x", "http://$config{http_proxy}");
+ if ($config{proxy_user}) {
+ push(@elist, "-U", "$config{proxy_user}");
+ }
}
# Check if we need to set a rate limiting value: otherwise make it null
push(@elist,"--limit-rate", $config{limit}) if ($config{limit} > 0);



apt-cacher is a proxy for apt, that allows upgrading many debian boxes through one caching 'proxy'.

Read More...

Wednesday, January 10, 2007

Emacs learning curve

Comparison of text editors learning curves. True.

Read More...

Friday, January 05, 2007

fine-tuning Firefox

Feels like a secret knoledge: To be able closing a tab with a middle click, you should set middlemouse.ContentLoadURL to false in about:config. Seems it is need only in Linux-version of Firefox.

Read More...

Thursday, January 04, 2007

Google Reader update

wow, Google added new feature to the Google Reader - trends view - very nice statistics about reading feed - now I know I've read more that 4000 items for the last 30 days. what a waste of time of mine. (g)

The one I don't understand is how do they calculate percent of read items - trends tell me all my feed has 100% read items. Is 'read' mean 'viewed by user'? If so, thats not true, since when reading with google reader I scroll throw all items reading titles, and read full articles (summaries and descriptions) only when title concerns me.
I think there should be another trend like 'percent of viewed items' - 'viewed' like 'opened original source article'.

Read More...

Wednesday, January 03, 2007

Expandable posts

Added 'expandable post' feature described at hackosphere.

Though I am not sure if it is useful since it isn't the same as <lj-cut> and doesn't stop loading of all post contents. It just makes posts partially hidden.

(just not to forget how to make posts 'expandable': after blog template customization (done once) wrap text with tags <span id="fullpost"> and </span>)

Read More...

Denis Dzyubenko shadone