XuNeo opened a new pull request, #14913:
URL: https://github.com/apache/nuttx/pull/14913

   *Note: Please adhere to [Contributing 
Guidelines](https://github.com/apache/nuttx/blob/master/CONTRIBUTING.md).*
   
   ## Summary
   
   This PR includes minor bug fixes to list iterator and introduced more 
powerful iteration commands.
   1. `foreach list` command now can iterate any type of `list`. E.g
   ```
       (gdb) foreach list -n next &g_msgfree
       0: {prev = 0x40286200 <g_msgpool+280>, next = 0x4028628c <g_msgpool+420>}
       1: {prev = 0x40286e30 <g_msgfree>, next = 0x40286318 <g_msgpool+560>}
   
       (gdb) foreach list "(struct list_node *) 0x40286e30"
       0: {prev = 0x40286200 <g_msgpool+280>, next = 0x4028628c <g_msgpool+420>}
       1: {prev = 0x40286e30 <g_msgfree>, next = 0x40286318 <g_msgpool+560>}
   
       (gdb) foreach list g_active_tcp_connections.head -n flink -c "struct 
tcp_conn_s" -m "sconn"
                                                                                
         13:14:07 [1047/1047]
       0 @ *(struct tcp_conn_s *)0x40441510 {
         sconn = {
           node = {
             flink = 0x40441658 <g_tcp_connections+984>,
             blink = 0x0
           },
           list = 0x40443754 <g_cbprealloc+1488>,
           list_tail = 0x40443754 <g_cbprealloc+1488>,
           s_error = 0,
           s_options = 0,
           s_rcvtimeo = 0,
           s_sndtimeo = 0,
           s_boundto = 0 '\000',
           s_flags = 105 'i',
           s_tos = 0 '\000',
           s_ttl = 64 '@'
         },
         u = {
           ipv4 = {
             laddr = 16777343,
             raddr = 16777343
           },
           ipv6 = {
             laddr = {127, 256, 127, 256, 0, 0, 0, 0},
             raddr = {0, 0, 0, 0, 0, 0, 0, 0}
           }
         },
         rcvseq = "h\374\375\064",
         sndseq = "h\374\375\063",
         crefs = 1 '\001',
         domain = 2 '\002',
         sa = 0 '\000',
         sv = 12 '\f',
         rto = 12 '\f',
         tcpstateflags = 4 '\004',
   ```
   Note that https://github.com/apache/nuttx/pull/14912 is needed to fix the 
issue of `container_of`.
   
   2. Added `foreach array`, just like list.
   ```
       E.g.
   
       (gdb) foreach array g_mmheap->mm_nodelist
       0: {preceding = 0, size = 0, pid = 0, seqno = 0, backtrace = {0x0, 0x0, 
0x0, 0x0, 0x0, 0x0, 0x0, 0x0}, flink = 0x41692cb8, blink = 0x0}
       1: {preceding = 0, size = 0, pid = 0, seqno = 0, backtrace = {0x0, 0x0, 
0x0, 0x0, 0x0, 0x0, 0x0, 0x0}, flink = 0x40c378a0, blink = 0x40605f58}
   
       (gdb) foreach array g_mmheap->mm_nodelist -e "flink"
       0: 0x41692cb8
       1: 0x40c378a0
   
   ``` 
   
   ## Impact
   
   No impact.
   
   ## Testing
   
   Tested on qemu
   1. compile
   `tools/configure.sh lm3s6965-ek:qemu-flat`
   
   Make sure `+CONFIG_DEBUG_SYMBOLS_LEVEL="-g3"`
   
   2. Run
   ```
   qemu-system-arm -semihosting \
           -M lm3s6965evb \
           -device loader,file=nuttx.bin,addr=0x00000000 \
           -nic user,id=user0,hostfwd=tcp::10023-:23 \
           -serial mon:stdio -nographic -s
   ```
   
   3. Connect
   ```
   gdb-multiarch nuttx -ex "source tools/gdb/gdbinit.py" -ex "tar rem:1234"
   ```
   
   4. Run the example commands above.
   
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to