http://blogs.msdn.com/debuggingtoolbox/archive/2007/04/04/windbg-script-retrieving-queries-stored-procedures-from-net-application.aspx
글 : Roberto Alexis Farah 번역 : 이태화
.NET Application 을 디버깅 할때 .NET Application 으로부터 queries/stored procedure 들을 검색 하거나 합니다. 여러분은 database 를 접근하는 thread 로 부터 queries 와 stored processdure 들을 찾고자 합니다. 그러나 어떻게 하는지 알 지 못한다. 좋은 뉴스! 이것은 더이상 문제가 되지 않습니다.
이 스크립트는 여러분에게 SQLCommand 또는 OracleCommande Object 들과 연관되어 있는 모든 querie 또는 stored procesdure 들을 보여줄 것이다. 더욱이 여러분은 클릭만으로 더 많은 정보와 thread 이것을 사용하는 것을 볼 수 있을 것입니다. 만약 여러분이 저의 이전 post 의 마지막 script 와 비교를 한다면 여러분은 왜 제가 DML 을 사용하기를 추천했는지와 왜 여러분이 이전 시도에서 더 많은 일을 했는지 알게 될 것입니다.
These are the screenshots:
Source code for GET_SQLCOMMAND.TXT:
$$ $$ ============================================================================= $$ It shows the SQL commands from a .NET application. It gives you detailed information $$ and the threads using the query/stored procedure you selected. $$ It's useful for SQL Server and Oracle. $$ $$ Compatibility: Win32. $$ $$ Attention! For .NET Framework 1.1 add clr10\\ in every SOS call. $$ Like: !clr10\sos.DumpObj $$ $$ Usage: Use $$>< to run the program. $$ $$ Requirements: Public symbols. $$ $$ If necessary change the filename below to include your path and filename. $$ By default it uses the WinDbg path and the default file name is GET_SQLCOMMAND.TXT $$ $$ Roberto Alexis Farah $$ Blog: http://blogs.msdn.com/debuggingtoolbox/ $$ $$ All my scripts are provided "AS IS" with no warranties, and confer no rights. $$ ============================================================================= $$ ad /q * r @$t0 = 0 r @$t1 = 0 .printf /D "<b>\nClick on the queries/stored procedures below to get more details and to find out the threads using it.\n\n</b>" .block { .block { as ScriptName MYSCRIPTS\\GET_SQLCOMMAND.TXT } .block { as SQLCommand .block { !sos.DumpObj poi(@$t0+0x10) !sos.DumpObj @$t0 !sos.GCRoot @$t0 } } .block { as OracleCommand .block { !psscor.DumpObj poi(@$t0+0x14) !psscor.DumpObj @$t0 !psscor.GCRoot @$t0 } } } .foreach(obj {!sos.dumpheap -short -type System.Data.SqlClient.SqlCommand } ) { r @$t1 = 1 .printf /D "<link cmd=\"r @$t0 = ${obj}; ${SQLCommand} ;ad /q *; $$><${ScriptName}\"><b>%mu</b></link>\n\n", poi(${obj}+0x10)+0xc } .foreach(obj {!sos.dumpheap -short -type System.Data.OracleClient.OracleCommand } )
r @$t1 = 1 .printf /D "<link cmd=\"r @$t0 = ${obj}; ${OracleCommand} ;ad /q *; $$><${ScriptName}\"><b>% mu</b></link>\n\n", poi(${obj}+0x14)+0xc
.if(0 = @$t1) { .printf /D "<b>\nNo SQL commands found.\n</b>" }
Read me.