GDB hangs when using OpenOCD in remote pipe mode

I’m using GDB and OpenOCD to debug a simple program on my STM32F4DISCOVERY board on Windows. This works fine when starting OpenOCD separately, and using TCP/IP to connect to it, with something like this:

target remote localhost:3333

When I’m done, I can shut down GDB using quit as normal. I would like, however, to use GDB in “remote pipe” mode, instead of needing to start and stop OpenOCD manually. This seems like a somewhat ideal configuration to me. When I do this, however, I cannot exit GDB, as it hangs when I attempt to exit.

The OpenOCD log file shows that the GDB connection was dropped:

Info : dropped ‘gdb’ connection

But GDB never exits:

(gdb) quit

A debugging session is active.

Inferior 1 [Remote target] will be detached.

Quit anyway? (y or n) y

Detaching from program: yagarto_sample.elf, Remote target

Ending remote debugging.

The disconnect command similarly hangs, never returing. Not even Ctrl-C will wake up GDB. Am I doing something wrong? Is there some sort of configuration change I can make?

I will have a look into it, have not tested pipe mode on windows for a while.

Due to the way we have to implement pipe mode under windows it is was never as responsive as we had hoped, unlike other platforms.

Can you provide more details on your OS? winxp, win7 32 or 64bit etc.

Spen

Windows 8, 64 bit. I tried in PowerShell as well as cmd.exe in case that would make a difference, but it didn’t seem to.

Cheers.

one more question, where did you get your OpenOCD from?

0.6.1 from Freddie Chopin’s website. I guess I should have tried the x86 version as well, but I was running the x64 version.

I have found the cause of the hang, i have uploaded a patch here - http://openocd.zylin.com/993

If you are able to build/test that would be good.

Cheers

Spen

I’ll give building it a shot, but it could be a bit, due to the holiday. Is it simpler to cross-compile from Linux or build using Cygwin? I’m not a particular fan of Cygwin…

A temp workaround may be to use an event handler, eg.

Try adding this to your cfg - not tested.

$_TARGETNAME configure -event gdb-detach { shutdown }

Cheers

Spen

Your workaround works great!

And you seem to be right, debugging over TCP/IP is MUCH faster. I’m not sure it’s worth investing much effort into a fix…

The speed issue only relates to windows, under Linux it is just as quick.

Long term the speed issue needs looking at, it may be fixable.

Spen