Windbg查看堆栈内容

时间:2019-07-13 11:30:50

标签: c# windbg

试图查看应该在堆栈上的变量,但似乎我缺少了一些东西。

Program.cs

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:minHeight="?attr/actionBarSize"
    android:orientation="horizontal"
    xmlns:android="http://schemas.android.com/apk/res/android">

    <ImageView
        android:layout_width="50dp"
        android:layout_height="50dp"
        android:layout_marginLeft="15dp"
        android:layout_marginRight="15dp"
        android:layout_marginTop="10dp"
        android:src="@drawable/connected_icon_png" />

    <View
        android:layout_width="10dp"
        android:layout_height="0dp" />

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical"
            android:paddingBottom="10dp"
            android:paddingTop="10dp">

            <TextView
                android:id="@+id/name"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginEnd="10dp"
                android:layout_marginRight="10dp"
                android:text="Title Label"/>

            <TextView
                android:id="@+id/description"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginEnd="10dp"
                android:layout_marginRight="10dp"
                android:layout_marginTop="10dp"
                android:maxLines="2"
                android:text="Content that you want" />

        </LinearLayout>

        <View
            android:layout_width="match_parent"
            android:layout_height="1dp"/>

    </LinearLayout>

</LinearLayout> 
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace OnlyMain
{
    class Program
    {
        static void Main(string[] args)
        {
            int i = 0;
            i = 2;
            Console.WriteLine(i);
        }
    }
}
0:000> .load C:\Users\Anton\Downloads\sosex_64\sosex.dll

0:000> !mbp Program.cs 15
The CLR has not yet been initialized in the process.
Breakpoint resolution will be attempted when the CLR is initialized.
0:000> g
ModLoad: 00007ffd`ef9e0000 00007ffd`efa81000   C:\Windows\System32\ADVAPI32.dll
ModLoad: 00007ffd`ed830000 00007ffd`ed8cd000   C:\Windows\System32\msvcrt.dll
ModLoad: 00007ffd`f0020000 00007ffd`f0079000   C:\Windows\System32\sechost.dll
ModLoad: 00007ffd`ed990000 00007ffd`edab5000   C:\Windows\System32\RPCRT4.dll
ModLoad: 00007ffd`e5800000 00007ffd`e589c000   C:\Windows\Microsoft.NET\Framework64\v4.0.30319\mscoreei.dll
ModLoad: 00007ffd`f0080000 00007ffd`f00d1000   C:\Windows\System32\SHLWAPI.dll
ModLoad: 00007ffd`ef6b0000 00007ffd`ef9a9000   C:\Windows\System32\combase.dll
ModLoad: 00007ffd`ed500000 00007ffd`ed5f6000   C:\Windows\System32\ucrtbase.dll
ModLoad: 00007ffd`ed010000 00007ffd`ed07a000   C:\Windows\System32\bcryptPrimitives.dll
ModLoad: 00007ffd`ef9b0000 00007ffd`ef9d7000   C:\Windows\System32\GDI32.dll
ModLoad: 00007ffd`ed370000 00007ffd`ed4f8000   C:\Windows\System32\gdi32full.dll
ModLoad: 00007ffd`ed2d0000 00007ffd`ed36a000   C:\Windows\System32\msvcp_win.dll
ModLoad: 00007ffd`efed0000 00007ffd`f001a000   C:\Windows\System32\USER32.dll
ModLoad: 00007ffd`ec6d0000 00007ffd`ec6ee000   C:\Windows\System32\win32u.dll
ModLoad: 00007ffd`ed760000 00007ffd`ed78d000   C:\Windows\System32\IMM32.DLL
ModLoad: 00007ffd`ec610000 00007ffd`ec621000   C:\Windows\System32\kernel.appcore.dll
ModLoad: 00007ffd`e7990000 00007ffd`e799a000   C:\Windows\SYSTEM32\VERSION.dll
ModLoad: 00007ffd`c8680000 00007ffd`c906c000   C:\Windows\Microsoft.NET\Framework64\v4.0.30319\clr.dll
ModLoad: 00007ffd`e5700000 00007ffd`e57f7000   C:\Windows\SYSTEM32\MSVCR120_CLR0400.dll
(218c.2bf4): Unknown exception - code 04242420 (first chance)
ModLoad: 00007ffd`edaf0000 00007ffd`edaf8000   C:\Windows\System32\psapi.dll
ModLoad: 00007ffd`acc10000 00007ffd`ae198000   C:\Windows\assembly\NativeImages_v4.0.30319_64\mscorlib\b308b9c61f65cf2dfd876031ee385ba4\mscorlib.ni.dll
*** WARNING: Unable to verify checksum for C:\Windows\assembly\NativeImages_v4.0.30319_64\mscorlib\b308b9c61f65cf2dfd876031ee385ba4\mscorlib.ni.dll
ModLoad: 00007ffd`ef370000 00007ffd`ef4b5000   C:\Windows\System32\ole32.dll
*** WARNING: Unable to verify checksum for OnlyMain.exe
ModLoad: 00007ffd`cbc40000 00007ffd`cbd6c000   C:\Windows\Microsoft.NET\Framework64\v4.0.30319\clrjit.dll
Breakpoint: JIT notification received for method OnlyMain.Program.Main(System.String[]) in AppDomain 000002590c97a790.
Breakpoint set at OnlyMain.Program.Main(System.String[]) in AppDomain 000002590c97a790.
Breakpoint 1 hit
00007ffd`690704ae 8b4dfc          mov     ecx,dword ptr [rbp-4] ss:00000090`54ffebac=00000002
0:000> !ClrStack -a
OS Thread Id: 0x2bf4 (0)
        Child SP               IP Call Site
0000009054ffeb80 00007ffd690704ae OnlyMain.Program.Main(System.String[]) [C:\Users\Anton\source\repos\OnlyMain\OnlyMain\Program.cs @ 15]
    PARAMETERS:
        args (0x0000009054ffebc0) = 0x000002590e3e2d40
    LOCALS:
        0x0000009054ffebac = 0x0000000000000002

0000009054ffedf0 00007ffdc8686bb3 [GCFrame: 0000009054ffedf0] 
0:000> !DumpObj /d 0000000000000002

如何查看变量<Note: this object has an invalid CLASS field> Invalid object 的值以及它的位置?

1 个答案:

答案 0 :(得分:1)

我认为您错过了输出的这一部分

LOCALS:
    0x0000009054ffebac = 0x0000000000000002

表示某个地址处有一个局部变量,其值为2。与

不同
PARAMETERS:
    args (0x0000009054ffebc0) = 0x000002590e3e2d40

您看不到局部变量的名称i

请注意,Stack in C# is implementation specific。可能会发生该变量不在堆栈(如C ++中的堆栈)上,但可能在CPU寄存器中。