[Debugging Toolbox]Connections from Pool

https://blogs.msdn.com/debuggingtoolbox/archive/2007/03/31/windbg-script-connections-from-pool.aspx

글 : Roberto Alexis Farah
번역 : 이태화

만약 여러분이 저와 같다면 특정 정보를 찾으려 할때 calss 나 namespace 를 잊어 버리곤할 것입니다. 아니면 찾고자 하는 field 이름을 잊기도 할 것입니다.

예를 들면 저는 System.Data.SqlClient namespace 에서 정보를 얻고자 할때 이런일이 발생하였습니다.

이 script 는 connection 으로 부터 몇가지 정보를 얻고자 하는 것입니다.

여러분이 비슷한 다른 namespace 와 field 에 대해서 비슷한 시도를 해서 확장을 하기 쉽습니다.

DML ( Debug Markup Language ) 을 base 로 시도할 것을 개인적으로 추천합니다. 왜냐하면 저는 hyperlink 들과 기본 script 호출 ($$><)을 사용합니다. DML 을 사용하는 것은 좀더 많은 일을 할 수 있으며 좀더 low-level 의 프로그래밍을 해야 하긴 하지만 좀더 나은 결과를 얻을 수 있습니다.

여러분이 이것을 실행시킬 때 $$< 가아닌 $$>< 을 사용해야 합니다.

 

참고
이번 코드는 정확히 이해가 안되는 군요 좀더 분석해 보고 찾아야 겠습니다. 동작을 요약해 보면 sos 관련 정보에서 결과를 얻은 후 _fINPool 이라는 문자열을 찾습니다.

.shell (Command Shell)
Shell 명령을 수행하여 결과를 dubugger 에 보여주거나 특정 파일에 저장합니다.
-ci "Commands"
  특정 debugger command 실행하고 결과를 실행되는 process 의 input file 로 전달한다.
.foreach
debugger command 의 결과를 분석하여 다른 command 의 입력으로 사용한다.
obj
아직 정확한 의미가 파악 안됩니다. 아마도 중괄호 안의 내용을 Obj 로 취급하라는 것 같습니다.
!do

FIND
파일에서 문자열을 찾습니다.
.shell -i - -ci ".foreach ( obj {
        !clr10\\sos.dumpheap -type System.Data.SqlClient.SqlInternalConnection -short
        } \
       )
       {!do ${obj} }"
    FIND  "_fInPool"

Source code for CONNECTIONS_POOL.TXT:

$$
$$ =============================================================================
$$ Verify Connections from Pool.
$$
$$ Compatilibity: Win32, should work on Win64.
$$
$$ Attention! For .Net Framework 2.0, edit the script and remove the clr10\\ from it so it can use the
$$ sos.dll version 2.0
$$
$$ Usage: $$< to run the script. (note: Just $$< not $$><)
$$
$$ Requirements: Public symbols.
$$
$$ Roberto Alexis Farah
$$ Blog: https://blogs.msdn.com/debuggingtoolbox/
$$ All my scripts are provided "AS IS" with no warranties, and confer no rights.
$$ =============================================================================
$$
.shell -i - -ci ".foreach ( obj {!clr10\\sos.dumpheap -type System.Data.SqlClient.SqlInternalConnection -short} ) {!do ${obj} }" FIND  "_fInPool"
.shell -i - -ci ".foreach ( obj {!clr10\\sos.dumpheap -type System.Data.SqlClient.SqlConnectionPoolControl -short} ) {!do ${obj} }" FIND  "_fResetConnection"
.shell -i - -ci ".foreach ( obj {!clr10\\sos.dumpheap -type System.Data.SqlClient.SqlConnectionPoolControl -short} ) {!do ${obj} }" FIND  "_maxPool"
$$
$$ Number of Connection Objects
$$ ============================
$$
!clr10\\sos.dumpheap -type System.Data.OleDb.OleDbConnection -stat
$$
$$ ===================================================================