openocd/src/target
Antonio Borneo 23d8831391 target: avoid polling during 'resumed' event handler
OpenOCD is based on a single main loop that schedules all the
activities.
At the execution of a TCL command, the timestamp is checked to
eventually trigger the polling of the targets. This means that by
executing a TCL command the polling can be triggered and detect a
change of target's state.

When openocd 'resumes' a target, the target can halt again by
hitting a breakpoint.
The 'resumed' event handler is started just after the target has
been resumed, but it triggers a polling before the execution of
its very first instruction.
If the polling finds the target halted, it will run the 'halted'
event handler, that will then be executed 'before' the pending
'resumed' handler.

In case of gdb, a 'continue' command will restart the target but,
polling (and halt detection) executed before the end of the resume
process will hide the halt. As a consequence, the gdb will not be
informed of the halt and will remains waiting as if the target is
still running without showing the prompt.

This can be verified by running on the target a firmware with a
loop, run openocd with a dummy 'resumed' event, and let gdb to set
a breakpoint in the loop. A 'continue' command will cause the
target to halt again by hitting the breakpoint at the next loop
iteration, but gdb will loose it and will not return the prompt.

	openocd -f board/st_nucleo_f4.cfg -c \
		'stm32f4x.cpu configure -event resumed {echo hello}'
	arm-none-eabi-gdb -ex 'target remote :3333' -ex 'b *$pc' -ex c

Disable the polling while executing target's resume().
Document it and provide hints to developers to cope with future
implementation.

Change-Id: I3be830a8e7c2ef6278617cb4547a4d676b0ddeb5
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reported-by: Габитов Александр Фаритович <gabitov@planarchel.ru>
Reviewed-on: http://openocd.zylin.com/6074
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
Tested-by: jenkins
2021-03-04 14:58:58 +00:00
..
openrisc server: permit the add_service function to return the created service 2020-11-07 20:49:53 +00:00
riscv target/riscv: fix build error with -Werror=maybe-uninitialized 2021-01-18 15:31:56 +00:00
Makefile.am Add initial RTT support 2020-12-02 23:15:52 +00:00
a64_disassembler.c target/aarch64: a64 disassembler 2020-10-03 11:21:15 +01:00
a64_disassembler.h target/aarch64: a64 disassembler 2020-10-03 11:21:15 +01:00
aarch64.c target/aarch64: fix use of 'target->private_config' 2020-10-11 15:53:52 +01:00
aarch64.h aarch64: add 'maskisr' command 2018-01-16 09:05:41 +00:00
adi_v5_dapdirect.c adi_v5_dapdirect: fix connect under reset 2020-02-24 10:28:46 +00:00
adi_v5_jtag.c target/adi_v5_jtag: remove unused global variable 2020-11-04 17:39:53 +00:00
adi_v5_swd.c adi_v5_swd: wait for readable DPIDR, ABORT if stalled 2020-12-02 23:15:16 +00:00
algorithm.c Remove FSF address from GPL notices 2016-05-24 22:30:01 +01:00
algorithm.h target: Add 64-bit target address support 2017-02-10 13:50:17 +01:00
arc.c openocd: fix doxygen parameters of functions 2021-01-13 11:33:53 +00:00
arc.h target: use proper format with uint32_t 2020-09-05 17:12:39 +01:00
arc_cmd.c target/arc: fix command's usage string 2020-09-05 17:13:00 +01:00
arc_cmd.h Introduce ARCv2 architecture related code 2020-02-27 06:46:51 +00:00
arc_jtag.c openocd: fix doxygen parameters of functions 2021-01-13 11:33:53 +00:00
arc_jtag.h Introduce ARCv2 architecture related code 2020-02-27 06:46:51 +00:00
arc_mem.c target: fix minor typos and duplicated words 2020-07-26 23:09:45 +01:00
arc_mem.h Introduce ARCv2 architecture related code 2020-02-27 06:46:51 +00:00
arm.h cortex_m: read and display core security state 2020-09-20 14:35:44 +01:00
arm7_9_common.c target/register: use an array of uint8_t for register's value 2020-12-05 23:18:37 +00:00
arm7_9_common.h target/arm926ejs: fix memory leaks 2020-07-08 22:07:38 +01:00
arm7tdmi.c target/arm7tdmi: remove unused/deprecated function parameter 2020-11-07 20:53:26 +00:00
arm7tdmi.h target/arm7tdmi: fix memory leak of register cache 2020-07-26 20:12:48 +01:00
arm9tdmi.c target: fix memory leaks on targets based on arm9tdmi 2020-07-26 20:12:21 +01:00
arm9tdmi.h target: fix memory leaks on targets based on arm9tdmi 2020-07-26 20:12:21 +01:00
arm11.c target/arm11: fix memory leaks, including register cache 2020-08-02 10:48:52 +01:00
arm11.h Make #include guard naming consistent 2016-05-24 22:30:55 +01:00
arm11_dbgtap.c target/arm11: fix memory leaks, including register cache 2020-08-02 10:48:52 +01:00
arm11_dbgtap.h target/arm11: fix memory leaks, including register cache 2020-08-02 10:48:52 +01:00
arm720t.c target/arm720t: fix memory leak of register cache 2020-07-26 20:12:56 +01:00
arm720t.h Make #include guard naming consistent 2016-05-24 22:30:55 +01:00
arm920t.c target: fix memory leaks on targets based on arm9tdmi 2020-07-26 20:12:21 +01:00
arm920t.h target: Add 64-bit target address support 2017-02-10 13:50:17 +01:00
arm926ejs.c target: declare local symbols as static 2020-11-04 17:39:17 +00:00
arm926ejs.h target: Add 64-bit target address support 2017-02-10 13:50:17 +01:00
arm946e.c target: declare local symbols as static 2020-11-04 17:39:17 +00:00
arm946e.h Make #include guard naming consistent 2016-05-24 22:30:55 +01:00
arm966e.c target: use proper format with uint32_t 2020-09-05 17:12:39 +01:00
arm966e.h Make #include guard naming consistent 2016-05-24 22:30:55 +01:00
arm_adi_v5.c openocd: fix doxygen parameters of functions 2021-01-13 11:33:53 +00:00
arm_adi_v5.h arm_adi_v5: prevent possibly endless recursion in dap_dp_init() 2020-12-02 23:15:08 +00:00
arm_cti.c target/arm_cti: use adiv5_jim_mem_ap_spot_configure() 2020-11-04 17:37:25 +00:00
arm_cti.h armv8: valgrind memleak fixes 2018-04-10 09:13:02 +01:00
arm_dap.c adi_v5_dapdirect: add support for adapter drivers that provide DAP API 2020-01-14 11:40:25 +00:00
arm_disassembler.c Use capstone for ARM disassembler 2020-09-27 17:39:44 +01:00
arm_disassembler.h Use capstone for ARM disassembler 2020-09-27 17:39:44 +01:00
arm_dpm.c target: fix minor typos and duplicated words 2020-07-26 23:09:45 +01:00
arm_dpm.h coding style: add arguments to function prototypes 2020-07-08 22:08:19 +01:00
arm_jtag.c target/arm926ejs: fix memory leaks 2020-07-08 22:07:38 +01:00
arm_jtag.h target/arm926ejs: fix memory leaks 2020-07-08 22:07:38 +01:00
arm_opcodes.h target: fix minor typos and duplicated words 2020-07-26 23:09:45 +01:00
arm_semihosting.c semihosting: print the semihosting operation id 2020-11-07 20:50:16 +00:00
arm_semihosting.h Rework/update ARM semihosting 2018-06-04 09:16:08 +01:00
arm_simulator.c Remove FSF address from GPL notices 2016-05-24 22:30:01 +01:00
arm_simulator.h Make #include guard naming consistent 2016-05-24 22:30:55 +01:00
armv4_5.c armv4_5: fix output of command 'arm reg' 2020-12-05 23:18:22 +00:00
armv4_5.h target/cortex_a: add hypervisor mode 2020-03-12 10:11:19 +00:00
armv4_5_cache.c helper/command: change prototype of command_print/command_print_sameline 2019-05-14 19:37:11 +01:00
armv4_5_cache.h target/armv4_5_cache: change prototype of armv4_5_handle_cache_info_command() 2019-05-14 19:35:41 +01:00
armv4_5_mmu.c Remove FSF address from GPL notices 2016-05-24 22:30:01 +01:00
armv4_5_mmu.h target: Add 64-bit target address support 2017-02-10 13:50:17 +01:00
armv7a.c target: declare local symbols as static 2020-11-04 17:39:17 +00:00
armv7a.h target: fix minor typos and duplicated words 2020-07-26 23:09:45 +01:00
armv7a_cache.c target: declare local symbols as static 2020-11-04 17:39:17 +00:00
armv7a_cache.h target: use proper format with uint32_t 2020-09-05 17:12:39 +01:00
armv7a_cache_l2x.c target: use proper format with uint32_t 2020-09-05 17:12:39 +01:00
armv7a_cache_l2x.h target: Add 64-bit target address support 2017-02-10 13:50:17 +01:00
armv7a_mmu.c target: use proper format with uint32_t 2020-09-05 17:12:39 +01:00
armv7a_mmu.h armv7a_mmu: Do not restrict virtual addresses to uint32_t 2019-06-12 15:14:44 +01:00
armv7m.c target/armv7m, cortex_m: fix misleading comments 2020-11-15 21:09:08 +00:00
armv7m.h target/armv7m: rework Cortex-M register handling part 3 2020-11-15 21:06:23 +00:00
armv7m_trace.c armv7m_trace: stop getting traces from adapter at exit 2020-12-26 15:47:44 +00:00
armv7m_trace.h armv7m_trace: stop getting traces from adapter at exit 2020-12-26 15:47:44 +00:00
armv8.c target: declare local symbols as static 2020-11-04 17:39:17 +00:00
armv8.h target: fix minor typos and duplicated words 2020-07-26 23:09:45 +01:00
armv8_cache.c target: use proper format with uint32_t 2020-09-05 17:12:39 +01:00
armv8_cache.h aarch64: add cache handling functions 2017-02-10 14:01:39 +01:00
armv8_dpm.c target: use proper format with uint32_t 2020-09-05 17:12:39 +01:00
armv8_dpm.h coding style: add arguments to function prototypes 2020-07-08 22:08:19 +01:00
armv8_opcodes.c target/armv8_opcodes: use T32 instructions when the PE is in AArch32 state 2020-03-12 09:47:08 +00:00
armv8_opcodes.h target/armv8_opcodes: use T32 instructions when the PE is in AArch32 state 2020-03-12 09:47:08 +00:00
avr32_ap7k.c target: declare local symbols as static 2020-11-04 17:39:17 +00:00
avr32_ap7k.h Make #include guard naming consistent 2016-05-24 22:30:55 +01:00
avr32_jtag.c target: declare local symbols as static 2020-11-04 17:39:17 +00:00
avr32_jtag.h Make #include guard naming consistent 2016-05-24 22:30:55 +01:00
avr32_mem.c Remove FSF address from GPL notices 2016-05-24 22:30:01 +01:00
avr32_mem.h Make #include guard naming consistent 2016-05-24 22:30:55 +01:00
avr32_regs.c Remove FSF address from GPL notices 2016-05-24 22:30:01 +01:00
avr32_regs.h Make #include guard naming consistent 2016-05-24 22:30:55 +01:00
avrt.c target: fix minor typos and duplicated words 2020-07-26 23:09:45 +01:00
avrt.h Make #include guard naming consistent 2016-05-24 22:30:55 +01:00
breakpoints.c target: Add function to remove all breakpoints 2020-03-26 19:30:34 +00:00
breakpoints.h target: Add function to remove all breakpoints 2020-03-26 19:30:34 +00:00
cortex_a.c cortex-a: fix reset on dapdirect transports 2020-12-26 15:47:48 +00:00
cortex_a.h target/cortex_a: remove unused code controlled by "fast_reg_read" 2018-11-06 12:17:48 +00:00
cortex_m.c cortex_m: [FIX] ARMv8-M does not support VECTRESET 2021-01-18 15:32:03 +00:00
cortex_m.h cortex_m: declare local functions as static 2020-11-04 17:39:47 +00:00
dsp563xx.c target: use proper format with uint32_t 2020-09-05 17:12:39 +01:00
dsp563xx.h coding style: fix space separation 2020-07-08 22:08:08 +01:00
dsp563xx_once.c coding style: wrap lines longer than 120 chars 2020-05-09 14:40:52 +01:00
dsp563xx_once.h coding style: fix space around pointer's asterisk 2020-02-24 10:30:36 +00:00
dsp5680xx.c openocd: fix doxygen parameters of functions 2021-01-13 11:33:53 +00:00
dsp5680xx.h coding style: fix space around pointer's asterisk 2020-02-24 10:30:36 +00:00
embeddedice.c target/arm926ejs: fix memory leaks 2020-07-08 22:07:38 +01:00
embeddedice.h target/arm926ejs: fix memory leaks 2020-07-08 22:07:38 +01:00
esirisc.c helper/command: change prototype of command_print/command_print_sameline 2019-05-14 19:37:11 +01:00
esirisc.h esirisc: support eSi-Trace 2018-12-12 08:47:44 +00:00
esirisc_jtag.c target: use proper format with uint32_t 2020-09-05 17:12:39 +01:00
esirisc_jtag.h esirisc: support eSi-Trace 2018-12-12 08:47:44 +00:00
esirisc_regs.h target: fix minor typos and duplicated words 2020-07-26 23:09:45 +01:00
esirisc_trace.c target: use proper format with uint32_t 2020-09-05 17:12:39 +01:00
esirisc_trace.h esirisc: support eSi-Trace 2018-12-12 08:47:44 +00:00
etb.c helper/binarybuffer: fix clang static analyzer warnings 2020-03-07 15:30:05 +00:00
etb.h Make #include guard naming consistent 2016-05-24 22:30:55 +01:00
etm.c target/register: use an array of uint8_t for register's value 2020-12-05 23:18:37 +00:00
etm.h target: fix minor typos and duplicated words 2020-07-26 23:09:45 +01:00
etm_dummy.c helper/command: change prototype of command_print/command_print_sameline 2019-05-14 19:37:11 +01:00
etm_dummy.h Make #include guard naming consistent 2016-05-24 22:30:55 +01:00
fa526.c target: fix memory leaks on targets based on arm9tdmi 2020-07-26 20:12:21 +01:00
feroceon.c target: fix minor typos and duplicated words 2020-07-26 23:09:45 +01:00
hla_target.c Add initial RTT support 2020-12-02 23:15:52 +00:00
image.c Flash, FRAM and EEPROM driver for STM32 QUAD-/OCTOSPI interface 2020-11-08 22:46:00 +00:00
image.h Flash, FRAM and EEPROM driver for STM32 QUAD-/OCTOSPI interface 2020-11-08 22:46:00 +00:00
lakemont.c target: fix minor typos and duplicated words 2020-07-26 23:09:45 +01:00
lakemont.h target: Add 64-bit target address support 2017-02-10 13:50:17 +01:00
ls1_sap.c target: use proper format with uint32_t 2020-09-05 17:12:39 +01:00
mem_ap.c target: use proper format with uint32_t 2020-09-05 17:12:39 +01:00
mips32.c target: use proper format with uint32_t 2020-09-05 17:12:39 +01:00
mips32.h target: fix minor typos and duplicated words 2020-07-26 23:09:45 +01:00
mips32_dmaacc.c Remove FSF address from GPL notices 2016-05-24 22:30:01 +01:00
mips32_dmaacc.h Make #include guard naming consistent 2016-05-24 22:30:55 +01:00
mips32_pracc.c target: declare local symbols as static 2020-11-04 17:39:17 +00:00
mips32_pracc.h target: fix minor typos and duplicated words 2020-07-26 23:09:45 +01:00
mips64.c coding style: fix space separation 2020-07-08 22:08:08 +01:00
mips64.h mips: Add MIPS64 support 2019-11-28 16:59:15 +00:00
mips64_pracc.c target: use proper format with uint32_t 2020-09-05 17:12:39 +01:00
mips64_pracc.h mips: Add MIPS64 support 2019-11-28 16:59:15 +00:00
mips_ejtag.c target: declare local symbols as static 2020-11-04 17:39:17 +00:00
mips_ejtag.h mips_ejtag: there is no DCR.MIPS64 bit 2020-01-20 06:28:49 +00:00
mips_m4k.c target: avoid checking for non NULL pointer to free it 2020-09-05 20:47:11 +01:00
mips_m4k.h mips32: add micromips isa handling 2017-05-08 18:04:56 +01:00
mips_mips64.c mips_mips64: fix minor host endianness bug 2020-12-05 23:18:33 +00:00
mips_mips64.h mips64: Add generic mips64 target support 2019-11-28 19:49:10 +00:00
nds32.c target: allow profiling from running 2020-10-30 22:00:49 +00:00
nds32.h target/nds32: fix type of magic number 2020-02-15 15:36:56 +00:00
nds32_aice.c target: Add 64-bit target address support 2017-02-10 13:50:17 +01:00
nds32_aice.h target: Add 64-bit target address support 2017-02-10 13:50:17 +01:00
nds32_cmd.c openocd: fix command's usage string 2020-09-05 17:13:10 +01:00
nds32_cmd.h Make #include guard naming consistent 2016-05-24 22:30:55 +01:00
nds32_disassembler.c coding style: avoid unnecessary line continuations 2020-05-09 14:39:29 +01:00
nds32_disassembler.h Make #include guard naming consistent 2016-05-24 22:30:55 +01:00
nds32_edm.h Make #include guard naming consistent 2016-05-24 22:30:55 +01:00
nds32_insn.h Make #include guard naming consistent 2016-05-24 22:30:55 +01:00
nds32_reg.c target: use proper format with uint32_t 2020-09-05 17:12:39 +01:00
nds32_reg.h Make #include guard naming consistent 2016-05-24 22:30:55 +01:00
nds32_tlb.c target: declare local symbols as static 2020-11-04 17:39:17 +00:00
nds32_tlb.h target: Add 64-bit target address support 2017-02-10 13:50:17 +01:00
nds32_v2.c target: fix minor typos and duplicated words 2020-07-26 23:09:45 +01:00
nds32_v2.h Make #include guard naming consistent 2016-05-24 22:30:55 +01:00
nds32_v3.c target: declare local symbols as static 2020-11-04 17:39:17 +00:00
nds32_v3.h Make #include guard naming consistent 2016-05-24 22:30:55 +01:00
nds32_v3_common.c target: Add 64-bit target address support 2017-02-10 13:50:17 +01:00
nds32_v3_common.h target: Add 64-bit target address support 2017-02-10 13:50:17 +01:00
nds32_v3m.c target: declare local symbols as static 2020-11-04 17:39:17 +00:00
nds32_v3m.h Make #include guard naming consistent 2016-05-24 22:30:55 +01:00
oocd_trace.c helper/command: change prototype of command_print/command_print_sameline 2019-05-14 19:37:11 +01:00
oocd_trace.h Make #include guard naming consistent 2016-05-24 22:30:55 +01:00
quark_d20xx.c target: declare local symbols as static 2020-11-04 17:39:17 +00:00
quark_x10xx.c target: quark_x10xx: miscellaneous cleanups 2018-01-13 09:25:12 +00:00
register.c gdb_server, rtos: Fine-grained RTOS register access 2019-08-28 08:07:37 +01:00
register.h target/register: use an array of uint8_t for register's value 2020-12-05 23:18:37 +00:00
rtt.c Add initial RTT support 2020-12-02 23:15:52 +00:00
rtt.h Add initial RTT support 2020-12-02 23:15:52 +00:00
semihosting_common.c openocd: fix doxygen parameters of functions 2021-01-13 11:33:53 +00:00
semihosting_common.h Rework/update ARM semihosting 2018-06-04 09:16:08 +01:00
smp.c helper/command: change prototype of command_print/command_print_sameline 2019-05-14 19:37:11 +01:00
smp.h smp: replace commands smp_on/smp_off with "smp [on|off]" 2019-03-27 08:55:03 +00:00
startup.tcl target: use one second timeout while halting target at gdb attach 2020-08-02 10:48:41 +01:00
stm8.c target: declare local symbols as static 2020-11-04 17:39:17 +00:00
stm8.h STM8 Target relicensing to GPLv2 and later 2019-11-07 08:21:40 +00:00
target.c target: avoid polling during 'resumed' event handler 2021-03-04 14:58:58 +00:00
target.h target/cortex_m: Change sleep to running state 2020-11-11 21:22:16 +00:00
target_request.c target: fix minor typos and duplicated words 2020-07-26 23:09:45 +01:00
target_request.h Make #include guard naming consistent 2016-05-24 22:30:55 +01:00
target_type.h gdb_server, rtos: Fine-grained RTOS register access 2019-08-28 08:07:37 +01:00
testee.c command_registration: add empty usage field to chained commands 2019-04-07 08:17:36 +01:00
trace.c target: avoid checking for non NULL pointer to free it 2020-09-05 20:47:11 +01:00
trace.h Make #include guard naming consistent 2016-05-24 22:30:55 +01:00
x86_32_common.c helper/command: change prototype of command_print/command_print_sameline 2019-05-14 19:37:11 +01:00
x86_32_common.h target: lakemon: implement assert_reset and deassert_reset 2018-01-13 09:25:34 +00:00
xscale.c target, register: allow a register hidden from gdb and 'reg' cmd 2020-11-15 21:05:37 +00:00
xscale.h Make #include guard naming consistent 2016-05-24 22:30:55 +01:00