// 1 - 这命令是再加载了mscorwks后WinDBG会断下来,这样就有机会加载SOS。
sxe ld:mscorwks
// 2 - 看是否加载了mscorwks,如果没有加载就使用按照上面方式做
lmm mscorwks
// 3 - 使用这个命令自己指定和.NET匹配的SOS
.load C:\Windows\Microsoft.NET\Framework\v2.0.50727\sos.dll
// 4 - 使用这个命令根据已加载的mscorwks来确定并加载SOS
.loadby sos mscorwks
// 5 - 查看加载的SOS. lists all loaded debugger extensions in their default search order
.chain
// 6 - 如果sos加载成功, 那么!help可以查看sos扩展的命令
!help
// !Name2EE 显示指定模块中指定类型或方法的 MethodTable 结构和 EEClass 结构。
// 7 - 使用!Name2EE *!ModuleName.Type来查看已经Module Address
例如: !Name2EE *!CQ2BCFAPInterface.Program
Module: 002b2c5c (CQ2BCFAPInterface.exe) // Module Address得到
Token: 0x02000016
MethodTable: 002b30c8
EEClass: 002b1d44
Name: CQ2BCFAPInterface.Program
// 8 - 使用!DumpModule
// 显示有关指定地址处的模块的信息。 -mt 选项显示模块中定义的类型和模块所引用的类型
!DumpModule -mt 002b2c5c
Name: E:\FordESB\CQ2BCFAPInterface\CQ2BCFAPInterface\bin\Debug\CQ2BCFAPInterface.exe
Attributes: PEFile
Assembly: 00475440
LoaderHeap: 00000000
TypeDefToMethodTableMap: 002b0038
TypeRefToMethodTableMap: 002b009c
MethodDefToDescMap: 002b0248
FieldDefToDescMap: 002b05d8
MemberRefToDescMap: 002b0724
FileReferencesMap: 002b09e4
AssemblyReferencesMap: 002b09e8
MetaData start address: 00334d78 (23992 bytes)
Types defined in this module
MT TypeDef Name
------------------------------------------------------------------------------
00698618 0x02000002 GateReleaseNote.noteUtil
002b8f84 0x02000004 CQ2BCFAPInterface.Cq2BCFAPInterface1 // 此处mt地址对我们有用
00698c08 0x02000005 BCFAPInterface.Properties.Settings
009e16d8 0x02000008 BCFAPInterface.WebReference.fordesb
009e4720 0x02000009 BCFAPInterface.WebReference.putmsgCompletedEventHandler
009e4804 0x0200000a BCFAPInterface.WebReference.getmsgCompletedEventHandler
009e20d8 0x0200000d CQ2BCFAPInterface.WebReference1.SupplierEcho2
009e24f8 0x0200000f CQ2BCFAPInterface.WebReference1.fileInfo2
002b30c8 0x02000016 CQ2BCFAPInterface.Program
03c5670c 0x02000017 BCFAPInterface.NotPutFileData
009e1828 0x02000018 BCFAPInterface.NotPutFileDataIO
Types referenced in this module
MT TypeRef Name
------------------------------------------------------------------------------
67c40704 0x01000001 System.Object
002b8a50 0x01000002 System.ServiceProcess.ServiceBase
00698aa4 0x01000003 System.Configuration.ApplicationSettingsBase
009e1480 0x01000005 System.Web.Services.Protocols.SoapHttpClientProtocol
67c41008 0x01000006 System.MulticastDelegate
002b90e4 0x01000008 System.ComponentModel.IContainer
// 然后使用!dumpmt -md
!dumpmt -md 002b8f84
EEClass: 0067a450
Module: 002b2c5c
Name: CQ2BCFAPInterface.Cq2BCFAPInterface1
mdToken: 02000004 (E:\FordESB\CQ2BCFAPInterface\CQ2BCFAPInterface\bin\Debug\CQ2BCFAPInterface.exe)
BaseSize: 0x78
ComponentSize: 0x0
Number of IFaces in IFaceMap: 2
Slots in VTable: 35
--------------------------------------
MethodDesc Table
Entry MethodDesc JIT Name
002bc091 002b85e0 NONE System.ComponentModel.Component.ToString()
67b96ab0 67a14944 PreJIT System.Object.Equals(System.Object)
67b96b20 67a14974 PreJIT System.Object.GetHashCode()
002bc05d 002b8568 JIT System.ComponentModel.Component.Finalize()
6809dcb0 67a1d510 PreJIT System.MarshalByRefObject.GetLifetimeService()
67b79190 67a1d518 PreJIT System.MarshalByRefObject.InitializeLifetimeService()
67baa680 67a1d520 PreJIT System.MarshalByRefObject.CreateObjRef(System.Type)
002bc061 002b8570 NONE System.ComponentModel.Component.get_CanRaiseEvents()
002bc069 002b8584 NONE System.ComponentModel.Component.add_Disposed(System.EventHandler)
002bc06d 002b858c NONE System.ComponentModel.Component.remove_Disposed(System.EventHandler)
002bc075 002b85a0 NONE System.ComponentModel.Component.get_Site()
002bc079 002b85a8 NONE System.ComponentModel.Component.set_Site(System.ComponentModel.ISite)
002bc07d 002b85b0 NONE System.ComponentModel.Component.Dispose()
002bc281 002b8ec4 NONE CQ2BCFAPInterface.Cq2BCFAPInterface1.Dispose(Boolean)
002bc089 002b85cc NONE System.ComponentModel.Component.GetService(System.Type)
0068d2a8 002b883c JIT System.ServiceProcess.ServiceBase.get_EventLog()
002bc105 002b8870 NONE System.ServiceProcess.ServiceBase.OnContinue()
002bc109 002b8878 NONE System.ServiceProcess.ServiceBase.OnPause()
002bc10d 002b8880 NONE System.ServiceProcess.ServiceBase.OnPowerEvent(System.ServiceProcess.PowerBroadcastStatus)
002bc111 002b8888 NONE System.ServiceProcess.ServiceBase.OnSessionChange(System.ServiceProcess.SessionChangeDescription)
002bc115 002b8890 NONE System.ServiceProcess.ServiceBase.OnShutdown()
00685328 002b8f2c JIT CQ2BCFAPInterface.Cq2BCFAPInterface1.OnStart(System.String[])
002bc2ad 002b8f40 NONE CQ2BCFAPInterface.Cq2BCFAPInterface1.OnStop()
002bc14d 002b88fc NONE System.ServiceProcess.ServiceBase.OnCustomCommand(Int32)
002bc4f4 002b8ecc JIT CQ2BCFAPInterface.Cq2BCFAPInterface1.InitializeComponent()
002bc2cc 002b8ed8 JIT CQ2BCFAPInterface.Cq2BCFAPInterface1..ctor()
002be410 002b8ee4 NONE CQ2BCFAPInterface.Cq2BCFAPInterface1.WriteEventLogToWindows(System.String)
002be3c0 002b8ef0 JIT CQ2BCFAPInterface.Cq2BCFAPInterface1.InitDataFileDir()
009c06a0 002b8f08 NONE CQ2BCFAPInterface.Cq2BCFAPInterface1.DetermineProxy()
002be5d4 002b8f14 JIT CQ2BCFAPInterface.Cq2BCFAPInterface1.FindLastSeqNum(System.String)
002be3d0 002b8f20 JIT CQ2BCFAPInterface.Cq2BCFAPInterface1.InitLastSeqNum()
002bc2a9 002b8f34 NONE CQ2BCFAPInterface.Cq2BCFAPInterface1.FlushLastSeqNum()
002be38c 002b8f48 JIT CQ2BCFAPInterface.Cq2BCFAPInterface1.myTimer_Elapsed(System.Object, System.Timers.ElapsedEventArgs)
002bc2b5 002b8f54 NONE CQ2BCFAPInterface.Cq2BCFAPInterface1.eventLog1_EntryWritten(System.Object, System.Diagnostics.EntryWrittenEventArgs)
002bc295 002b8efc NONE CQ2BCFAPInterface.Cq2BCFAPInterface1.GetSeqFromFileName(System.String)
// 这里, JIT表示已经经过just in time编译器编译后的本地代码地址, 可以直接在Entry对应的地址上下断点.
如果用bp, 就用Entry对应的地址, 如果用!bpmd -md 可以直接在后面的符号上下断点
bp 002be38c
// 断点断下来后, 用
!dso查看堆栈上, 所有的对象
0:005> !dso
OS Thread Id: 0x16f0 (5)
ESP/REG Object Name
ebx 00e09e44 System.Threading.ContextCallback
ecx 00dd2be0 CQ2BCFAPInterface.Cq2BCFAPInterface1
edx 00dd2cc0 System.Timers.Timer
esi 00dd2be0 CQ2BCFAPInterface.Cq2BCFAPInterface1
037ff698 00e07e1c System.CurrentSystemTimeZone
037ff6d0 00e09e44 System.Threading.ContextCallback
037ff6d4 00e07e1c System.CurrentSystemTimeZone
037ff6e4 00e07f18 System.Globalization.DaylightTime
037ff74c 00ea0218 System.Collections.ArrayList
037ff750 00ea0080 System.Collections.ArrayList
037ff754 00e9d5a4 BCFAPInterface.NotPutFileDataIO
037ff760 00e953f0 BCFAPInterface.WebReference.fordesb
037ff770 00e9d5a4 BCFAPInterface.NotPutFileDataIO
037ff77c 00dd1198 System.String
037ff780 00ea0080 System.Collections.ArrayList
037ff784 00dd2be0 CQ2BCFAPInterface.Cq2BCFAPInterface1
037ff824 00dd2cc0 System.Timers.Timer
037ff840 00e09e44 System.Threading.ContextCallback
037ff844 00dd2cc0 System.Timers.Timer
037ff848 00ea4608 System.Timers.ElapsedEventArgs
037ff854 00ea4608 System.Timers.ElapsedEventArgs
037ff85c 00e095fc System.Timers.ElapsedEventHandler
037ff87c 00e09e44 System.Threading.ContextCallback
037ff880 00ea4564 System.Threading._TimerCallback
037ff884 00e31edc System.Threading.ExecutionContext
037ff890 00ea45c0 System.Threading.ExecutionContext
037ff89c 00ea45c0 System.Threading.ExecutionContext
037ff8a0 00ea4564 System.Threading._TimerCallback
037ff8ac 00ea4564 System.Threading._TimerCallback
037ffa58 00ea4564 System.Threading._TimerCallback
037ffa5c 00ea4564 System.Threading._TimerCallback
然后用!do查看对象的 有关指定地址处的对象的信息
!do 00dd2be0
!do 00dd2be0
Name: CQ2BCFAPInterface.Cq2BCFAPInterface1
MethodTable: 002b8f84
EEClass: 0067a450
Size: 120(0x78) bytes
(E:\FordESB\CQ2BCFAPInterface\CQ2BCFAPInterface\bin\Debug\CQ2BCFAPInterface.exe)
Fields:
MT Field Offset Type VT Attr Value Name
67c40704 400018a 4 System.Object 0 instance 00000000 __identity
0069e7b0 40008cc 8 ...ponentModel.ISite 0 instance 00000000 site
03c54f10 40008cd c ....EventHandlerList 0 instance 00000000 events
67c40704 40008cb 108 System.Object 0 static 00dd2cf8 EventDisposed
002b89f4 40001cc 3c ...ds+SERVICE_STATUS 1 instance 00dd2c1c status
67c433b0 40001cd 28 System.IntPtr 1 instance 4de358 statusHandle
006982f0 40001ce 10 ...ceControlCallback 0 instance 00dfd9b8 commandCallback
006983d4 40001cf 14 ...ControlCallbackEx 0 instance 00dfd9d8 commandCallbackEx
0069820c 40001d0 18 ...rviceMainCallback 0 instance 00dfd998 mainCallback
67c433b0 40001d1 2c System.IntPtr 1 instance 4884e8 handleName
67c27914 40001d2 1c ....ManualResetEvent 0 instance 00dfda58 startCompletedSignal
67c42d34 40001d3 30 System.Int32 1 instance 1 acceptedCommands
67c145b4 40001d4 34 System.Boolean 1 instance 1 autoLog
67c40ae8 40001d5 20 System.String 0 instance 00dfd6a8 serviceName
00697638 40001d6 24 ...gnostics.EventLog 0 instance 00e09be0 eventLog
67c145b4 40001d7 35 System.Boolean 1 instance 1 nameFrozen
67c145b4 40001d8 36 System.Boolean 1 instance 1 commandPropsFrozen
67c145b4 40001d9 37 System.Boolean 1 instance 0 disposed
67c145b4 40001da 38 System.Boolean 1 instance 1 initialized
67c145b4 40001db 39 System.Boolean 1 instance 0 isServiceHosted
002b90e4 4000009 58 ...tModel.IContainer 0 instance 00000000 components
00697638 400000a 5c ...gnostics.EventLog 0 instance 00dfd6e0 eventLog_ToWindows
002b9390 400000b 60 System.Timers.Timer 0 instance 00dd2cc0 myTimer
67c40ae8 400000c 64 System.String 0 instance 00dfc854 baseDataPath
67c40ae8 400000d 68 System.String 0 instance 00dfc5ac baseNotePath
67c40ae8 400000e 6c System.String 0 instance 00dfcaf0 _putFileName
67c18718 400000f 70 System.UInt32 1 instance 1000000000 _lastSeqNumber
还可以用!clrstack查看此时的managed code的堆栈
0:005> !CLRStack
OS Thread Id: 0x16f0 (5)
ESP EIP
037ff698 0068ea9b CQ2BCFAPInterface.Cq2BCFAPInterface1.myTimer_Elapsed(System.Object, System.Timers.ElapsedEventArgs)
037ff858 0068e948 System.Timers.Timer.MyTimerCallback(System.Object)
037ff890 67bb83ff System.Threading._TimerCallback.TimerCallback_Context(System.Object)
037ff898 67bf027f System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object)
037ff8b0 67bb836b System.Threading._TimerCallback.PerformTimerCallback(System.Object)
037ffa3c 69821b4c [GCFrame: 037ffa3c]
!dumpstack查看native和managed的堆栈
0:005> !dumpstack
OS Thread Id: 0x16f0 (5)
Current frame: (MethodDesc 0x2b8f48 +0x3b CQ2BCFAPInterface.Cq2BCFAPInterface1.myTimer_Elapsed(System.Object, System.Timers.ElapsedEventArgs))
ChildEBP RetAddr Caller,Callee
037ff6dc 67b99a59 (MethodDesc 0x67ab17bc +0x49 System.CurrentSystemTimeZone.GetUtcOffsetFromUniversalTime(System.DateTime, Boolean ByRef))
037ff6f4 698248ab mscorwks!operator delete[]+0x3b, calling mscorwks!_EH_epilog3
037ff6f8 69840752 mscorwks!BaseWrapper<PEDecoder *,FunctionBase<PEDecoder *,&DoNothing<PEDecoder *>,&Delete<PEDecoder>,2>,0,&CompareDefault<PEDecoder *>,2>::~BaseWrapper<PEDecoder *,FunctionBase<PEDecoder *,&DoNothing<PEDecoder *>,&Delete<PEDecoder>,2>,0,&CompareDefault<PEDecoder *>,2>+0x22, calling mscorwks!operator delete[]
037ff6fc 698354a1 mscorwks!BaseWrapper<PEDecoder *,FunctionBase<PEDecoder *,&DoNothing<PEDecoder *>,&Delete<PEDecoder>,2>,0,&CompareDefault<PEDecoder *>,2>::~BaseWrapper<PEDecoder *,FunctionBase<PEDecoder *,&DoNothing<PEDecoder *>,&Delete<PEDecoder>,2>,0,&CompareDefault<PEDecoder *>,2>+0x2c, calling mscorwks!_EH_epilog3
037ff724 69840dd3 mscorwks!MethodDesc::GetTemporaryEntryPoint+0x46, calling mscorwks!MethodDesc::GetMethodDescFromStubAddr
037ff740 698308a9 mscorwks!MethodDesc::DoBackpatch+0xb1, calling mscorwks!MethodTable::GetSlot
037ff744 698308bc mscorwks!MethodDesc::DoBackpatch+0xea, calling mscorwks!MethodDesc::IsMethodImpl
037ff84c 0068e948 (MethodDesc 0x2b933c +0xd8 System.Timers.Timer.MyTimerCallback(System.Object))
037ff888 67bb83ff (MethodDesc 0x67aa341c +0x2f System.Threading._TimerCallback.TimerCallback_Context(System.Object))
037ff890 67bf027f (MethodDesc 0x67a12784 +0x6f System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object))
037ff8a4 67bb836b (MethodDesc 0x67a0b4f0 +0x6b System.Threading._TimerCallback.PerformTimerCallback(System.Object)), calling (MethodDesc 0x67a12784 +0 System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object))
037ff8bc 69821b4c mscorwks!CallDescrWorker+0x33
037ff8cc 698396b6 mscorwks!CallDescrWorkerWithHandler+0xa3, calling mscorwks!CallDescrWorker
037ff934 69824438 mscorwks!CrstBase::Leave+0xab, calling mscorwks!_EH_epilog3
037ff94c 69839eb3 mscorwks!DispatchCallBody+0x1e, calling mscorwks!CallDescrWorkerWithHandler
037ff96c 69839ef4 mscorwks!DispatchCallDebuggerWrapper+0x3d, calling mscorwks!DispatchCallBody
037ff9d0 69839f61 mscorwks!DispatchCallNoEH+0x51, calling mscorwks!DispatchCallDebuggerWrapper
037ffa04 698645e9 mscorwks!AddTimerCallback_Worker+0x66, calling mscorwks!DispatchCallNoEH
037ffa60 6984cbff mscorwks!Thread::DoADCallBack+0x32a
037ffa74 6984cb9b mscorwks!Thread::ShouldChangeAbortToUnload+0xe3, calling mscorwks!Thread::DoADCallBack+0x2db
037ffaa8 69928510 mscorwks!QueueUserWorkItemManagedCallback+0x61, calling mscorwks!GCFrame::Pop
037ffab8 698223e8 mscorwks!GCHolder<1,0,1>::GCHolder<1,0,1>+0xc, calling (JitHelp: CORINFO_HELP_GET_THREAD)
037ffad0 75ed17c4 KERNELBASE!WaitForSingleObjectEx+0xcb, calling KERNELBASE!_SEH_epilog4
037ffb08 6984cac1 mscorwks!Thread::ShouldChangeAbortToUnload+0x30a, calling mscorwks!Thread::ShouldChangeAbortToUnload+0x32
037ffb44 6984cc4d mscorwks!Thread::ShouldChangeAbortToUnload+0x33e, calling mscorwks!Thread::ShouldChangeAbortToUnload+0x29d
037ffb6c 69863f78 mscorwks!ManagedThreadBase::ThreadPool+0x13, calling mscorwks!Thread::ShouldChangeAbortToUnload+0x319
037ffb84 69864569 mscorwks!AddTimerCallbackEx+0x83, calling mscorwks!ManagedThreadBase::ThreadPool
037ffbcc 69864598 mscorwks!AddTimerCallback+0x10, calling mscorwks!AddTimerCallbackEx
037ffbe0 6986463e mscorwks!ThreadpoolMgr::AsyncTimerCallbackCompletion+0x64
037ffc1c 69864300 mscorwks!UnManagedPerAppDomainTPCount::DispatchWorkItem+0x9a
037ffc68 69863c12 mscorwks!ThreadpoolMgr::ExecuteWorkRequest+0xaf
037ffc74 7682ef16 KERNEL32!GetTickCountStub
037ffc7c 69863d86 mscorwks!ThreadpoolMgr::WorkerThreadStart+0x20b, calling mscorwks!ThreadpoolMgr::ExecuteWorkRequest
037ffcd4 69949c71 mscorwks!Thread::intermediateThreadProc+0x49
037ffde4 69949c5f mscorwks!Thread::intermediateThreadProc+0x37, calling mscorwks!_alloca_probe_16
037ffdf8 76831114 KERNEL32!BaseThreadInitThunk+0xe
037ffe04 77c9b429 ntdll!__RtlUserThreadStart+0x70
037ffe44 77c9b3fc ntdll!_RtlUserThreadStart+0x1b, calling ntdll!__RtlUserThreadStart
在某个managed code函数上下了断点后, 还可以查看他的IL汇编
0:005> !dumpil 002b8f48
ilAddr = 00333144
IL_0000: nop
IL_0001: ldarg.0
IL_0002: ldfld CQ2BCFAPInterface.Cq2BCFAPInterface1::myTimer
IL_0007: callvirt System.Timers.Timer::Stop
IL_000c: nop
IL_000d: ldstr "handler_enter+++++++++++++++++"
IL_0012: call GateReleaseNote.noteUtil::WriteNoteFile
IL_0017: nop
.try
{
IL_0018: nop
IL_0019: ldnull
IL_001a: stloc.0
IL_001b: ldstr ""
IL_0020: stloc.1
IL_0021: ldstr ""
IL_0026: stloc.2
.try
{
IL_0027: nop
IL_0028: newobj BCFAPInterface.WebReference.fordesb::.ctor
IL_002d: stloc.3
IL_002e: ldloc.3
IL_002f: ldstr "SupplierWeb"
IL_0034: callvirt BCFAPInterface.WebReference.fordesb::getmsg
IL_0039: stloc.2
IL_003a: ldloc.2
IL_003b: ldnull
IL_003c: ceq
IL_003e: ldc.i4.0
IL_003f: ceq
IL_0041: stloc.s VAR OR ARG 14
IL_0043: ldloc.s VAR OR ARG 14
IL_0045: brtrue.s IL_0056
IL_0047: nop
IL_0048: ldstr "fordesb_getmsg <succ>: vtrin is NULL"
IL_004d: call GateReleaseNote.noteUtil::WriteNoteFile
IL_0052: nop
IL_0053: nop
IL_0054: br.s IL_0069
IL_0056: nop
IL_0057: ldstr "fordesb_getmsg <succ>: vtrin={0}"
IL_005c: ldloc.2
IL_005d: call System.String::Format
IL_0062: call GateReleaseNote.noteUtil::WriteNoteFile
IL_0067: nop
IL_0068: nop
IL_0069: nop
IL_006a: leave.s IL_0089
} // end .try
.catch
{
IL_006c: stloc.s VAR OR ARG 4
IL_006e: nop
IL_006f: ldstr "fordesb_getmsg <expt>: msg={0}"
IL_0074: ldloc.s VAR OR ARG 4
IL_0076: callvirt System.Exception::get_Message
IL_007b: call System.String::Format
IL_0080: call GateReleaseNote.noteUtil::WriteNoteFile
IL_0085: nop
IL_0086: nop
IL_0087: leave.s IL_0089
} // end .catch
IL_0089: nop
.try
{
IL_008a: nop
IL_008b: ldloc.2
IL_008c: ldstr "null"
IL_0091: call System.String::op_Inequality
IL_0096: ldc.i4.0
IL_0097: ceq
IL_0099: stloc.s VAR OR ARG 14
IL_009b: ldloc.s VAR OR ARG 14
IL_009d: brtrue.s IL_00b9
IL_009f: nop
IL_00a0: ldloc.2
IL_00a1: call GateReleaseNote.noteUtil::WriteDataFile
IL_00a6: stloc.1
IL_00a7: ldstr "writedatafile <succ>: vtrin={0}"
IL_00ac: ldloc.2
IL_00ad: call System.String::Format
IL_00b2: call GateReleaseNote.noteUtil::WriteNoteFile
IL_00b7: nop
IL_00b8: nop
IL_00b9: nop
IL_00ba: leave.s IL_00d9
} // end .try
.catch
{
IL_00bc: stloc.s VAR OR ARG 4
IL_00be: nop
IL_00bf: ldstr "writedatafile <expt>: msg={0}"
IL_00c4: ldloc.s VAR OR ARG 4
IL_00c6: callvirt System.Exception::get_Message
IL_00cb: call System.String::Format
IL_00d0: call GateReleaseNote.noteUtil::WriteNoteFile
IL_00d5: nop
IL_00d6: nop
IL_00d7: leave.s IL_00d9
} // end .catch
IL_00d9: nop
IL_00da: ldarg.0
IL_00db: ldfld CQ2BCFAPInterface.Cq2BCFAPInterface1::_putFileName
IL_00e0: newobj BCFAPInterface.NotPutFileDataIO::.ctor
IL_00e5: stloc.s VAR OR ARG 5
IL_00e7: ldloc.s VAR OR ARG 5
IL_00e9: callvirt BCFAPInterface.NotPutFileDataIO::Load
IL_00ee: stloc.0
IL_00ef: ldloc.0
IL_00f0: ldnull
IL_00f1: ceq
IL_00f3: ldc.i4.0
IL_00f4: ceq
IL_00f6: stloc.s VAR OR ARG 14
IL_00f8: ldloc.s VAR OR ARG 14
IL_00fa: brtrue.s IL_0102
IL_00fc: newobj System.Collections.ArrayList::.ctor
IL_0101: stloc.0
IL_0102: ldloc.1
IL_0103: brfalse.s IL_0113
IL_0105: ldloc.1
IL_0106: callvirt System.String::get_Length
IL_010b: ldc.i4.0
IL_010c: cgt
IL_010e: ldc.i4.0
IL_010f: ceq
IL_0111: br.s IL_0114
IL_0113: ldc.i4.1
IL_0114: stloc.s VAR OR ARG 14
IL_0116: ldloc.s VAR OR ARG 14
IL_0118: brtrue.s IL_012d
IL_011a: nop
IL_011b: ldloc.0
IL_011c: ldloc.1
IL_011d: callvirt System.Collections.ArrayList::Add
IL_0122: pop
IL_0123: ldloc.s VAR OR ARG 5
IL_0125: ldloc.0
IL_0126: callvirt BCFAPInterface.NotPutFileDataIO::Save
IL_012b: nop
IL_012c: nop
IL_012d: newobj System.Collections.ArrayList::.ctor
IL_0132: stloc.s VAR OR ARG 6
IL_0134: ldc.i4.0
IL_0135: stloc.s VAR OR ARG 7
IL_0137: br IL_02f6
IL_013c: nop
.try
{
IL_013d: nop
IL_013e: ldloc.0
IL_013f: ldloc.s VAR OR ARG 7
IL_0141: callvirt System.Collections.ArrayList::get_Item
IL_0146: castclass System.String
IL_014b: call GateReleaseNote.noteUtil::ReadDataFile
IL_0150: stloc.s VAR OR ARG 8
IL_0152: ldloc.s VAR OR ARG 8
IL_0154: brfalse.s IL_0165
IL_0156: ldloc.s VAR OR ARG 8
IL_0158: callvirt System.String::get_Length
IL_015d: ldc.i4.0
IL_015e: cgt
IL_0160: ldc.i4.0
IL_0161: ceq
IL_0163: br.s IL_0166
IL_0165: ldc.i4.1
IL_0166: stloc.s VAR OR ARG 14
IL_0168: ldloc.s VAR OR ARG 14
IL_016a: brtrue IL_0290
IL_016f: nop
IL_0170: ldarg.0
IL_0171: call CQ2BCFAPInterface.Cq2BCFAPInterface1::DetermineProxy
IL_0176: stloc.s VAR OR ARG 9
IL_0178: ldloc.s VAR OR ARG 9
IL_017a: ldc.i4.s 83
IL_017c: newobj System.Net.WebProxy::.ctor
IL_0181: stloc.s VAR OR ARG 10
IL_0183: ldloc.s VAR OR ARG 10
IL_0185: newobj System.Net.NetworkCredential::.ctor
IL_018a: callvirt System.Net.IWebProxy::set_Credentials
IL_018f: nop
IL_0190: newobj CQ2BCFAPInterface.WebReference1.SupplierEcho2::.ctor
IL_0195: stloc.s VAR OR ARG 11
IL_0197: call BCFAPInterface.Properties.Settings::get_Default
IL_019c: callvirt BCFAPInterface.Properties.Settings::get_useProxy
IL_01a1: ldc.i4.0
IL_01a2: ceq
IL_01a4: stloc.s VAR OR ARG 14
IL_01a6: ldloc.s VAR OR ARG 14
IL_01a8: brtrue.s IL_01d8
IL_01aa: nop
IL_01ab: ldstr "proxy set begin....."
IL_01b0: call GateReleaseNote.noteUtil::WriteNoteFile
IL_01b5: nop
IL_01b6: ldloc.s VAR OR ARG 11
IL_01b8: ldloc.s VAR OR ARG 10
IL_01ba: callvirt System.Web.Services.Protocols.HttpWebClientProtoc::set_Proxy
IL_01bf: nop
IL_01c0: ldstr "proxy set end....."
IL_01c5: ldloc.s VAR OR ARG 11
IL_01c7: callvirt System.Web.Services.Protocols.HttpWebClientProtoc::get_Proxy
IL_01cc: call System.String::Concat
IL_01d1: call GateReleaseNote.noteUtil::WriteNoteFile
IL_01d6: nop
IL_01d7: nop
IL_01d8: ldloc.s VAR OR ARG 11
IL_01da: ldloc.s VAR OR ARG 10
IL_01dc: callvirt System.Web.Services.Protocols.HttpWebClientProtoc::set_Proxy
IL_01e1: nop
IL_01e2: ldstr "Settings.Default.useProxy == "
IL_01e7: call BCFAPInterface.Properties.Settings::get_Default
IL_01ec: callvirt BCFAPInterface.Properties.Settings::get_useProxy
IL_01f1: box System.Boolean
IL_01f6: call System.String::Concat
IL_01fb: call GateReleaseNote.noteUtil::WriteNoteFile
IL_0200: nop
IL_0201: ldstr "Settings.Default.useProxy == true ...."
IL_0206: call BCFAPInterface.Properties.Settings::get_Default
IL_020b: callvirt BCFAPInterface.Properties.Settings::get_useProxy
IL_0210: box System.Boolean
IL_0215: call System.String::Concat
IL_021a: call GateReleaseNote.noteUtil::WriteNoteFile
IL_021f: nop
IL_0220: ldstr "is_use_proxy={0}"
IL_0225: call BCFAPInterface.Properties.Settings::get_Default
IL_022a: callvirt BCFAPInterface.Properties.Settings::get_useProxy
IL_022f: stloc.s VAR OR ARG 15
IL_0231: ldloca.s VAR OR ARG 15
IL_0233: call System.Boolean::ToString
IL_0238: call System.String::Format
IL_023d: call GateReleaseNote.noteUtil::WriteNoteFile
IL_0242: nop
IL_0243: ldstr "webservice begin....."
IL_0248: call GateReleaseNote.noteUtil::WriteNoteFile
IL_024d: nop
IL_024e: ldloc.s VAR OR ARG 11
IL_0250: ldloc.s VAR OR ARG 8
IL_0252: ldstr ""
IL_0257: ldstr ""
IL_025c: callvirt CQ2BCFAPInterface.WebReference1.SupplierEcho2::getBasicInfo
IL_0261: stloc.s VAR OR ARG 12
IL_0263: ldstr "webservice end....."
IL_0268: call GateReleaseNote.noteUtil::WriteNoteFile
IL_026d: nop
IL_026e: ldstr "put_vtr <succ>: filename={0} content={1}"
IL_0273: ldloc.0
IL_0274: ldloc.s VAR OR ARG 7
IL_0276: callvirt System.Collections.ArrayList::get_Item
IL_027b: castclass System.String
IL_0280: ldloc.s VAR OR ARG 8
IL_0282: call System.String::Format
IL_0287: call GateReleaseNote.noteUtil::WriteNoteFile
IL_028c: nop
IL_028d: nop
IL_028e: br.s IL_02b1
IL_0290: nop
IL_0291: ldstr "put_vtr <fail>: filename={0} content={1}"
IL_0296: ldloc.0
IL_0297: ldloc.s VAR OR ARG 7
IL_0299: callvirt System.Collections.ArrayList::get_Item
IL_029e: castclass System.String
IL_02a3: ldloc.s VAR OR ARG 8
IL_02a5: call System.String::Format
IL_02aa: call GateReleaseNote.noteUtil::WriteNoteFile
IL_02af: nop
IL_02b0: nop
IL_02b1: nop
IL_02b2: leave.s IL_02ed
} // end .try
.catch
{
IL_02b4: stloc.s VAR OR ARG 4
IL_02b6: nop
IL_02b7: ldstr "put_vtrin <expt>: filename={0} expt={1}"
IL_02bc: ldloc.0
IL_02bd: ldloc.s VAR OR ARG 7
IL_02bf: callvirt System.Collections.ArrayList::get_Item
IL_02c4: castclass System.String
IL_02c9: ldloc.s VAR OR ARG 4
IL_02cb: callvirt System.Exception::get_Message
IL_02d0: call System.String::Format
IL_02d5: call GateReleaseNote.noteUtil::WriteNoteFile
IL_02da: nop
IL_02db: ldloc.s VAR OR ARG 6
IL_02dd: ldloc.0
IL_02de: ldloc.s VAR OR ARG 7
IL_02e0: callvirt System.Collections.ArrayList::get_Item
IL_02e5: callvirt System.Collections.ArrayList::Add
IL_02ea: pop
IL_02eb: leave.s IL_02ef
} // end .catch
IL_02ed: nop
IL_02ee: nop
IL_02ef: nop
IL_02f0: ldloc.s VAR OR ARG 7
IL_02f2: ldc.i4.1
IL_02f3: add
IL_02f4: stloc.s VAR OR ARG 7
IL_02f6: ldloc.s VAR OR ARG 7
IL_02f8: ldloc.0
IL_02f9: callvirt System.Collections.ArrayList::get_Count
IL_02fe: clt
IL_0300: stloc.s VAR OR ARG 14
IL_0302: ldloc.s VAR OR ARG 14
IL_0304: brtrue IL_013c
IL_0309: ldloc.s VAR OR ARG 5
IL_030b: ldloc.s VAR OR ARG 6
IL_030d: callvirt BCFAPInterface.NotPutFileDataIO::Save
IL_0312: nop
IL_0313: nop
IL_0314: leave.s IL_035d
} // end .try
.catch
{
IL_0316: stloc.s VAR OR ARG 4
IL_0318: nop
.try
{
IL_0319: nop
IL_031a: ldstr "unknown <fail>: "
IL_031f: ldloc.s VAR OR ARG 4
IL_0321: callvirt System.Exception::get_Message
IL_0326: call System.String::Concat
IL_032b: call GateReleaseNote.noteUtil::WriteNoteFile
IL_0330: nop
IL_0331: nop
IL_0332: leave.s IL_0359
} // end .try
.catch
{
IL_0334: stloc.s VAR OR ARG 13
IL_0336: nop
IL_0337: ldarg.0
IL_0338: ldstr "WriteNoteFile Error: "
IL_033d: ldloc.s VAR OR ARG 13
IL_033f: callvirt System.Exception::get_Message
IL_0344: ldloc.s VAR OR ARG 13
IL_0346: callvirt System.Exception::get_StackTrace
IL_034b: call System.String::Concat
IL_0350: call CQ2BCFAPInterface.Cq2BCFAPInterface1::WriteEventLogToWindows
IL_0355: nop
IL_0356: nop
IL_0357: leave.s IL_0359
} // end .catch
IL_0359: nop
IL_035a: nop
IL_035b: leave.s IL_035d
} // end .catch
IL_035d: nop
IL_035e: ldarg.0
IL_035f: ldfld CQ2BCFAPInterface.Cq2BCFAPInterface1::myTimer
IL_0364: callvirt System.Timers.Timer::Start
IL_0369: nop
IL_036a: ret
/// 这个命令比较好用, 得到当前运行地址的method desc地址
!IP2MD eip
然后, 可以用!dumpmd methoddesc_addr查看一些东西
要注意查看程序抛出的异常类型, 然后, 当异常发生时, 直接断下来, 命令
!soe -create system.Exception -1
表示当程序出现system.Exception后, 断下来, 此时用!dso查看对象, 然后用!do命令观察对象中的数据值
////////////////////////////////////////////////////
总的来说, 用Windbg来调试.net程序, 不怎么好用. 一点都不直观. 无法直观的观察到managed code的运行情况.
特别是变量的值. 异常等, 看得都不是很清楚. 可以这么说, 花费大力气, 却未必能得到讨好的结果;.