mago icon indicating copy to clipboard operation
mago copied to clipboard

mago-mi: -break-insert -f does not work.

Open pirocks opened this issue 6 years ago • 8 comments

-break-insert -f allows for the insertion of breakpoints before the actual executable file is loaded. Breakpoints created like this seem to never be hit.

pirocks avatar Sep 21 '17 05:09 pirocks

@buggins I guess this refers to mago-mi.

rainers avatar Sep 22 '17 19:09 rainers

Yes it does refer to mago-mi.

pirocks avatar Sep 22 '17 19:09 pirocks

I will check it. I'm planning to work on dlangide debugging support improvement next month, so I can hack mago-mi

buggins avatar Sep 23 '17 05:09 buggins

Thanks. I've noticed another unrelated issue. See #15.

pirocks avatar Sep 23 '17 05:09 pirocks

I also hit this issue. @pirocks I assume you ask because this is related to IntelliJ D plugin you are involved. I did some tests and it seems it is related to the order:

-- Breakpoint is not hit --

C:\D\tools\mago-mi.exe --interpreter=mi2
-break-insert -f C:/D/projects/magotest/source/app.d:6
-file-exec-and-symbols C:/D/projects/magotest/magotest.exe
run

-- Breakpoint is hit --

C:\D\tools\mago-mi.exe --interpreter=mi2
-file-exec-and-symbols C:/D/projects/magotest/magotest.exe
-break-insert -f C:/D/projects/magotest/source/app.d:6
run

-- Breakpoint is hit --

C:\D\tools\mago-mi.exe --interpreter=mi2 C:/D/projects/magotest/magotest.exe
-break-insert -f C:/D/projects/magotest/source/app.d:6
-list-features
run

The IntelliJ D Plugin has 2 issues:

  • Instead of executing command -file-exec-and-symbols C:/D/projects/magotest/magotest.exe it executes command file C:/D/projects/magotest/magotest.exe. MagoMI only knows about the -file-exec-and-symbols command. As far as I understand the documentation both should be equivalent.

  • It sets the breakpoint before the executable is set.

I do not know whether setting breakpoints should be supported before the executable is set. But an easy way to solve the issue is just to change the OS call from C:\D\tools\mago-mi.exe --interpreter=mi2 to C:\D\tools\mago-mi.exe --interpreter=mi2 C:/D/projects/magotest/magotest.exe and remove the command "file C:/D/projects/magotest/magotest.exe" because the executable is already set. As far as I understood this is also the way DlangIDE is working.

andre2007 avatar Jun 07 '18 18:06 andre2007

I compared the behavior of GDB mi2 (linux) with MagoMI. In my test also GDB mi2 does not allow setting a breakpoint before the executable is specified. Doing so, will throw an error with the message "please specify executable first with command file".

Please note, while gdb mi2 knows the commands "file" and "-file-exec-and-symbols", MagoMI only knows command "-file-exec-and-symbols". Therefore "-file-exec-and-symbols" should be used by IntelliJ D plugin.

andre2007 avatar Jun 15 '18 10:06 andre2007

This issue can be closed. Today the merge of the pr was done which loads the executable first and then sets the breakpoints.

andre2007 avatar Jun 28 '18 19:06 andre2007

It might no longer be necessary for intellij, but the GDB/MI-API defines this function. So I think the issue can stay open.

rainers avatar Jun 29 '18 19:06 rainers