mono / sdb

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

How to use SDB? #28

Closed achobanov closed 9 years ago

achobanov commented 9 years ago

Could someone please explain how to use this debugger. I am failing very miserably and I am stuck on trying to put a breakpoint. I can't find any information at all. Thanks

esdrubal commented 9 years ago

You can use help <command> Try doing help breakpoint in sdb. Or help breakpoint add

alexrp commented 9 years ago

So you can place two kinds of breakpoints: Method breakpoints and location breakpoints. The former is great when you just want to break on method entry, e.g.:

$ cat test.cs
namespace MyApp {
        class Program {
                static void Main () {
                }
        }
}
$ mcs -debug test.cs
$ sdb
Welcome to the Mono soft debugger (sdb 1.5.5596.4936)
Type 'help' for a list of commands or 'quit' to exit

(sdb) bp add func MyApp.Program.Main
Breakpoint '0' added for method 'MyApp.Program.Main'
(sdb) r test.exe
Inferior process '30219' ('test.exe') started
Hit method breakpoint on 'MyApp.Program.Main'
#0 [0x00000000] MyApp.Program.Main at /home/alexrp/Projects/tests/test.cs:3
                static void Main () {
(sdb)

The latter kind of breakpoint is your more traditional kind, where you specify a file and line:

$ cat test.cs
using System;
namespace MyApp {
        class Program {
                static void Main () {
                        Console.WriteLine ("Foo");
                        Console.WriteLine ("Bar");
                }
        }
}
$ mcs -debug test.cs
$ sdb
Welcome to the Mono soft debugger (sdb 1.5.5596.4936)
Type 'help' for a list of commands or 'quit' to exit

(sdb) bp add at test.cs 6
Breakpoint '0' added at '/home/alexrp/Projects/tests/test.cs:6'
(sdb) r test.exe
Inferior process '30354' ('test.exe') started
Foo
Hit breakpoint at '/home/alexrp/Projects/tests/test.cs:6'
#0 [0x0000000B] MyApp.Program.Main at /home/alexrp/Projects/tests/test.cs:6
                        Console.WriteLine ("Bar");
(sdb)

Does that answer your question?