gdb fails to interrupt after "run"

Bug #1594341 reported by Karl Palsson
16
This bug affects 3 people
Affects Status Importance Assigned to Milestone
GNU Arm Embedded Toolchain
New
Undecided
Unassigned

Bug Description

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)

Revision history for this message
Karl Palsson (ubuntu-tweak) wrote :

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)

Revision history for this message
Chuck McManis (chuck-mcmanis) wrote :

I share Karl's issue here. It is really annoying having to remember the workaround.

Revision history for this message
Tejas Belagod (belagod-tejas) wrote :

What is the version of OpenOCD you're using? We'd need to eliminate the possibility of the bug in OpenOCD. Have you tried with a different version of OpenOCD?

Revision history for this message
Karl Palsson (ubuntu-tweak) wrote :

here's a matrix of all the tested versions

0.10.0-dev-00325-g12e4a2a OpenOCD (recent git master)
2013q2 gdb works 7.4.1.20130613-cvs
2014q2 gdb works 7.6.0.20140529-cvs
2014q3 gdb works 7.6.0.20140731-cvs
2014q4 gdb fails 7.8.1.20141128-cvs (workaround works)
2015q4 gdb fails 7.10.1.20151217-cvs (workaround works)
2016q1 gdb fails 7.10.1.20160210-cvs (workaround works)

0.9.0 OpenOCD release version
2013q2 gdb works
2014q2 gdb works 7.6.0.20140529-cvs
2014q3 gdb works 7.6.0.20140731-cvs
2014q4 gdb fails 7.8.1.20141128-cvs (workaround works)
2015q4 gdb fails 7.10.1.20151217-cvs (workaround works)
2016q1 gdb fails 7.10.1.20160210-cvs (workaround works)

0.8.0 OpenOCD release
2014q3 gdb works 7.6.0.20140731-cvs
2014q4 gdb fails 7.8.1.20141128-cvs (workaround works)

I didn't test the full matrix for oocd 0.8, just the versions where I could confirm working/nonworking in the same change in gdb, from 7.6, to 7.8.

Revision history for this message
Steven Stallion (sstallion) wrote :

Aha! I've finally duplicated the issue. I'm looking into the cause (and hopefully a fix), but a better workaround in the meantime should be to add:

    maintenance set target-async off

To your .gdbinit. I'll update the thread as soon as I find something.

Revision history for this message
Karl Palsson (ubuntu-tweak) wrote :

Still occurs with gcc-arm-none-eabi-6-2017-q2-update

Revision history for this message
Karl Palsson (ubuntu-tweak) wrote :

Oh, and in case it was't clear, "maintenance set target-async off" has no impact on this. It's just as broken with it off.

Revision history for this message
Tejas Belagod (belagod-tejas) wrote :
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.