mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-21 05:13:34 +08:00
NuttX debug helper improvements
- use NuttX gdb script for nxthreads and thread backtrace - update jlink_gdb_backtrace and jlink_debug_gdb helper targets to use NuttX gdb script - Debug/PX4 fix "perf" divide by zero - Debug/PX4 add "dmesg"
This commit is contained in:
@@ -11,6 +11,9 @@ end
|
||||
document px4
|
||||
. Various macros for working with the PX4 firmware.
|
||||
.
|
||||
. dmesg
|
||||
. Prints the dmesg output (if available).
|
||||
.
|
||||
. perf
|
||||
. Prints the state of all performance counters.
|
||||
.
|
||||
@@ -18,6 +21,22 @@ document px4
|
||||
end
|
||||
|
||||
|
||||
define dmesg
|
||||
if g_console_buffer
|
||||
printf "PX4 dmesg:\n"
|
||||
# TODO: respect head and tail
|
||||
printf "%s\n", g_console_buffer._buffer
|
||||
else
|
||||
printf "PX4 dmesg unavailable\n"
|
||||
end
|
||||
end
|
||||
|
||||
document dmesg
|
||||
. dmesg
|
||||
. Prints dmesg (if available).
|
||||
end
|
||||
|
||||
|
||||
define _perf_print
|
||||
set $hdr = (struct perf_ctr_header *)$arg0
|
||||
#printf "%p\n", $hdr
|
||||
@@ -35,7 +54,11 @@ define _perf_print
|
||||
# PC_INTERVAL
|
||||
if $hdr->type == 2
|
||||
set $interval = (struct perf_ctr_interval *)$hdr
|
||||
printf "%llu events, %llu avg, min %lluus max %lluus\n", $interval->event_count, ($interval->time_last - $interval->time_first) / $interval->event_count, $interval->time_least, $interval->time_most
|
||||
if $interval->event_count == 0
|
||||
printf "%llu events, %llu avg, min %lluus max %lluus\n", $interval->event_count, 0, $interval->time_least, $interval->time_most
|
||||
else
|
||||
printf "%llu events, %llu avg, min %lluus max %lluus\n", $interval->event_count, ($interval->time_last - $interval->time_first) / $interval->event_count, $interval->time_least, $interval->time_most
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -1,9 +1,23 @@
|
||||
#! /bin/sh
|
||||
|
||||
if command -v gdb-multiarch &> /dev/null
|
||||
then
|
||||
GDB_CMD=$(command -v gdb-multiarch)
|
||||
|
||||
elif command -v arm-none-eabi-gdb &> /dev/null
|
||||
then
|
||||
GDB_CMD=$(command -v arm-none-eabi-gdb)
|
||||
|
||||
else
|
||||
echo "gdb arm-none-eabi or multi-arch not found"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
@JLinkGDBServerExe_PATH@ -device @DEBUG_DEVICE@ -select usb -endian little -if SWD -speed auto -ir -LocalhostOnly 1 -strict -vd -singlerun &
|
||||
|
||||
cd @PX4_BINARY_DIR@ && @CMAKE_GDB@ -silent -nh \
|
||||
cd @PX4_BINARY_DIR@ && ${GDB_CMD} -silent -nh \
|
||||
-iex "set auto-load safe-path @PX4_BINARY_DIR@" \
|
||||
-ix=@PX4_SOURCE_DIR@/platforms/nuttx/NuttX/nuttx/tools/nuttx-gdbinit \
|
||||
-ex "target remote localhost:2331" \
|
||||
-ex "monitor reset 0" \
|
||||
-ex "load" \
|
||||
|
||||
@@ -19,23 +19,31 @@ gdb_cmd_file=$(mktemp)
|
||||
|
||||
cat >"${gdb_cmd_file}" <<EOL
|
||||
|
||||
source ${WORKSPACE}/platforms/nuttx/Debug/NuttX
|
||||
source ${WORKSPACE}/platforms/nuttx/Debug/ARMv7M
|
||||
source ${WORKSPACE}/platforms/nuttx/Debug/NuttX
|
||||
source ${WORKSPACE}/platforms/nuttx/Debug/PX4
|
||||
|
||||
set mem inaccessible-by-default off
|
||||
set print pretty
|
||||
set pagination off
|
||||
|
||||
target remote localhost:2331
|
||||
|
||||
monitor regs
|
||||
|
||||
dmesg
|
||||
|
||||
perf
|
||||
|
||||
showtasks
|
||||
backtrace
|
||||
|
||||
vecstate
|
||||
|
||||
info threads
|
||||
info_nxthreads
|
||||
|
||||
backtrace
|
||||
|
||||
bt full
|
||||
nxthread_all_bt
|
||||
|
||||
EOL
|
||||
|
||||
${GDB_CMD} -silent --nh --nx --nw -batch -x ${gdb_cmd_file} ${1}
|
||||
${GDB_CMD} -silent --nh --nx --nw -batch -ix=${WORKSPACE}/platforms/nuttx/NuttX/nuttx/tools/nuttx-gdbinit -x ${gdb_cmd_file} ${1}
|
||||
|
||||
+49
@@ -0,0 +1,49 @@
|
||||
#! /bin/sh
|
||||
|
||||
if command -v gdb-multiarch &> /dev/null
|
||||
then
|
||||
GDB_CMD=$(command -v gdb-multiarch)
|
||||
|
||||
elif command -v arm-none-eabi-gdb &> /dev/null
|
||||
then
|
||||
GDB_CMD=$(command -v arm-none-eabi-gdb)
|
||||
|
||||
else
|
||||
echo "gdb arm-none-eabi or multi-arch not found"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
file ${1}
|
||||
|
||||
gdb_cmd_file=$(mktemp)
|
||||
|
||||
cat >"${gdb_cmd_file}" <<EOL
|
||||
|
||||
source ${WORKSPACE}/platforms/nuttx/Debug/ARMv7M
|
||||
source ${WORKSPACE}/platforms/nuttx/Debug/NuttX
|
||||
source ${WORKSPACE}/platforms/nuttx/Debug/PX4
|
||||
|
||||
set mem inaccessible-by-default off
|
||||
set print pretty
|
||||
set pagination off
|
||||
|
||||
target remote localhost:2331
|
||||
|
||||
monitor regs
|
||||
|
||||
dmesg
|
||||
|
||||
perf
|
||||
|
||||
showtasks
|
||||
backtrace
|
||||
|
||||
vecstate
|
||||
|
||||
info threads
|
||||
|
||||
bt full
|
||||
|
||||
EOL
|
||||
|
||||
${GDB_CMD} -silent --nh --nx --nw -batch -x ${gdb_cmd_file} ${1}
|
||||
Reference in New Issue
Block a user