mono / sdb

A command line client for the Mono soft debugger.
https://www.mono-project.com
MIT License
117 stars 44 forks source link

Instruction stepping steps multiple instructions #56

Closed saagarjha closed 5 years ago

saagarjha commented 5 years ago

I'm not sure if this is a bug in this project or this one, but instruction single stepping (using step into instruction or step over instruction) works unreliably for me. Often, it will skip over multiple instructions instead. For example, here SDB skips an entire call to System.Type:GetTypeFromHandle and instead jumps into System.Reflection.Assembly.GetAssembly:

Inferior process '14779' ('CampRE.dll') started
Hit method breakpoint on 'CampRE.Program.Main'
#0 [0x00000000] CampRE.Program.Main (no source)
    nop
(sdb) disassemble
0x00000000    nop
0x00000001    ldtoken CampRE.Program
0x00000006    call Type System.Type:GetTypeFromHandle (RuntimeTypeHandle)
0x0000000B    call Assembly System.Reflection.Assembly:GetAssembly (Type)
0x00000010    callvirt String System.Reflection.Assembly:get_Location ()
0x00000015    call Byte[] System.IO.File:ReadAllBytes (String)
0x0000001A    stloc.0
0x0000001B    ldc.i4.0
0x0000001C    stloc.1
0x0000001D    br 0000013c
0x00000022    nop
0x00000023    call MD5 System.Security.Cryptography.MD5:Create ()
0x00000028    stloc.2
0x00000029    call Encoding System.Text.Encoding:get_ASCII ()
0x0000002E    ldstr "i="
0x00000033    ldloca.s 1
0x00000035    call String System.Int32:ToString ()
0x0000003A    call String System.String:Concat (String, String)
0x0000003F    callvirt Byte[] System.Text.Encoding:GetBytes (String)
0x00000044    stloc.3
(sdb) step into instruction
Inferior process '14779' ('CampRE.dll') resumed
Inferior process '14779' ('CampRE.dll') suspended
#0 [0x00000001] CampRE.Program.Main (no source)
    ldtoken CampRE.Program
(sdb) step into instruction
Inferior process '14779' ('CampRE.dll') resumed
Inferior process '14779' ('CampRE.dll') suspended
#0 [0x00000000] System.Reflection.Assembly.GetAssembly at /Users/builder/jenkins/workspace/build-package-osx-mono/2019-02/external/bockbuild/builds/mono-x64/mcs/class/corlib/System.Reflection/Assembly.cs:462 (no source)
    ldarg.0
(sdb) backtrace
#0 [0x00000000] System.Reflection.Assembly.GetAssembly at /Users/builder/jenkins/workspace/build-package-osx-mono/2019-02/external/bockbuild/builds/mono-x64/mcs/class/corlib/System.Reflection/Assembly.cs:462 (no source)
    ldarg.0
#1 [0x0000000B] CampRE.Program.Main (no source)
    call Assembly System.Reflection.Assembly:GetAssembly (Type)

Am I doing something wrong here, or is there any reason SDB might be behaving this way? The number of instructions it skips seems to be a random number (especially if the next instruction is a call or callvirt) as well so I'm not sure what's going on.

alexrp commented 5 years ago

Seems like a bug in the Mono runtime.

saagarjha commented 5 years ago

Do you have any ideas on where I should report this and how I can gather additional information to make this easier to diagnose?

alexrp commented 5 years ago

Bugs in the soft debugger itself (the thing in the Mono runtime) should be reported on: https://github.com/mono/mono

You would probably need to provide a self-contained repro of the problem.

alexrp commented 5 years ago

Since this was closed as "won't fix" in the runtime, I'll close this.