2
0
mirror of git://git.code.sf.net/p/openocd/code synced 2025-08-05 17:40:16 +10:00
openocd/src/target
Marcin Niestroj 7dd5b6a464 rtt: fix corner-cases of finding control block
This patch fixes two corner-cases of finding RTT control block.

The first one is when there was a partial match (even single byte) at
the end of loaded buffer (uint8_t buf[1024]), but this was not part of
full match. In that case `cb_offset` was not updated correctly and the
returned `*address` was lower by the legth of the partial match. In case
of searched 'SEGGER RTT' (the default control block ID) string, it was
enough to match `buf[1023] == 'S'`, which is quite likely to happen, and
the `*address` was offset by 1 (e.g. it was 0x20000fff instead of
0x20010000).

Updating (or even maintaining) `cb_offset` is not needed, as start
address of control block can be calculated based on memory address that
was loaded into `uint8_t buf[1024]`, the offset within this buffer and
the length of expected string.

The second issue is when control block is prepended with a byte that
matches first ID character, e.g. there is `SEGGER RTT` control block ID
is prepended by another `S`, making memory contents be `SSEGGER RTT`. In
that case there was no match found.

Fix that issue by making sure that tested byte is always compared with
first byte of expected control block ID.

While at it, change names of local variables to better describe their
meaning.

Signed-off-by: Marcin Niestroj <m.niestroj@emb.dev>
Change-Id: I12aa6e202bf12bedcbb888ab595751a2a2518a24
Reviewed-on: https://review.openocd.org/c/openocd/+/7429
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2023-01-11 17:02:25 +00:00
..
espressif target/esp32s2: check xtensa_poll return value 2022-10-15 15:57:57 +00:00
openrisc openrisc: fix clang error core.CallAndMessage 2022-11-11 20:10:41 +00:00
riscv doc: fix riscv commands 2022-10-21 18:14:46 +00:00
xtensa target/xtensa: remove redundant call for TARGET_EVENT_HALTED 2022-10-21 18:16:23 +00:00
a64_disassembler.c openocd: fix SPDX tag format for files .c 2022-09-18 08:22:01 +00:00
a64_disassembler.h openocd: src/target: replace the GPL-2.0-or-later license tag 2022-07-23 13:58:51 +00:00
aarch64.c arm_adi_v5: fix SIGSEGV due to failing re-examine 2022-12-17 09:30:45 +00:00
aarch64.h target: move parent target structs just after common_magic 2022-08-14 12:10:14 +00:00
adi_v5_dapdirect.c openocd: fix SPDX tag format for files .c 2022-09-18 08:22:01 +00:00
adi_v5_jtag.c openocd: fix SPDX tag format for files .c 2022-09-18 08:22:01 +00:00
adi_v5_swd.c target/adi_v5_swd: suppress reconnect in swd_multidrop_select() 2022-09-27 08:29:00 +00:00
algorithm.c openocd: fix SPDX tag format for files .c 2022-09-18 08:22:01 +00:00
algorithm.h openocd: src/target: replace the GPL-2.0-or-later license tag 2022-07-23 13:58:51 +00:00
arc_cmd.c openocd: fix SPDX tag format for files .c 2022-09-18 08:22:01 +00:00
arc_cmd.h openocd: src: fix incorrect SPDX tags 2022-07-23 13:16:09 +00:00
arc_jtag.c openocd: fix SPDX tag format for files .c 2022-09-18 08:22:01 +00:00
arc_jtag.h openocd: src: fix incorrect SPDX tags 2022-07-23 13:16:09 +00:00
arc_mem.c openocd: fix SPDX tag format for files .c 2022-09-18 08:22:01 +00:00
arc_mem.h openocd: src: fix incorrect SPDX tags 2022-07-23 13:16:09 +00:00
arc.c openocd: fix SPDX tag format for files .c 2022-09-18 08:22:01 +00:00
arc.h target: consolidate existing target/algo common_magic 2022-08-14 12:02:38 +00:00
arm7_9_common.c openocd: fix SPDX tag format for files .c 2022-09-18 08:22:01 +00:00
arm7_9_common.h target: consolidate existing target/algo common_magic 2022-08-14 12:02:38 +00:00
arm7tdmi.c openocd: fix SPDX tag format for files .c 2022-09-18 08:22:01 +00:00
arm7tdmi.h openocd: src/target: replace the GPL-2.0-or-later license tag 2022-07-23 13:58:51 +00:00
arm9tdmi.c openocd: fix SPDX tag format for files .c 2022-09-18 08:22:01 +00:00
arm9tdmi.h openocd: src/target: replace the GPL-2.0-or-later license tag 2022-07-23 13:58:51 +00:00
arm11_dbgtap.c openocd: fix SPDX tag format for files .c 2022-09-18 08:22:01 +00:00
arm11_dbgtap.h openocd: src/target: replace the GPL-2.0-or-later license tag 2022-07-23 13:58:51 +00:00
arm11.c openocd: fix SPDX tag format for files .c 2022-09-18 08:22:01 +00:00
arm11.h openocd: src/target: replace the GPL-2.0-or-later license tag 2022-07-23 13:58:51 +00:00
arm720t.c openocd: fix SPDX tag format for files .c 2022-09-18 08:22:01 +00:00
arm720t.h target: consolidate existing target/algo common_magic 2022-08-14 12:02:38 +00:00
arm920t.c openocd: fix SPDX tag format for files .c 2022-09-18 08:22:01 +00:00
arm920t.h target: consolidate existing target/algo common_magic 2022-08-14 12:02:38 +00:00
arm926ejs.c openocd: fix SPDX tag format for files .c 2022-09-18 08:22:01 +00:00
arm926ejs.h target: consolidate existing target/algo common_magic 2022-08-14 12:02:38 +00:00
arm946e.c openocd: fix SPDX tag format for files .c 2022-09-18 08:22:01 +00:00
arm946e.h target: don't export local symbols 2022-09-13 22:13:58 +00:00
arm966e.c openocd: fix SPDX tag format for files .c 2022-09-18 08:22:01 +00:00
arm966e.h target: consolidate existing target/algo common_magic 2022-08-14 12:02:38 +00:00
arm_adi_v5.c target/adiv5: 64-bit TAR setup bugfix 2022-10-08 07:55:35 +00:00
arm_adi_v5.h arm_adi_v5: Adding Nuvoton NPCX quirk 2022-07-30 08:49:47 +00:00
arm_coresight.h arm_adi_v5: replace dap_lookup_cs_component() 2022-05-14 08:55:52 +00:00
arm_cti.c openocd: fix SPDX tag format for files .c 2022-09-18 08:22:01 +00:00
arm_cti.h openocd: src/target: replace the GPL-2.0-or-later license tag 2022-07-23 13:58:51 +00:00
arm_dap.c openocd: fix SPDX tag format for files .c 2022-09-18 08:22:01 +00:00
arm_disassembler.c openocd: fix SPDX tag format for files .c 2022-09-18 08:22:01 +00:00
arm_disassembler.h openocd: src/target: replace the GPL-2.0-or-later license tag 2022-07-23 13:58:51 +00:00
arm_dpm.c openocd: fix SPDX tag format for files .c 2022-09-18 08:22:01 +00:00
arm_dpm.h openocd: src/target: replace the GPL-2.0-or-later license tag 2022-07-23 13:58:51 +00:00
arm_jtag.c openocd: fix SPDX tag format for files .c 2022-09-18 08:22:01 +00:00
arm_jtag.h openocd: src/target: replace the GPL-2.0-or-later license tag 2022-07-23 13:58:51 +00:00
arm_opcodes.h openocd: src/target: replace the GPL-2.0-or-later license tag 2022-07-23 13:58:51 +00:00
arm_semihosting.c openocd: fix SPDX tag format for files .c 2022-09-18 08:22:01 +00:00
arm_semihosting.h openocd: src/target: replace the GPL-2.0-or-later license tag 2022-07-23 13:58:51 +00:00
arm_simulator.c openocd: fix SPDX tag format for files .c 2022-09-18 08:22:01 +00:00
arm_simulator.h openocd: src/target: replace the GPL-2.0-or-later license tag 2022-07-23 13:58:51 +00:00
arm_tpiu_swo.c openocd: fix SPDX tag format for files .c 2022-09-18 08:22:01 +00:00
arm_tpiu_swo.h
arm.h target: don't export local symbols 2022-09-13 22:13:58 +00:00
armv4_5_cache.c openocd: fix SPDX tag format for files .c 2022-09-18 08:22:01 +00:00
armv4_5_cache.h openocd: src/target: replace the GPL-2.0-or-later license tag 2022-07-23 13:58:51 +00:00
armv4_5_mmu.c openocd: fix SPDX tag format for files .c 2022-09-18 08:22:01 +00:00
armv4_5_mmu.h openocd: src/target: replace the GPL-2.0-or-later license tag 2022-07-23 13:58:51 +00:00
armv4_5.c openocd: fix SPDX tag format for files .c 2022-09-18 08:22:01 +00:00
armv4_5.h openocd: src/target: replace the GPL-2.0-or-later license tag 2022-07-23 13:58:51 +00:00
armv7a_cache_l2x.c openocd: fix SPDX tag format for files .c 2022-09-18 08:22:01 +00:00
armv7a_cache_l2x.h openocd: src/target: replace the GPL-2.0-or-later license tag 2022-07-23 13:58:51 +00:00
armv7a_cache.c openocd: fix SPDX tag format for files .c 2022-09-18 08:22:01 +00:00
armv7a_cache.h openocd: src/target: replace the GPL-2.0-or-later license tag 2022-07-23 13:58:51 +00:00
armv7a_mmu.c openocd: fix SPDX tag format for files .c 2022-09-18 08:22:01 +00:00
armv7a_mmu.h openocd: src/target: replace the GPL-2.0-or-later license tag 2022-07-23 13:58:51 +00:00
armv7a.c openocd: fix SPDX tag format for files .c 2022-09-18 08:22:01 +00:00
armv7a.h target: consolidate existing target/algo common_magic 2022-08-14 12:02:38 +00:00
armv7m_trace.c openocd: fix SPDX tag format for files .c 2022-09-18 08:22:01 +00:00
armv7m_trace.h openocd: src/target: replace the GPL-2.0-or-later license tag 2022-07-23 13:58:51 +00:00
armv7m.c target/armv7m: fix feature name of ARMv8M security extension regs 2022-11-15 21:39:19 +00:00
armv7m.h openocd: remove CamelCase symbols *xPSR* 2022-09-13 22:03:02 +00:00
armv8_cache.c openocd: fix SPDX tag format for files .c 2022-09-18 08:22:01 +00:00
armv8_cache.h openocd: src/target: replace the GPL-2.0-or-later license tag 2022-07-23 13:58:51 +00:00
armv8_dpm.c openocd: fix SPDX tag format for files .c 2022-09-18 08:22:01 +00:00
armv8_dpm.h openocd: src: replace the incomplete GPL-2.0-or-later license tag 2022-07-23 13:15:24 +00:00
armv8_opcodes.c openocd: fix SPDX tag format for files .c 2022-09-18 08:22:01 +00:00
armv8_opcodes.h openocd: remove CamelCase symbols *xPSR* 2022-09-13 22:03:02 +00:00
armv8.c openocd: fix SPDX tag format for files .c 2022-09-18 08:22:01 +00:00
armv8.h openocd: remove CamelCase symbols *xPSR* 2022-09-13 22:03:02 +00:00
avr32_ap7k.c openocd: fix SPDX tag format for files .c 2022-09-18 08:22:01 +00:00
avr32_ap7k.h target: consolidate existing target/algo common_magic 2022-08-14 12:02:38 +00:00
avr32_jtag.c openocd: fix SPDX tag format for files .c 2022-09-18 08:22:01 +00:00
avr32_jtag.h openocd: src/target: replace the GPL-2.0-or-later license tag 2022-07-23 13:58:51 +00:00
avr32_mem.c openocd: fix SPDX tag format for files .c 2022-09-18 08:22:01 +00:00
avr32_mem.h openocd: src/target: replace the GPL-2.0-or-later license tag 2022-07-23 13:58:51 +00:00
avr32_regs.c openocd: fix SPDX tag format for files .c 2022-09-18 08:22:01 +00:00
avr32_regs.h openocd: src/target: replace the GPL-2.0-or-later license tag 2022-07-23 13:58:51 +00:00
avrt.c openocd: fix SPDX tag format for files .c 2022-09-18 08:22:01 +00:00
avrt.h openocd: src/target: replace the GPL-2.0-or-later license tag 2022-07-23 13:58:51 +00:00
breakpoints.c openocd: fix SPDX tag format for files .c 2022-09-18 08:22:01 +00:00
breakpoints.h openocd: src/target: replace the GPL-2.0-or-later license tag 2022-07-23 13:58:51 +00:00
cortex_a.c target: cortex_a: fix clang error core.CallAndMessage 2022-12-17 09:31:29 +00:00
cortex_a.h target: move parent target structs just after common_magic 2022-08-14 12:10:14 +00:00
cortex_m.c cortex_m: handle armv8m cores without security extension 2022-12-18 21:52:41 +00:00
cortex_m.h cortex_m: handle armv8m cores without security extension 2022-12-18 21:52:41 +00:00
dsp563xx_once.c openocd: fix SPDX tag format for files .c 2022-09-18 08:22:01 +00:00
dsp563xx_once.h openocd: src/target: replace the GPL-2.0-or-later license tag 2022-07-23 13:58:51 +00:00
dsp563xx.c target/dsp563xx: fix scan-build warning 2022-09-23 21:22:09 +00:00
dsp563xx.h openocd: src/target: replace the GPL-2.0-or-later license tag 2022-07-23 13:58:51 +00:00
dsp5680xx.c dsp5680xx: fix clang error core.UndefinedBinaryOperatorResult 2022-11-11 20:11:22 +00:00
dsp5680xx.h target: don't export local symbols 2022-09-13 22:13:58 +00:00
embeddedice.c openocd: fix SPDX tag format for files .c 2022-09-18 08:22:01 +00:00
embeddedice.h openocd: src/target: replace the GPL-2.0-or-later license tag 2022-07-23 13:58:51 +00:00
esirisc_jtag.c esirisc_jtag: fix clang error core.VLASize 2022-11-11 20:11:03 +00:00
esirisc_jtag.h openocd: src/target: replace the GPL-2.0-or-later license tag 2022-07-23 13:58:51 +00:00
esirisc_regs.h openocd: src/target: replace the GPL-2.0-or-later license tag 2022-07-23 13:58:51 +00:00
esirisc_trace.c openocd: fix SPDX tag format for files .c 2022-09-18 08:22:01 +00:00
esirisc_trace.h openocd: src/target: replace the GPL-2.0-or-later license tag 2022-07-23 13:58:51 +00:00
esirisc.c openocd: fix SPDX tag format for files .c 2022-09-18 08:22:01 +00:00
esirisc.h openocd: src/target: replace the GPL-2.0-or-later license tag 2022-07-23 13:58:51 +00:00
etb.c openocd: fix SPDX tag format for files .c 2022-09-18 08:22:01 +00:00
etb.h openocd: src/target: replace the GPL-2.0-or-later license tag 2022-07-23 13:58:51 +00:00
etm_dummy.c openocd: fix SPDX tag format for files .c 2022-09-18 08:22:01 +00:00
etm_dummy.h openocd: src/target: replace the GPL-2.0-or-later license tag 2022-07-23 13:58:51 +00:00
etm.c openocd: fix SPDX tag format for files .c 2022-09-18 08:22:01 +00:00
etm.h openocd: src/target: replace the GPL-2.0-or-later license tag 2022-07-23 13:58:51 +00:00
fa526.c openocd: fix SPDX tag format for files .c 2022-09-18 08:22:01 +00:00
feroceon.c openocd: fix SPDX tag format for files .c 2022-09-18 08:22:01 +00:00
hla_target.c target/hla_target: try to re-examine under reset in hl_assert_reset() 2022-10-08 08:52:45 +00:00
image.c openocd: fix SPDX tag format for files .c 2022-09-18 08:22:01 +00:00
image.h openocd: src/target: replace the GPL-2.0-or-later license tag 2022-07-23 13:58:51 +00:00
lakemont.c openocd: fix SPDX tag format for files .c 2022-09-18 08:22:01 +00:00
lakemont.h openocd: src/target: replace the GPL-2.0-or-later license tag 2022-07-23 13:58:51 +00:00
ls1_sap.c openocd: fix SPDX tag format for files .c 2022-09-18 08:22:01 +00:00
Makefile.am openocd: build: add SPDX tag 2022-07-23 13:06:38 +00:00
mem_ap.c arm_adi_v5: fix SIGSEGV due to failing re-examine 2022-12-17 09:30:45 +00:00
mips32_dmaacc.c openocd: fix SPDX tag format for files .c 2022-09-18 08:22:01 +00:00
mips32_dmaacc.h openocd: src/target: replace the GPL-2.0-or-later license tag 2022-07-23 13:58:51 +00:00
mips32_pracc.c openocd: fix SPDX tag format for files .c 2022-09-18 08:22:01 +00:00
mips32_pracc.h target: don't export local symbols 2022-09-13 22:13:58 +00:00
mips32.c openocd: fix SPDX tag format for files .c 2022-09-18 08:22:01 +00:00
mips32.h target: consolidate existing target/algo common_magic 2022-08-14 12:02:38 +00:00
mips64_pracc.c openocd: fix SPDX tag format for files .c 2022-09-18 08:22:01 +00:00
mips64_pracc.h
mips64.c openocd: fix SPDX tag format for files .c 2022-09-18 08:22:01 +00:00
mips64.h target: consolidate existing target/algo common_magic 2022-08-14 12:02:38 +00:00
mips_ejtag.c openocd: fix SPDX tag format for files .c 2022-09-18 08:22:01 +00:00
mips_ejtag.h openocd: src/target: replace the GPL-2.0-or-later license tag 2022-07-23 13:58:51 +00:00
mips_m4k.c src/target/mips_m4k.c: set missing flag in set_watchpoint 2022-12-17 09:29:32 +00:00
mips_m4k.h target: don't export local symbols 2022-09-13 22:13:58 +00:00
mips_mips64.c openocd: fix SPDX tag format for files .c 2022-09-18 08:22:01 +00:00
mips_mips64.h target: consolidate existing target/algo common_magic 2022-08-14 12:02:38 +00:00
nds32_aice.c openocd: fix SPDX tag format for files .c 2022-09-18 08:22:01 +00:00
nds32_aice.h openocd: src/target: replace the GPL-2.0-or-later license tag 2022-07-23 13:58:51 +00:00
nds32_cmd.c openocd: fix SPDX tag format for files .c 2022-09-18 08:22:01 +00:00
nds32_cmd.h openocd: src/target: replace the GPL-2.0-or-later license tag 2022-07-23 13:58:51 +00:00
nds32_disassembler.c openocd: fix SPDX tag format for files .c 2022-09-18 08:22:01 +00:00
nds32_disassembler.h openocd: src/target: replace the GPL-2.0-or-later license tag 2022-07-23 13:58:51 +00:00
nds32_edm.h openocd: src/target: replace the GPL-2.0-or-later license tag 2022-07-23 13:58:51 +00:00
nds32_insn.h openocd: src/target: replace the GPL-2.0-or-later license tag 2022-07-23 13:58:51 +00:00
nds32_reg.c openocd: fix SPDX tag format for files .c 2022-09-18 08:22:01 +00:00
nds32_reg.h openocd: src/target: replace the GPL-2.0-or-later license tag 2022-07-23 13:58:51 +00:00
nds32_tlb.c openocd: fix SPDX tag format for files .c 2022-09-18 08:22:01 +00:00
nds32_tlb.h openocd: src/target: replace the GPL-2.0-or-later license tag 2022-07-23 13:58:51 +00:00
nds32_v2.c openocd: fix SPDX tag format for files .c 2022-09-18 08:22:01 +00:00
nds32_v2.h openocd: src/target: replace the GPL-2.0-or-later license tag 2022-07-23 13:58:51 +00:00
nds32_v3_common.c openocd: fix SPDX tag format for files .c 2022-09-18 08:22:01 +00:00
nds32_v3_common.h openocd: src/target: replace the GPL-2.0-or-later license tag 2022-07-23 13:58:51 +00:00
nds32_v3.c openocd: fix SPDX tag format for files .c 2022-09-18 08:22:01 +00:00
nds32_v3.h openocd: src/target: replace the GPL-2.0-or-later license tag 2022-07-23 13:58:51 +00:00
nds32_v3m.c openocd: fix SPDX tag format for files .c 2022-09-18 08:22:01 +00:00
nds32_v3m.h openocd: src/target: replace the GPL-2.0-or-later license tag 2022-07-23 13:58:51 +00:00
nds32.c openocd: fix SPDX tag format for files .c 2022-09-18 08:22:01 +00:00
nds32.h target: consolidate existing target/algo common_magic 2022-08-14 12:02:38 +00:00
quark_d20xx.c openocd: fix SPDX tag format for files .c 2022-09-18 08:22:01 +00:00
quark_x10xx.c openocd: fix SPDX tag format for files .c 2022-09-18 08:22:01 +00:00
register.c openocd: fix SPDX tag format for files .c 2022-09-18 08:22:01 +00:00
register.h openocd: src/target: replace the GPL-2.0-or-later license tag 2022-07-23 13:58:51 +00:00
rtt.c rtt: fix corner-cases of finding control block 2023-01-11 17:02:25 +00:00
rtt.h openocd: src/target: replace the GPL-2.0-or-later license tag 2022-07-23 13:58:51 +00:00
semihosting_common.c openocd: fix SPDX tag format for files .c 2022-09-18 08:22:01 +00:00
semihosting_common.h openocd: remove recently added CamelCase symbols 2022-09-13 22:02:33 +00:00
smp.c openocd: fix SPDX tag format for files .c 2022-09-18 08:22:01 +00:00
smp.h openocd: src/target: replace the GPL-2.0-or-later license tag 2022-07-23 13:58:51 +00:00
startup.tcl target: re-examine before arp_waitstate in ocd_process_reset_inner 2022-10-08 08:53:51 +00:00
stm8.c openocd: fix SPDX tag format for files .c 2022-09-18 08:22:01 +00:00
stm8.h target: consolidate existing target/algo common_magic 2022-08-14 12:02:38 +00:00
target_request.c openocd: fix SPDX tag format for files .c 2022-09-18 08:22:01 +00:00
target_request.h openocd: src/target: replace the GPL-2.0-or-later license tag 2022-07-23 13:58:51 +00:00
target_type.h gdb_server: custom target-specific GDB queries 2022-08-15 13:23:05 +00:00
target.c target: fix assert in 'monitor profile' on constant PC 2022-12-17 09:32:34 +00:00
target.h openocd: remove recently added CamelCase symbols 2022-09-13 22:02:33 +00:00
testee.c openocd: fix SPDX tag format for files .c 2022-09-18 08:22:01 +00:00
trace.c openocd: fix SPDX tag format for files .c 2022-09-18 08:22:01 +00:00
trace.h openocd: src/target: replace the GPL-2.0-or-later license tag 2022-07-23 13:58:51 +00:00
x86_32_common.c openocd: fix SPDX tag format for files .c 2022-09-18 08:22:01 +00:00
x86_32_common.h target: consolidate existing target/algo common_magic 2022-08-14 12:02:38 +00:00
xscale.c openocd: fix SPDX tag format for files .c 2022-09-18 08:22:01 +00:00
xscale.h target: consolidate existing target/algo common_magic 2022-08-14 12:02:38 +00:00