Commit graph

57039 commits

Author SHA1 Message Date
xuxingliang
8b4a4f8539 tools/gdb: add get_task_tls and get_thread_tls
Signed-off-by: rongyichang <rongyichang@xiaomi.com>
2024-11-23 13:09:16 +08:00
xuxingliang
5d86bee5c7 tools/gdb: add diagnose commands
Run diagnostic related commands anytime to generate report.

E.g `diag report -o systemreport.json`

Signed-off-by: xuxingliang <xuxingliang@xiaomi.com>
2024-11-23 13:09:16 +08:00
xuxingliang
a2da6b94f0 tools/gdb: add foreach prefixed command
Signed-off-by: xuxingliang <xuxingliang@xiaomi.com>
2024-11-23 13:09:16 +08:00
xuxingliang
04b35a2e8f tools/gdb: add pyproject.toml to build as a package
Now the GDB tool can be built with python -m build . to generate a
package.

Signed-off-by: xuxingliang <xuxingliang@xiaomi.com>
2024-11-23 13:09:16 +08:00
xuxingliang
5a82e21edb tools/gdb: use iterator for list
Signed-off-by: xuxingliang <xuxingliang@xiaomi.com>
2024-11-23 13:09:16 +08:00
xuxingliang
e7c2e7c576 tools/gdb: use remote-register standard
GDB uses remote-register to describe g/G packet. Whatever the target is,
we can always find out the register offset in packet by `maint print
remote-registers`.

In NuttX, we follow the same standard to prepare the packet, in both
coredump and GDB stub.

For example, the CPSR for arm-v7a is at register number of 25, byte
offset of 164. So we define the CPSR in g_reg_offs (164 /4 = 41)th
elementent.

If GDB stub supports qXfer feature, then GDB will ask stub for target
descriptor, which is a standard xml file. If this file is provided, then
the register order is also changed. It's also reflected in 'maint print
remote-registers' output. JLink GDB server supports it for example.

We always use manually added second inferiort to query the original
remote register layout. So it can match with tcbinfo.

Signed-off-by: xuxingliang <xuxingliang@xiaomi.com>
2024-11-23 13:09:16 +08:00
xuxingliang
68d47ee847 tools/gdb: init superclass in python3 code style
Signed-off-by: xuxingliang <xuxingliang@xiaomi.com>
2024-11-23 13:09:16 +08:00
xuxingliang
74bac56539 tools/gdb: fix regression on older version of GDB
Signed-off-by: xuxingliang <xuxingliang@xiaomi.com>
2024-11-23 13:09:16 +08:00
xuxingliang
94a2ce3641 tools/gdb: need to switch back to inferior 1
After check version using inferior 2, need to switch back for normal operation

Signed-off-by: xuxingliang <xuxingliang@xiaomi.com>
2024-11-23 13:09:16 +08:00
anjiahao
5f34b44fca gdb python:support check elf version
Signed-off-by: anjiahao <anjiahao@xiaomi.com>
2024-11-23 13:09:16 +08:00
anjiahao
92d79d5e71 utils.py:add profile command to profile python command
Signed-off-by: anjiahao <anjiahao@xiaomi.com>
2024-11-23 13:09:16 +08:00
anjiahao
160f61cd4d memdump.py:add some error info to mmforeach and try dump mempool frist
Signed-off-by: anjiahao <anjiahao@xiaomi.com>
2024-11-23 13:09:16 +08:00
anjiahao
8adbf6c504 gdb/memdump:fixed the problem of inaccurate statistics
Signed-off-by: anjiahao <anjiahao@xiaomi.com>
2024-11-23 13:09:16 +08:00
xuxingliang
75c1b26cbc tools/gdb: accept expression or value for arguments
Signed-off-by: xuxingliang <xuxingliang@xiaomi.com>
2024-11-23 13:09:16 +08:00
anjiahao
0f0fefb942 gdb:add dmesg command show ramlog buffer data as syslog
Signed-off-by: anjiahao <anjiahao@xiaomi.com>
2024-11-23 13:09:16 +08:00
xuxingliang
cbf778cb60 tools/gdb: add addr2line tool
Usage: addr2line address1 address2 expression1
Example: addr2line 0x1234 0x5678
         addr2line "0x1234 + pointer->abc" &var var->field function_name var
         addr2line $pc $r1 "$r2 + var"
         addr2line [24/08/29 20:51:02] [CPU1] [209] [ap] sched_dumpstack: backtrace| 0: 0x402cd484 0x4028357e

Signed-off-by: xuxingliang <xuxingliang@xiaomi.com>
2024-11-23 13:09:16 +08:00
xuxingliang
1a934a4da0 tools/gdb: fix older version gdb compatibility issue
Prebuilt arm-none-eabi-gdb may have not socket module available.

Signed-off-by: xuxingliang <xuxingliang@xiaomi.com>
2024-11-23 13:09:16 +08:00
xuxingliang
58cd81ea46 tools/gdb: register NuttX commands when loading the first elf file
Make sure elf exists before registering our commands. If no elf at the moment, register event to GDB to get notified when user adds the first object file.

Signed-off-by: xuxingliang <xuxingliang@xiaomi.com>
2024-11-23 13:09:16 +08:00
xuxingliang
444396ee37 tools/gdb: use os.system to call readelf
Some version of gdb does not support subprocess

Signed-off-by: xuxingliang <xuxingliang@xiaomi.com>
2024-11-23 13:09:16 +08:00
xuxingliang
d15540a836 tools/gdb: add deadlock detect tool
Signed-off-by: xuxingliang <xuxingliang@xiaomi.com>
2024-11-23 13:09:16 +08:00
xuxingliang
7b43cf5221 tools/gdb: make entry for list iteration optional
Signed-off-by: xuxingliang <xuxingliang@xiaomi.com>
2024-11-23 13:09:16 +08:00
buxiasen
3f3bbf76f9 tool/gdb/memdump: fix orphan, fix -p support
Signed-off-by: buxiasen <buxiasen@xiaomi.com>
2024-11-23 13:09:16 +08:00
xuxingliang
796806c65b tools/gdb: allow to use info nxthreads
(gdb) info threads
  Id   Target Id         Frame
* 1.1  Thread 1 (Name: CPU0 IDLE, State: 3, Pri: 0, Stack: 41eccfec, Size: 3976)                       0x402cd586 in up_idle () at chip/r528_idle.c:80
  1.2  Thread 2 (Name: CPU1 IDLE, State: 4, Pri: 0, Stack: 4194bb78, Size: 3976)                       0x402cd586 in up_idle () at chip/r528_idle.c:80

(gdb) info nxthreads
Index Tid  Pid  Cpu  Thread                Info                                                                             Frame
 0    0    0    0 '\000' Thread 0x419633b8     (Name: CPU0 IDLE, State: Assigned, Priority: 0, Stack: 3976) 0x402cd586  up_idle() at chip/r528_idle.c:80
*1    1    1    1 '\001' Thread 0x41963498     (Name: CPU1 IDLE, State: Running, Priority: 0, Stack: 3976)  0x402cd586  up_idle() at chip/r528_idle.c:80
(gdb)

Signed-off-by: xuxingliang <xuxingliang@xiaomi.com>
2024-11-23 13:09:16 +08:00
anjiahao
db1e97405a thread.py: fix bug that ARM-A TCB info register[2]
Signed-off-by: anjiahao <anjiahao@xiaomi.com>
2024-11-23 13:09:16 +08:00
Gao Jiawei
b5e7f8a40f trvial adjustment on get_arch_(sp|pc)_name()
Signed-off-by: Gao Jiawei <gaojiawei@xiaomi.com>
2024-11-23 13:09:16 +08:00
Gao Jiawei
1b5b882e53 improve sanity checking when constructing the stack object
Signed-off-by: Gao Jiawei <gaojiawei@xiaomi.com>
2024-11-23 13:09:16 +08:00
Gao Jiawei
fa8aff6d9b regression: use stack TLS region to retrieve task argument vector
ta_argv is removed, we use pointer to the TLS instead

Signed-off-by: Gao Jiawei <gaojiawei@xiaomi.com>
2024-11-23 13:09:16 +08:00
xuxingliang
7daecfb10c tools/gdb: fallback to parse elf to get macro
For LTO optimization, we may not be able to parse the macro value. Parse .debug_macro section from elf manually.

Signed-off-by: xuxingliang <xuxingliang@xiaomi.com>
2024-11-23 13:09:16 +08:00
hujun5
fccd908114 arch/arm64: syscall SYS_switch_context and SYS_restore_context use 0 para
reason:
simplify context switch
sys_call0(SYS_switch_context)
sys_call0(SYS_restore_context)

Signed-off-by: hujun5 <hujun5@xiaomi.com>
2024-11-23 12:22:21 +08:00
hujun5
f4d212fd6d arm64: remove up_set_current_regs/up_current_regs
reason:
up_set_current_regs initially had two functions:

1: To mark the entry into an interrupt state.
2: To record the context before an interrupt/exception. If we switch to
a new task, we need to store the upcoming context regs by calling up_set_current_regs(regs).

Currently, we record the context in other ways, so the second function is obsolete. Therefore,
we need to rename up_set_current_regs to better reflect its actual meaning, which is solely to mark an interrupt.

Signed-off-by: hujun5 <hujun5@xiaomi.com>
2024-11-23 02:05:56 +02:00
xuxin19
cfe78ad74e cmake(enhance):enhance NuttX cmake target dependencies and link_library modules
Enhance CMake's add_dependencies for Nuttx so that
different targets can call dependencies without errors when they are not traversed.

In addition, since we do not call link_library directly,
we increment nuttx_link_library to inherit the PUBLIC property

Signed-off-by: xuxin19 <xuxin19@xiaomi.com>
2024-11-22 15:16:07 -03:00
simbit18
a1cbed020a build.yml: MSYS2 GitHub Action disable ccache
You need to disable the msys2 cache from the GitHub action because we moved the Scheduled Merge Jobs to a new NuttX Mirror Repo and approaching total cache storage limit !!!

https://github.com/apache/nuttx/actions/caches

https://github.com/msys2/setup-msys2?tab=readme-ov-file#cache
2024-11-23 01:48:24 +08:00
cuiziwei
8e58245524 sim: Fix sim m32 start up crash issue.
After compilation, when starting nsh, the following crash occurs.
==2500151==Shadow memory range interleaves with an existing memory mapping. ASan cannot proceed correctly. ABORTING.
==2500151==ASan shadow was supposed to be located in the [0x1ffff000-0x3fffffff] range.
==2500151==Process memory map follows:
0x30000000-0x33dd4000 /nuttx/nuttx

To avoid overlaps, change the starting address of the text segment.

Using Ttext-segment=0x30000000 causes a crash when starting the 32-bit SIM.
Using -Ttext-segment=0x50000000 causes a crash when starting the 64-bit SIM.
Setting -Ttext-segment=0x40000000 resolves all issues perfectly.

Signed-off-by: cuiziwei <cuiziwei@xiaomi.com>
2024-11-23 01:47:34 +08:00
wangjianyu3
2d20de72be Documentation/esp32s3-devkit: Add doc for USB ADB
Signed-off-by: wangjianyu3 <wangjianyu3@xiaomi.com>
2024-11-22 13:28:44 -03:00
wangjianyu3
ccefe43149 esp32s3-devkit/adb: Enable ROMFS/etc for ADB auto start
Signed-off-by: wangjianyu3 <wangjianyu3@xiaomi.com>
2024-11-22 13:28:44 -03:00
wangjianyu3
9e08bb2d25 esp32s3-devkit: Add initialize scripts for ROMFS/etc
Signed-off-by: wangjianyu3 <wangjianyu3@xiaomi.com>
2024-11-22 13:28:44 -03:00
wangjianyu3
385de9d850 esp32s3-devkit/adb: Reusing configuration of usb_device
Signed-off-by: wangjianyu3 <wangjianyu3@xiaomi.com>
2024-11-22 13:28:44 -03:00
wangjianyu3
9a63f9a881 esp32s3-devkit/adb: Initializing configuration for ADB
Build & Flash

  ./tools/configure.sh -l esp32s3-devkit:adb
  make -j16
  make flash ESPTOOL_PORT=/dev/ttyACMx

Runtime

  $ adb -s 1234 shell
  nsh> uname -a
  NuttX 0.0.0  Nov 22 2024 11:41:43 xtensa esp32s3-devkit

Signed-off-by: wangjianyu3 <wangjianyu3@xiaomi.com>
2024-11-22 13:28:44 -03:00
YAMAMOTO Takashi
72a8764ea8 fs/littlefs: Add a kconfig to override littlefs version
Hopefully, It's more user-friendly than the current method,
which is just an overridable make variable. It would also help
to make some features (and their associated local patches)
conditional on littlefs version in future.

Also, update CMakeLists.txt to use the same littlefs version as Makefile.
2024-11-22 21:02:54 +08:00
yinshengkai
0413d74f31 libs: add gcov framework support
In devices without storage media, you can export data to the
command line and then generate the corresponding gcda file

It can save the result output by calling __gcov_info_to_gcda
The usage is similar to:
https://gcc.gnu.org/onlinedocs/gcc/Freestanding-Environments.html#Profiling-and-Test-Coverage-in-Freestanding-Environments

Usage:
 ./tools/configure.sh qemu-armv7a:nsh
Modify the configuration
+CONFIG_COVERAGE_ALL=y
+CONFIG_COVERAGE_MINI=y
+CONFIG_SYSTEM_GCOV=y
Run:
qemu-system-arm -cpu cortex-a7 -nographic -smp 4 \
     -machine virt,virtualization=off,gic-version=2 \
     -net none -chardev stdio,id=con,mux=on -serial chardev:con \
     -mon chardev=con,mode=readline -kernel ./nuttx/nuttx -semihosting -s | tee gcov.txt
./nuttx/tools/gcov_convert.py -i ./gcov.txt
./nuttx/tools/gcov.sh -t arm-none-eabi-gcov

Signed-off-by: yinshengkai <yinshengkai@xiaomi.com>
2024-11-22 19:08:08 +08:00
yinshengkai
0194c2f88a gcov: update gcov compilation parameters
profile-generate is used to generate compilation feedback optimization data, not just code coverage data

It will rely on the toolchain library:
nuttx/libs/libc/misc/lib_utsname.c:94:(.text.uname+0x2c): undefined reference to `__gcov_indirect_call_profiler_v4'
arm-none-eabi-ld: nuttx/libs/libc/misc/lib_utsname.c:113:(.text.uname+0x178): undefined reference to `__gcov_indirect_call'
arm-none-eabi-ld: nuttx/libs/libc/misc/lib_utsname.c:113:(.text.uname+0x188): undefined reference to `__gcov_time_profiler_counter'
arm-none-eabi-ld: nuttx/staging/libc.a(lib_utsname.o):(.data..LPBX0+0x30): undefined reference to `__gcov_merge_time_profile'

Signed-off-by: yinshengkai <yinshengkai@xiaomi.com>
2024-11-22 19:08:08 +08:00
Jouni Ukkonen
74cdb53027 tools/imx9: Add norimage support to bootloader
Fetch fspi header and fcb generation script,
using mkimage generate nor bootable image.
compile bootloader using -mstrict-align

Signed-off-by: Jouni Ukkonen <jouni.ukkonen@unikie.com>
2024-11-22 18:53:21 +08:00
wangmingrong1
1f2d1e97e8 x86-64: Added KASan compilation options
Sorry for this commit: 6cd43777c3
This is the real x86-64 modification, and this patch is x86
Fortunately, except for the error in the previous modification, the actual architecture is supported

Signed-off-by: wangmingrong1 <wangmingrong1@xiaomi.com>
2024-11-22 15:06:02 +08:00
Zhe Weng
5ec2c97424 tools/gdb: Supports args and help for netstats
(gdb) help netstats
Network statistics
    Usage: netstats [iob|pkt|tcp|udp|all]

    Examples: netstats - Show all stats
              netstats all - Show all stats
              netstats iob - Show IOB stats
              netstats tcp udp - Show both TCP and UDP stats

(gdb) netstats iob pkt
IOB:       size    ntotal     nfree     nwait nthrottle
           1518        72        72         0        40

Packets:   IPv4   IPv6    TCP    UDP   ICMP ICMPv6
Received     12     20      2     10      0      0
Dropped       0     20      0      0      0      0
  VHL         0      0      -      -      -      -
  Frag        0      0      -      -      -      -
  Chksum      0      -      0      0      -      -
  Type        -      -      -      -      0      0
  Proto       0      0      -      -      -      -
Sent          4      0      4      0      0      0
  Rexmit      -      -      2      -      -      -

Signed-off-by: Zhe Weng <wengzhe@xiaomi.com>
2024-11-22 13:38:23 +08:00
Zhe Weng
d0884828ed tools/gdb: Add TCP in netstats
(gdb) netstats
IOB:       size    ntotal     nfree     nwait nthrottle
           1518        72        70         0        38
<...>
TCP Conn:  st flg ref tmr uack nrt       txbuf       rxbuf+ofo           local_address        remote_address
0           4  61   1   3    0   0     0/16384    28/16384+0            10.0.1.2:11315        10.0.1.1:5001

Signed-off-by: Zhe Weng <wengzhe@xiaomi.com>
2024-11-22 13:38:23 +08:00
Zhe Weng
395090284a tools/gdb: Add UDP in netstats
(gdb) netstats
IOB:       size    ntotal     nfree     nwait nthrottle
           1518        72        70         0        38
<...>
UDP Conn:  flg       txbuf       rxbuf         local_address        remote_address
0           41     0/16384     0/16384              :::19279         fc00::1:5001
1           41     0/16384     0/16384              :::19280         fc00::1:5001
2           41     0/16384     0/16384              :::19281         fc00::1:5001
3           41     0/16384     0/16384              :::19282         fc00::1:5001
4           41     0/16384     0/16384              :::19283         fc00::1:5001
5           41     0/16384     0/16384         0.0.0.0:19284        10.0.1.1:5001
6           41     0/16384     0/16384         0.0.0.0:19285        10.0.1.1:5001
7           41     0/16384     0/16384         0.0.0.0:19286        10.0.1.1:5001
8           41     0/16384     0/16384         0.0.0.0:19287        10.0.1.1:5001
9           41     0/16384     0/16384         0.0.0.0:19288        10.0.1.1:5001

Signed-off-by: Zhe Weng <wengzhe@xiaomi.com>
2024-11-22 13:38:23 +08:00
Zhe Weng
1c884ee230 tools/gdb: Add packet statistic in netstats
Unlike NuttX's one, we use decimal instead of hexadecimal, because other
stats may all use decimal.

(gdb) netstats
IOB:       size    ntotal     nfree     nwait nthrottle
           1518        72        72         0        40

Packets:   IPv4   IPv6    TCP    UDP   ICMP ICMPv6
Received    137     43      0     49     88      0
Dropped       0     43      0      0     74      0
  VHL         0      0      -      -      -      -
  Frag        0      0      -      -      -      -
  Chksum      0      -      0      0      -      -
  Type        -      -      -      -     74      0
  Proto       0      0      -      -      -      -
Sent      11481  11542      0  17223     27      4
  Rexmit      -      -      0      -      -      -

Signed-off-by: Zhe Weng <wengzhe@xiaomi.com>
2024-11-22 13:38:23 +08:00
Zhe Weng
4ff0447027 tools/gdb: Add net.py and netstats command
Only support IOB stats now, may add socket status later.

(gdb) netstats
IOB:       size    ntotal     nfree     nwait nthrottle
           1518        72        72         0        40

Signed-off-by: Zhe Weng <wengzhe@xiaomi.com>
2024-11-22 13:38:23 +08:00
c0669e3fc9 CI: Run CI Job other only for Simple x86 PR
Presently, Simple x86 PRs will run All CI Checks (across all Architectures), as reported here: https://github.com/apache/nuttx/pull/14885#issuecomment-2492555557

This PR fixes the CI Build Rules, so that Simple x86 PRs will run only One Single CI Job: `other`.
2024-11-22 13:32:33 +08:00
xuxingliang
992d5e0127 tools/gdb: add info shm command
(gdb) info shm
  /var/shm/xms:bq-325-1044165565 memsize: 1536000, paddr: 0x41de3970
  /var/shm/xms:bq-325-2123092606 memsize: 1536000, paddr: 0x41f5a9a8
  /var/shm/xms:fakemq-325-1835096569 memsize: 12, paddr: 0x420d19e0
(gdb)

Signed-off-by: xuxingliang <xuxingliang@xiaomi.com>
2024-11-22 12:30:12 +08:00