emad-elsaid / debugger

Golang Debugger Graphical user interface for Go programming language. Based on Delve debugger
MIT License
65 stars 5 forks source link

locking up on simple example on mac #5

Open gedw99 opened 1 year ago

gedw99 commented 1 year ago

i decided to go back to basics, because i can not work on other aspects due to locking up.

Here is an easy example: https://github.com/gioui/gio-example/tree/main/markdown

From this the markdown folder...

go install github.com/emad-elsaid/debugger@latest

# change to the gio markdown example...
markdown % debugger run .
debugserver-@(#)PROGRAM:LLDB  PROJECT:lldb-1300.0.42.3
 for x86_64.
Got a connection, launched process /Users/apple/workspace/go/src/github.com/_jumk/gio-example/markdown/debug (pid = 39290).
Exiting.
debugserver-@(#)PROGRAM:LLDB  PROJECT:lldb-1300.0.42.3
 for x86_64.
Got a connection, launched process /Users/apple/workspace/go/src/github.com/_jumk/gio-example/markdown/debug (pid = 39347).
Exiting.

The Debugger GUI and Markdown GUI opens in 1 second.. ok good so far...

Now i click on the line to mark it as a breakpoint and the system locks up. On Mac it beach balls but you can't see it in the screen shots. Have to trust me...

Screenshot 2023-07-12 at 17 48 40 Screenshot 2023-07-12 at 17 44 39

I would love to get to the bottom of this as i really want to work on this gio debugger...

gedw99 commented 1 year ago

Maybe just getting the red dot showing when you pick a breakpoint would be a good start, because it's driving me nuts to not know where the break point is.

gedw99 commented 1 year ago

Maybe the issue is that its trying to restart the example program and has a bug there.

i noticed that after i press "restart" in the debugger GUI, everything locks up. If i them close the example GUI, then the debugger immediately comes back to life. In the OS task manager it immediately stopped being red - ie blocking

so i think it has to do with the process manager code maybe ?

emad-elsaid commented 1 year ago

the main file that control the debugger is here: https://github.com/emad-elsaid/debugger/blob/master/debugger.go it include all functions that add/remove/toggle/list breakpoints. stop/continue/start/pause the program.

I would try to do the same to a stopped program first. so stop the program, add breakpoint, run the program.

Another test is to try that on an Intel machine mac instead of M1. to eliminate the issue that it could be an M1 compatibility for delv.

have we checked if this issue is a delv issue? maybe it's delv not the UI implementation.

emad-elsaid commented 1 year ago

I have updated the dependencies. and fixed the issue with breakpoints.

The issue is that we can't change/read breakpoints for a running program. it has to be stopped. and we can't stop the program every frame so we cache this list when we can. so when we change the breakpoints we will also cache the list.

gedw99 commented 1 year ago

Btw I am using an Intel Mac.

I started to go through the code also . thank you for the changes.

I will try out things here and update my progress here …

gedw99 commented 1 year ago

Hey @emad-elsaid

Ok so i am running your latest code on Mac intel.

Your idea worked - Always stop the running program via the debugger STOP button before setting a breakpoint OR removing a breakpoint. So that's encouraging !!!

Stack Trace Tab

If the debugger is running ( with zero break points ), and i press the "stack" tab, it locks up for 15 seconds before coming back to life.

Here are 2 screenshots to help you understand what happens ...

Debugger running, and Stack trackers are NOT available.

Screenshot 2023-07-20 at 15 41 30

Debugger stopped, and Stack trackers are available.

Screenshot 2023-07-20 at 15 41 23

Breakpoints Tab

Also i managed to crash the Debugger by going into the Breakpoints Tab and selecting to delete all breakpoints. Can't remember is Debugging was ON or OFF.


2023/07/20 15:38:32 ERR could not find statement at /Users/apple/workspace/go/src/github.com/gedw99/x-editor/debugger/gio-example/markdown/main.go:120, please use a line with a statement
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x68 pc=0x1005134a8]

goroutine 41 [running]:
github.com/go-delve/delve/pkg/proc.(*Breakpoint).LogicalID(...)
        /Users/apple/go/pkg/mod/github.com/go-delve/delve@v1.21.0/pkg/proc/breakpoints.go:176
github.com/go-delve/delve/service/debugger.(*Debugger).ClearBreakpoint(0xc0000f20b0, 0xc003e00c80)
        /Users/apple/go/pkg/mod/github.com/go-delve/delve@v1.21.0/service/debugger/debugger.go:969 +0x108
main.(*Debugger).ClearAllBreakpoints(0xc0000f2000)
        /Users/apple/workspace/go/src/github.com/gedw99/x-editor/debugger/debugger/debugger.go:188 +0x125
main.(*BreakpointsPanel).Toolbar(0xc00149ce70, 0x5d0?)
        /Users/apple/workspace/go/src/github.com/gedw99/x-editor/debugger/debugger/breakpoints_panel.go:89 +0x237
main.(*BreakpointsPanel).Layout(0x2c4f?, 0xe000?)
        /Users/apple/workspace/go/src/github.com/gedw99/x-editor/debugger/debugger/breakpoints_panel.go:37 +0x38
main.(*DebugScreen).Layout.func8({{{0x5d0, 0x12f}, {0x5d0, 0x12f}}, {0x40000000, 0x40000000}, {0x10080fae0, 0xc0000f00c8}, {0xc1266c912cc6a198, 0x117b924b16d, ...}, ...})
        /Users/apple/workspace/go/src/github.com/gedw99/x-editor/debugger/debugger/debug_screen.go:65 +0x29
gioui.org/layout.Flex.Layout({0x44?, 0x0?, 0x0?, 0x0?}, {{{0x5d0, 0x170}, {0x5d0, 0x170}}, {0x40000000, 0x40000000}, ...}, ...)
        /Users/apple/go/pkg/mod/gioui.org@v0.1.0/layout/flex.go:134 +0x738
github.com/emad-elsaid/debugger/ui.Rows.func1({{{0x5d0, 0x170}, {0x5d0, 0x170}}, {0x40000000, 0x40000000}, {0x10080fae0, 0xc0000f00c8}, {0xc1266c912cc6a198, 0x117b924b16d, ...}, ...})
        /Users/apple/workspace/go/src/github.com/gedw99/x-editor/debugger/debugger/ui/layouts.go:34 +0x6a
gioui.org/layout.Flex.Layout({0xa0?, 0xfa?, 0x17?, 0xc0?}, {{{0x5d0, 0x4b0}, {0x5d0, 0x4b0}}, {0x40000000, 0x40000000}, ...}, ...)
        /Users/apple/go/pkg/mod/gioui.org@v0.1.0/layout/flex.go:134 +0x738
github.com/emad-elsaid/debugger/ui.Rows.func1({{{0x5d0, 0x4b0}, {0x5d0, 0x4b0}}, {0x40000000, 0x40000000}, {0x10080fae0, 0xc0000f00c8}, {0xc1266c912cc6a198, 0x117b924b16d, ...}, ...})
        /Users/apple/workspace/go/src/github.com/gedw99/x-editor/debugger/debugger/ui/layouts.go:34 +0x6a
main.(*DebugScreen).Layout(0xc001498000, {{{0x5d0, 0x4b0}, {0x5d0, 0x4b0}}, {0x40000000, 0x40000000}, {0x10080fae0, 0xc0000f00c8}, {0xc1266c912cc6a198, ...}, ...})
        /Users/apple/workspace/go/src/github.com/gedw99/x-editor/debugger/debugger/debug_screen.go:70 +0xbdb
main.EventLoop(0xc0000f2000)
        /Users/apple/workspace/go/src/github.com/gedw99/x-editor/debugger/debugger/main.go:68 +0x1be
main.RunWindowAndExit(0xc00069c150?)
        /Users/apple/workspace/go/src/github.com/gedw99/x-editor/debugger/debugger/main.go:54 +0x19
created by main.main
        /Users/apple/workspace/go/src/github.com/gedw99/x-editor/debugger/debugger/main.go:48 +0x4c5
Exiting.
emad-elsaid commented 1 year ago

There is something that delve doesn't allow which is getting stacks while the application is running and some other stuff, and if I tried that the debugger process panics. I tried to work around that by locking the process, get the information we want then unlock it. But delve doesn't export the mutex it uses to lock the process so I had to make another workaround to access it. I guess this whole part I probably should give up on and just go with the decisions made in delve.

gedw99 commented 1 year ago

Hey

sorry about not following up. Am in the middle of moving countries and it’s taking all my time …

emad-elsaid commented 1 year ago

no worries, we're all busy. take care. I'll wait for your input when you have some time :wave:

gedw99 commented 1 year ago

Have time again.. I was looking at this issue and not sure what I can do to help.

Last thing you said above was "just go with the decisions made in delve."...

I have MAC and Windows here....

just let me know :)

I just tried it again and got the Beach ball of course :)