public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
From: "robertjenssen at ozemail dot com.au" <sourceware-bugzilla@sourceware.org>
To: gdb-prs@sourceware.org
Subject: [Bug remote/27927] gdb crash with OpenOCD
Date: Wed, 29 Jun 2022 13:43:47 +0000	[thread overview]
Message-ID: <bug-27927-4717-pfaNbuDqls@http.sourceware.org/bugzilla/> (raw)
In-Reply-To: <bug-27927-4717@http.sourceware.org/bugzilla/>

https://sourceware.org/bugzilla/show_bug.cgi?id=27927

Robert Jenssen <robertjenssen at ozemail dot com.au> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |robertjenssen at ozemail dot com.a
                   |                            |u

--- Comment #13 from Robert Jenssen <robertjenssen at ozemail dot com.au> ---
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


My system is:
$ uname -a
Linux morgawr 5.18.6-200.fc36.x86_64 #1 SMP PREEMPT_DYNAMIC Wed Jun 22 13:46:18
UTC 2022 x86_64 x86_64 x86_64 GNU/Linux


The gdb version is:
$ arm-none-eabi-gdb --version
GNU gdb (GDB) 12.1


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.)


The OpenOCD version is:
$ openocd --version
Open On-Chip Debugger 0.11.0


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/>.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

  parent reply	other threads:[~2022-06-29 13:43 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-28 12:47 [Bug remote/27927] New: " jerome.pouiller at gmail dot com
2021-05-28 12:49 ` [Bug remote/27927] " jerome.pouiller at gmail dot com
2021-05-28 12:52 ` jerome.pouiller at gmail dot com
2021-05-28 13:40 ` simark at simark dot ca
2021-06-01  8:14 ` jerome.pouiller at gmail dot com
2021-06-01  8:21 ` jerome.pouiller at gmail dot com
2021-06-01  8:23 ` jerome.pouiller at gmail dot com
2021-06-01 13:43 ` simark at simark dot ca
2021-06-01 13:44 ` simark at simark dot ca
2021-06-02  6:22 ` alucca388 at gmail dot com
2021-06-02  7:06 ` jerome.pouiller at gmail dot com
2021-06-02  7:26 ` jerome.pouiller at gmail dot com
2021-06-02  7:29 ` jerome.pouiller at gmail dot com
2021-06-02 13:28 ` simark at simark dot ca
2021-11-06  9:04 ` fredrik.hederstierna@securitas-direct.com
2022-06-29 13:43 ` robertjenssen at ozemail dot com.au [this message]
2023-01-17 16:28 ` tromey at sourceware dot org
2023-02-09 14:40 ` jerome.pouiller at gmail dot com
2023-02-09 14:43 ` jerome.pouiller at gmail dot com
2023-02-09 21:45 ` tromey at sourceware dot org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-27927-4717-pfaNbuDqls@http.sourceware.org/bugzilla/ \
    --to=sourceware-bugzilla@sourceware.org \
    --cc=gdb-prs@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).