Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

I want to set the break-point at bar function. (^_^)/ #42

Closed
callmekohei opened this issue Oct 23, 2017 · 10 comments
Closed

I want to set the break-point at bar function. (^_^)/ #42

callmekohei opened this issue Oct 23, 2017 · 10 comments

Comments

@callmekohei
Copy link

callmekohei commented Oct 23, 2017

Hello! I'm callmekohei!.

Problems summary

I want to set the break-point at `bar` function. (^_^)/

system

$ sw_vers 
ProductName:	Mac OS X
ProductVersion:	10.12.6
BuildVersion:	16G29

$ sdb --version
Mono soft debugger (sdb) 1.5.6503.20649

$ mono --version
Mono JIT compiler version 5.0.1.1 (2017-02/5077205 Wed May 31 14:47:04 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)

code

let bar() = 
    stdout.WriteLine("abc")   // <--- I want to set break-point at this line!

let foo (str:string) =
    stdout.WriteLine(str)
    bar()

[<EntryPointAttribute>]
let main _ =
    let s = "Foo!"
    foo s
    stdout.WriteLine("callmekohei")
    0

debugging

$ sdb
Welcome to the Mono soft debugger (sdb 1.5.6503.20649)
Type 'help' for a list of commands or 'quit' to exit

(sdb) bp add at test.fs 2
Breakpoint '0' added at '/Users/callmekohei/tmp/test.fs:2'
(sdb) bp add at test.fs 12
Breakpoint '1' added at '/Users/callmekohei/tmp/test.fs:12'
(sdb) bp
#0 '/Users/callmekohei/tmp/test.fs:2'
#1 '/Users/callmekohei/tmp/test.fs:12'
(sdb) r test.exe
Inferior process '1627' ('test.exe') started
Event: 'TargetReady'
[Mono] Loaded assembly: /Users/callmekohei/tmp/test.exe
[Mono] Loaded assembly: /usr/local/Cellar/mono/5.0.1.1/lib/mono/gac/FSharp.Core/4.4.1.0__b03f5f7f11d50a3a/FSharp.Core.dll
[Mono] Resolved pending breakpoint at 'test.fs:2,1' to void Test.bar () [0x00000].
[Mono] Resolved pending breakpoint at 'test.fs:12,1' to int Test.main (string[] _arg1) [0x0001f].
Foo!
abc
Hit breakpoint at '/Users/callmekohei/tmp/test.fs:12'
#0 [0x0000001F] Test.main at /Users/callmekohei/tmp/test.fs:12
    stdout.WriteLine("callmekohei")
Event: 'TargetHitBreakpoint'
(sdb) c
Inferior process '1627' ('test.exe') resumed
callmekohei
Inferior process '1627' ('test.exe') exited with code '0'
Event: 'TargetExited'
@callmekohei callmekohei changed the title I want to set the break-point at bar function. (^_^)/ I want to set the break-point at 'bar' function. (^_^)/ Oct 23, 2017
@callmekohei callmekohei changed the title I want to set the break-point at 'bar' function. (^_^)/ I want to set the break-point at bar function. (^_^)/ Oct 23, 2017
@alexrp
Copy link
Collaborator

alexrp commented Nov 23, 2017

Hello,

Assuming your code is in a file called Program.fs, something like bp add fun Program.bar should work, since the F# compiler translates modules into static classes.

@callmekohei
Copy link
Author

Hello!

Thank your reply! (^_^)/

I do try it. But it does not work well (^_^;;

Last login: Thu Nov 23 17:05:08 on ttys000
~$ cd tmp
tmp$ cd jikken_sdb/
jikken_sdb$ cat pro
Program.exe  Program.fs   
jikken_sdb$ cat Program.fs 
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
jikken_sdb$ sdb
Welcome to the Mono soft debugger (sdb 1.5.6503.20649)
Type 'help' for a list of commands or 'quit' to exit

(sdb) bp add fun Program.bar
Breakpoint '0' added for method 'Program.bar'
(sdb) run Program.exe
Inferior process '3306' ('Program.exe') started
Event: 'TargetReady'
[Mono] Loaded assembly: /Users/callmekohei/tmp/jikken_sdb/Program.exe
[Mono] Loaded assembly: /usr/local/Cellar/mono/5.0.1.1/lib/mono/gac/FSharp.Core/4.4.1.0__b03f5f7f11d50a3a/FSharp.Core.dll
[Mono] Resolved pending breakpoint for 'Program.bar()' to [0x0](no debug symbols).
Foo!
abc
callmekohei
Inferior process '3306' ('Program.exe') exited with code '0'
Event: 'TargetExited'
(sdb) exit
Bye
jikken_sdb$ 

@callmekohei
Copy link
Author

Hmmmm....

I try to create namespace and module.

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

then try

Last login: Thu Nov 23 17:24:26 on ttys001
~$ cd tmp
tmp$ cd jikken_sdb/
jikken_sdb$ sdb
Welcome to the Mono soft debugger (sdb 1.5.6503.20649)
Type 'help' for a list of commands or 'quit' to exit

(sdb) bp add fun ABC.DEF.bar
Breakpoint '0' added for method 'ABC.DEF.bar'
(sdb) bp
#0 'ABC.DEF.bar'
(sdb) run Program.exe
Inferior process '3447' ('Program.exe') started
Event: 'TargetReady'
[Mono] Loaded assembly: /Users/callmekohei/tmp/jikken_sdb/Program.exe
[Mono] Loaded assembly: /usr/local/Cellar/mono/5.0.1.1/lib/mono/gac/FSharp.Core/4.4.1.0__b03f5f7f11d50a3a/FSharp.Core.dll
[Mono] Resolved pending breakpoint for 'ABC.DEF.bar()' to [0x0](no debug symbols).
Foo!
abc
callmekohei
Inferior process '3447' ('Program.exe') exited with code '0'
Event: 'TargetExited'
(sdb) exit
Bye
jikken_sdb$ 

@alexrp
Copy link
Collaborator

alexrp commented Nov 23, 2017

Hmm, I think you need to compile your program with --debug+. As far as I remember, method breakpoints do not work without debug information (PDB/MDB file) available (not really sure why).

@callmekohei
Copy link
Author

Thank you for your reply!

So, I try it.

jikken_sdb$ cat Program.fs 
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
jikken_sdb$ fsharpc --debug+ Program.fs 
F# Compiler for F# 4.1
Freely distributed under the Apache 2.0 Open Source License
jikken_sdb$ ls
Program.exe     Program.exe.mdb Program.fs

then

jikken_sdb$ sdb
Welcome to the Mono soft debugger (sdb 1.5.6503.20649)
Type 'help' for a list of commands or 'quit' to exit

(sdb) bp add func ABC.DEF.bar
Breakpoint '0' added for method 'ABC.DEF.bar'
(sdb) run program.exe
Inferior process '3813' ('program.exe') started
Event: 'TargetReady'
[Mono] Loaded assembly: /Users/callmekohei/tmp/jikken_sdb/program.exe
[Mono] Loaded assembly: /usr/local/Cellar/mono/5.0.1.1/lib/mono/gac/FSharp.Core/4.4.1.0__b03f5f7f11d50a3a/FSharp.Core.dll
[Mono] Resolved pending breakpoint for 'ABC.DEF.bar()' to /Users/callmekohei/tmp/jikken_sdb/Program.fs:4 [0x00000].
Foo!
abc
callmekohei
Inferior process '3813' ('program.exe') exited with code '0'
Event: 'TargetExited'
(sdb) quit
Bye

Hmmm....

It seems to work not well...

@alexrp
Copy link
Collaborator

alexrp commented Nov 23, 2017

OK, that looks like a bug. I will take a look.

@callmekohei
Copy link
Author

Thank you! (^_^)/

@callmekohei
Copy link
Author

Hello! I'm callmekohei!

So, I try and try and try!

I can do it!

screen shot 2017-12-06 at 17 27 15

I write detail later (^_^)/

@callmekohei
Copy link
Author

Hello! I'm callmekohei!

So, I find cause.

It's just how to compile.

In case Fsharp, compile following:

$ fsharpc -g --optimize- abc.fsx

That's point is --optimize-.

screen shot 2017-12-07 at 10 13 44

It's not cause on sdb.

So, I close this issue.

Thank you (^_^)/

@callmekohei
Copy link
Author

I wrote article about it.

see also: http://callmekohei00.hatenablog.com/entry/2017/12/07/202955

@alexrp alexrp removed their assignment Apr 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants