Using gdb from 2016q1 (GNU gdb (GNU Tools for ARM Embedded Processors) 7.10.1.20160210-cvs)
Using openocd as the gdb middleware.
*** Steps to reproduce: (with gdb remote included from run) ***
gdb blah.elf
target ext :33333
run
ctrl-c
(GDB HANGS)
$ arm-none-eabi-gdb somefile.elf
(gdb) set debug remote 10
(gdb) tar ext :3333
(snipped lots of remote protocol here)
(gdb) run
The program being debugged has been started already.
Start it from the beginning? (y or n) y
Sending packet: $vKill;a410#33...Packet received:
Packet vKill (kill) is NOT supported
Sending packet: $k#6b...Sending packet: $?#3f...Packet received: W00
Starting program: /home/karlp/src/libopencm3-examples/examples/stm32/l1/stm32l-discovery/button-irq-printf/main.elf
Sending packet: $vRun;#e6...Packet received:
Packet vRun (run) is NOT supported
Sending packet: $R0#82...Sending packet: $qC#b4...Packet received: QC0
Sending packet: $qAttached#8f...Packet received: 1
Sending packet: $qOffsets#4b...Packet received: Text=0;Data=0;Bss=0
Sending packet: $Hg0#df...Packet received: OK
Sending packet: $qXfer:features:read:target.xml:0,fff#7d...Packet received: l<?xml version="1.0"?>\n<!DOCTYPE target SYSTEM "gdb-target.dtd">\n<target version="1.0">\n<feature name="org.gnu.gdb.arm.m-profile">\n<reg name="r0" bitsize="32" regnum="0" save-restore="yes" type="int" group="general"/>\n<reg name="r1" bitsize="32" regnum="1" save-restore="yes" type="int" group="general"/>\n<reg name="r2" bitsize="32" regnum="2" save-restore="yes" type="int" group="general"/>\n<reg name="r3" bitsize="32" regnum="3" save-restore="yes" type="int" group="general"/>\n<reg name="r4" bitsize="32" regnum="4" save-restore="yes" type="int" group="general"/>\n<reg name="r5" bitsize="32" regnum="5" save-restore="yes" type="int" group="general"/>\n<reg name="r6" bitsize="32" regnum="6" save-restore="yes" type="int" group="general"/>\n<reg name="r7" bitsize="32" regnum="7" save-restore="yes" type="int" group="general"/>\n<reg name="r8" bitsize="32" regnum="8" save-restore="yes" type="int" group="general"/>\n<reg name="r9" bitsize="32" regnum="9" save-restore="yes" type="int" group="general"/>\n<reg name="r10" bitsize="32" regnum="10" save-restore="yes" type="int" group="general"/>\n<reg name="r11" bitsize="32" regnum="11" save-restore="yes" type="int" group="general"/>\n<reg name="r12" bitsize="32" regnum="12" save-restore="yes" type="int" group="general"/>\n<reg name="sp" bitsize="32" regnum="13" save-restore="yes" type="data_ptr" group="general"/>\n<reg name="lr" bitsize="32" regnum="14" save-restore="yes" type="int" group="general"/>\n<reg name="pc" bitsize="32" regnum="15" save-restore="yes" type="code_ptr" group="general"/>\n<reg name="xPSR" bitsize="32" regnum="16" save-restore="yes" type="int" group="general"/>\n</feature>\n<feature name="org.gnu.gdb.arm.m-system">\n<reg name="msp" bitsize="32" regnum="17" save-restore="yes" type="data_ptr" group="system"/>\n<reg name="psp" bitsize="32" regnum="18" save-restore="yes" type="data_ptr" group="system"/>\n<reg name="primask" bitsize="1" regnum="19" save-restore="yes" type="int8" group="system"/>\n<reg name="basepri" bitsize="8" regnum="20" save-restore="yes" type="int8" group="system"/>\n<reg name="faultmask" bitsize="1" regnum="21" save-restore="yes" type="int8" group="system"/>\n<reg name="control" bitsize="2" regnum="22" save-restore="yes" type="int8" group="system"/>\n</feature>\n</target>\n
Sending packet: $g#67...Packet received: 0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000400020ffffffff3c08000800000001
Sending packet: $vCont?#49...Packet received:
Packet vCont (verbose-resume) is NOT supported
Sending packet: $Hc0#db...Packet received: OK
Sending packet: $c#63...
---- target is successfully running as expected here ---
^Casync_remote_interrupt called
remote_stop called
Packet received: T02
Sending packet: $g#67...Packet received: 00140040ffff00002000000001000000a0610008a061000800000000000000000000000000000000000000000000000001000000f83f0020330300083203000800000001
Sending packet: $qXfer:memory-map:read::0,fff#1c...Packet received: l<memory-map>\n<memory type="ram" start="0x0" length="0x8000000"/>\n<memory type="flash" start="0x8000000" length="0x20000">\n<property name="blocksize">0x1000</property>\n</memory>\n<memory type="ram" start="0x8020000" length="0xf7fe0000"/>\n</memory-map>\n
Sending packet: $m8000332,4#2d...Packet received: fee7585f
---- GDB has hung here, a second ctrl-c will produce "Interrupted while waiting for the program.
Give up waiting? (y or n)"
---- however, OpenOCD has succesfully interrupted the target.
WORKAROUND:
If, instead of issuing "run" you issue "continue" you can then ctrl-c to interrupt, and any _subsequent_ use of "run" will also successfully interrupt.
ie Notice run/ctrl-c now interrupts properly.
$ gdb blah.elf
(gdb) tar ext :3333
(gdb) c
target running...
^C
Program received signal SIGINT, Interrupt.
0x08000332 in setup_tim7 () at main.c:160
160 timer_enable_counter(TIM7);
(gdb) run
The program being debugged has been started already.
Start it from the beginning? (y or n) y
Starting program: /home/karlp/src/libopencm3-examples/examples/stm32/l1/stm32l-discovery/button-irq-printf/main.elf
^C
Program received signal SIGINT, Interrupt.
0x08000332 in setup_tim7 () at main.c:160
160 timer_enable_counter(TIM7);
(gdb)
This behaviour has been broken since 4.9-2014q4 release. 4.8-2014q3 was the last release that worked properly. (gdb7.6 vs gdb 7.8)