Debug F# with sdb!
This article is F# Advent Calendar2017 7th day
see : F# Advent Calendar2017Summary
I just try to debug F# code with sdb!
Like this
What is mono/sdb?
A command line client for the Mono soft debugger.
mono/sdb
환경
$ sw_vers
ProductName: Mac OS X
ProductVersion: 10.13.1
BuildVersion: 17B1003
$ uname -a
Darwin callmekoheis-MacBook-Air.local
17.2.0 Darwin Kernel
Version 17.2.0:
Fri Sep 29 18:27:05 PDT 2017;
root:xnu-4570.20.62~3/RELEASE_X86_64 x86_64
$ mono --version
Mono JIT compiler version 5.0.1.1 (2017-02/5077205 Sun Sep 17 18:29:46 BST 2017)
Copyright (C) 2002-2014 Novell, Inc, Xamarin Inc and Contributors. www.mono-project.com
TLS: normal
SIGSEGV: altstack
Notification: kqueue
Architecture: amd64
Disabled: none
Misc: softdebug
LLVM: supported, not enabled.
GC: sgen (concurrent by default)
Prepare
install mono/sdb
$ git clone https://github.com/mono/sdb
$ cd sdb
$ git submodule update --init --recursive
$ make
check
$ sdb --version
Mono soft debugger (sdb) 1.5.6503.20649
$ which sdb
/usr/local/bin/sdb
설정
$ which mono
/usr/local/bin/mono
// set location of mono
$ sdb
(sdb) cfg s RuntimePrefix /usr/local/ ( was /usr )
Debug
// write code
$ vim sample.fsx
namespace ABC
module DEF =
let bar() =
stdout.WriteLine("abc")
let foo (str:string) =
stdout.WriteLine(str)
bar()
[<EntryPointAttribute>]
let main _ =
let s = "Foo!"
foo s
stdout.WriteLine("callmekohei")
0
// compile
$ fsharpc -g --optimize- sample.fsx
// launch sdb
$ sdb
Welcome to the Mono soft debugger (sdb 1.5.6548.37600)
Type 'help' for a list of commands or 'quit' to exit
// set break point
(sdb) bp add func ABC.DEF.foo
Breakpoint '0' added for method 'ABC.DEF.foo'
// run
(sdb) r sample.exe
Inferior process '8743' ('sample.exe') started
Hit method breakpoint on 'ABC.DEF.foo'
#0 [0x00000000] ABC.DEF.foo at /Users/callmekohei/tmp/xxx/sample.fsx:8
stdout.WriteLine(str)
// look source code
(sdb) src
1: namespace ABC
2:
3: module DEF =
4: let bar() =
5: stdout.WriteLine("abc")
6:
7: let foo (str:string) =
8: stdout.WriteLine(str) // <--- color green!
9: bar()
10:
11: [<EntryPointAttribute>]
12: let main _ =
13: let s = "Foo!"
14: foo s
15: stdout.WriteLine("callmekohei")
16: 0
// continue
(sdb) c
Inferior process '8743' ('sample.exe') resumed
Foo!
abc
callmekohei
Inferior process '8743' ('sample.exe') exited with code '0'
// quiet
(sdb) q
Bye
포인트
compile option --optimize-
$ fsharpc -g --optimize- sample.fsx
Reference
이 문제에 관하여(Debug F# with sdb!), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다
https://qiita.com/callmekohei/items/8d3268f6905864de6717
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념
(Collection and Share based on the CC Protocol.)
$ sw_vers
ProductName: Mac OS X
ProductVersion: 10.13.1
BuildVersion: 17B1003
$ uname -a
Darwin callmekoheis-MacBook-Air.local
17.2.0 Darwin Kernel
Version 17.2.0:
Fri Sep 29 18:27:05 PDT 2017;
root:xnu-4570.20.62~3/RELEASE_X86_64 x86_64
$ mono --version
Mono JIT compiler version 5.0.1.1 (2017-02/5077205 Sun Sep 17 18:29:46 BST 2017)
Copyright (C) 2002-2014 Novell, Inc, Xamarin Inc and Contributors. www.mono-project.com
TLS: normal
SIGSEGV: altstack
Notification: kqueue
Architecture: amd64
Disabled: none
Misc: softdebug
LLVM: supported, not enabled.
GC: sgen (concurrent by default)
$ git clone https://github.com/mono/sdb
$ cd sdb
$ git submodule update --init --recursive
$ make
$ sdb --version
Mono soft debugger (sdb) 1.5.6503.20649
$ which sdb
/usr/local/bin/sdb
$ which mono
/usr/local/bin/mono
// set location of mono
$ sdb
(sdb) cfg s RuntimePrefix /usr/local/ ( was /usr )
// write code
$ vim sample.fsx
namespace ABC
module DEF =
let bar() =
stdout.WriteLine("abc")
let foo (str:string) =
stdout.WriteLine(str)
bar()
[<EntryPointAttribute>]
let main _ =
let s = "Foo!"
foo s
stdout.WriteLine("callmekohei")
0
// compile
$ fsharpc -g --optimize- sample.fsx
// launch sdb
$ sdb
Welcome to the Mono soft debugger (sdb 1.5.6548.37600)
Type 'help' for a list of commands or 'quit' to exit
// set break point
(sdb) bp add func ABC.DEF.foo
Breakpoint '0' added for method 'ABC.DEF.foo'
// run
(sdb) r sample.exe
Inferior process '8743' ('sample.exe') started
Hit method breakpoint on 'ABC.DEF.foo'
#0 [0x00000000] ABC.DEF.foo at /Users/callmekohei/tmp/xxx/sample.fsx:8
stdout.WriteLine(str)
// look source code
(sdb) src
1: namespace ABC
2:
3: module DEF =
4: let bar() =
5: stdout.WriteLine("abc")
6:
7: let foo (str:string) =
8: stdout.WriteLine(str) // <--- color green!
9: bar()
10:
11: [<EntryPointAttribute>]
12: let main _ =
13: let s = "Foo!"
14: foo s
15: stdout.WriteLine("callmekohei")
16: 0
// continue
(sdb) c
Inferior process '8743' ('sample.exe') resumed
Foo!
abc
callmekohei
Inferior process '8743' ('sample.exe') exited with code '0'
// quiet
(sdb) q
Bye
$ fsharpc -g --optimize- sample.fsx
Reference
이 문제에 관하여(Debug F# with sdb!), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://qiita.com/callmekohei/items/8d3268f6905864de6717텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념 (Collection and Share based on the CC Protocol.)