public inbox for overseers@sourceware.org
 help / color / mirror / Atom feed
* Bug 27927 - gdb crash with OpenOCD
@ 2022-06-27 10:50 Robert Jenssen
  2022-06-29 13:11 ` Mark Wielaard
  0 siblings, 1 reply; 2+ messages in thread
From: Robert Jenssen @ 2022-06-27 10:50 UTC (permalink / raw)
  To: overseers

Hi,

I would like to add a comment to Bug#27927 but require a login to do so.

I have been experimenting with a "Poor Man's Profiler" with
openocd-0.11.0, a local build of arm-none-eabi-gdb-12.1 and an
STM32F3Discovery evaluation board. See:
https://poormansprofiler.org
https://interrupt.memfault.com/blog/profiling-firmware-on-cortex-m



arm-none-eabi-gdb was built as follows:
$ arm-none-eabi-gdb --configuration 
This GDB was configured as follows:
   configure --host=x86_64-pc-linux-gnu --target=arm-none-eabi
	     --with-auto-load-dir=$debugdir:$datadir/auto-load
	     --with-auto-load-safe-path=$debugdir:$datadir/auto-load
	     --with-expat
	     --with-gdb-datadir=/usr/local/arm-toolchain/share/gdb
(relocatable) --with-jit-reader-dir=/usr/local/arm-toolchain/lib/gdb
(relocatable) --without-libunwind-ia64
	     --with-lzma
	     --without-babeltrace
	     --with-intel-pt
	     --with-mpfr
	     --without-xxhash
	     --with-python=/usr
	     --with-python-libdir=/usr/lib
	     --with-debuginfod
	     --without-guile
	     --disable-source-highlight
	     --with-separate-debug-dir=/usr/local/arm-toolchain/lib/debug
(relocatable)

("Relocatable" means the directory can be moved with the GDB
installation tree, and GDB will still find it.)



OpenOCD was run as follows:
openocd -c "source [find board/stm32f3discovery.cfg]; \
stm32f3x.cpu configure -rtos auto"



The following shell scrip runs arm-none-eabi-gdb repeatedly:
#!/bin/bash

# See https://poormansprofiler.org/
# Run in another terminal:
# openocd -c "source [find board/stm32f3discovery.cfg];
#             stm32f3x.cpu configure -rtos auto"

nsamples=100
sleeptime=1
elf=bin/imu
for x in $(seq 1 $nsamples); do
    arm-none-eabi-gdb -ex "set pagination off" \
                      -ex "target extended-remote :3333" \
                      -ex "monitor halt" \
                      -ex "thread apply all bt" \
                      -ex "monitor resume" \
                      -batch $elf
    sleep $sleeptime
done | \
awk '
BEGIN { s = ""; }
  /^Thread/ { print s; s = ""; }
  /^#/ {
   a   if (s != "" ) { if ($3 == "in") {  s = s "," $4 } else {  s = s
"," $2 }} else { if ($3 == "in") {  s = $4 } else {  s = $2 } }
  }
END { print s }' | \
sort | uniq -c | sort -r -n -k 1,1



Here is the output from openocd when arm-none-eabi-gdb fails:
.
.
.
Info : accepting 'gdb' connection on tcp/3333
target halted due to debug-request, current mode: Thread 
xPSR: 0x61000000 pc: 0x08013e1c psp: 0x20001a60
Info : dropped 'gdb' connection
Info : accepting 'gdb' connection on tcp/3333
target halted due to debug-request, current mode: Thread 
xPSR: 0x61000000 pc: 0x08013e22 psp: 0x20001a60
Info : dropped 'gdb' connection
Info : accepting 'gdb' connection on tcp/3333
target halted due to debug-request, current mode: Thread 
xPSR: 0x01000000 pc: 0x08014786 psp: 0x20004728
Info : dropped 'gdb' connection
Info : accepting 'gdb' connection on tcp/3333
Info : dropped 'gdb' connection
Info : accepting 'gdb' connection on tcp/3333
Info : dropped 'gdb' connection
Info : accepting 'gdb' connection on tcp/3333
Info : dropped 'gdb' connection
Info : accepting 'gdb' connection on tcp/3333
Info : dropped 'gdb' connection
.
.
.



Before the failure I get messages from arm-none-eabi-gdb like:
warning: multi-threaded target stopped without sending a thread-id,
using first non-exited thread


Here is an example of the repeated output from
arm-none-eabi-gdb after the failure:

doc/poor_mans_profiler.sh: line 11: 159394 Aborted
(core dumped) arm-none-eabi-gdb -ex "set pagination off" -ex "target
extended-remote :3333" -ex "monitor halt" -ex "thread apply all bt" -ex
"monitor resume" -batch $elf ../../gdb-12.1/gdb/thread.c:1328:
internal-error: switch_to_thread: Assertion `thr != NULL' failed. A
problem internal to GDB has been detected, further debugging may prove
unreliable. ----- Backtrace ----- 0x4cd402 gdb_internal_backtrace_1
../../gdb-12.1/gdb/bt-utils.c:122 0x4cd402 _Z22gdb_internal_backtracev
	../../gdb-12.1/gdb/bt-utils.c:168
0x7b6374 internal_vproblem
	../../gdb-12.1/gdb/utils.c:394
0x7b65c8 _Z15internal_verrorPKciS0_P13__va_list_tag
	../../gdb-12.1/gdb/utils.c:471
0x8e9171 _Z14internal_errorPKciS0_z
	../../gdb-12.1/gdbsupport/errors.cc:55
0x776bff _Z16switch_to_threadP11thread_info
	../../gdb-12.1/gdb/thread.c:1328
0x776bff _Z16switch_to_threadP11thread_info
	../../gdb-12.1/gdb/thread.c:1326
0x6f48eb _ZN13remote_target14start_remote_1Eii
	../../gdb-12.1/gdb/remote.c:4938
0x6f4e17 _ZN13remote_target12start_remoteEii
	../../gdb-12.1/gdb/remote.c:5050
0x6f4e17 _ZN13remote_target6open_1EPKcii
	../../gdb-12.1/gdb/remote.c:5856
0x772780 open_target
	../../gdb-12.1/gdb/target.c:853
0x4fe1f4 _Z8cmd_funcP16cmd_list_elementPKci
	../../gdb-12.1/gdb/cli/cli-decode.c:2514
0x77e0da _Z15execute_commandPKci
	../../gdb-12.1/gdb/top.c:702
0x638f21 catch_command_errors
	../../gdb-12.1/gdb/main.c:523
0x638fef execute_cmdargs
	../../gdb-12.1/gdb/main.c:618
0x63ad6c captured_main_1
	../../gdb-12.1/gdb/main.c:1320
0x63b7da captured_main
	../../gdb-12.1/gdb/main.c:1341
0x63b7da _Z8gdb_mainP18captured_main_args
	../../gdb-12.1/gdb/main.c:1366
0x42f1b4 main
	../../gdb-12.1/gdb/gdb.c:32
---------------------

This is a bug, please report it.  For instructions, see:
<https://www.gnu.org/software/gdb/bugs/>.

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Bug 27927 - gdb crash with OpenOCD
  2022-06-27 10:50 Bug 27927 - gdb crash with OpenOCD Robert Jenssen
@ 2022-06-29 13:11 ` Mark Wielaard
  0 siblings, 0 replies; 2+ messages in thread
From: Mark Wielaard @ 2022-06-29 13:11 UTC (permalink / raw)
  To: Overseers mailing list; +Cc: Robert Jenssen

Hi Robert,

On Mon, 2022-06-27 at 20:50 +1000, Robert Jenssen via Overseers wrote:
> I would like to add a comment to Bug#27927 but require a login to do
> so.

A bugzilla account has been created for you. You should have gotten an
email about it. You can activate your account through the Forgot/Reset
Password link.

Cheers,

Mark

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-06-29 13:11 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-27 10:50 Bug 27927 - gdb crash with OpenOCD Robert Jenssen
2022-06-29 13:11 ` Mark Wielaard

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).