You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by GitBox <gi...@apache.org> on 2020/12/21 09:32:01 UTC
[GitHub] [incubator-nuttx] anchao opened a new pull request #2574: libs/libc/dumpbuffer: dump buffer enhancement
anchao opened a new pull request #2574:
URL: https://github.com/apache/incubator-nuttx/pull/2574
## Summary
libs/libc/dumpbuffer: add support to dump the buffer to file descriptor.
libs/libc: add lib_dumpvbuffer support
libs/libc/dumpbuffer: remove the unnecessary printable characters traversal
libs/libc/dumpbuffer: fix nxstyle warning
libs/libc/dumpbuffer: add support to recognizable from wireshark
e.g: Encapsulation Type: Bluetooth H4: add packet type dump support
From:
`lib_dumpvbuffer(NULL, data, len);`
```
[ 2.196000] 0000: 030c00 ...
[ 2.514600] 0000: 0e0401030c00 ......
[ 2.514600] 0000: 031000 ...
[ 2.517600] 0000: 0e0c01031000ffff8ffedbff5b87 ............[.
[ 2.517600] 0000: 011000 ...
[ 2.520600] 0000: 0e0c0101100006bb22060a00bb22 ........"...."
[ 2.520600] 0000: 021000 ...
[ 2.527600] 0000: 0e4401021000ffffff03feffffffffff fffff30fe8fe3ff783ff1c00000061f7 .D.............. ......?.......a.
[ 2.527600] 0020: ffff7f00000000000000000000000000 00000000000000000000000000000000 ................ ................
[ 2.527600] 0040: 000000000000 ......
```
To:
```
struct iovec bufs[2];
bufs[0].iov_base = &type;
bufs[0].iov_len = 1;
bufs[1].iov_base = data;
bufs[1].iov_len = len;
lib_dumpvbuffer(NULL, bufs, 2);
```
```
[ 3.711400] 0000 01 03 0c 00 ....
[ 4.035400] 0000 04 0e 04 01 03 0c 00 .......
[ 4.035400] 0000 01 03 10 00 ....
[ 4.037400] 0000 04 0e 0c 01 03 10 00 ff ff 8f fe db ff 5b 87 .............[.
[ 4.037400] 0000 01 01 10 00 ....
[ 4.039400] 0000 04 0e 0c 01 01 10 00 06 bb 22 06 0a 00 bb 22 ........."...."
[ 4.039400] 0000 01 02 10 00 ....
[ 4.046400] 0000 04 0e 44 01 02 10 00 ff ff ff 03 fe ff ff ff ff ..D.............
[ 4.046400] 0010 ff ff ff f3 0f e8 fe 3f f7 83 ff 1c 00 00 00 61 .......?.......a
[ 4.046400] 0020 f7 ff ff 7f 00 00 00 00 00 00 00 00 00 00 00 00 ................
[ 4.046400] 0030 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
[ 4.046400] 0040 00 00 00 00 00 00 00 .......
```
## Impact
## Testing
```
struct iovec bufs[2];
bufs[0].iov_base = &type;
bufs[0].iov_len = 1;
bufs[1].iov_base = data;
bufs[1].iov_len = len;
int fd;
fd = open("/data/hci.dump", O_RDWR| O_CREAT | O_APPEND, 0777);
if (fd > 0) {
pthread_mutex_lock(&g_mutex);
lib_writevbuffer(fd, NULL, bufs, 2);
pthread_mutex_unlock(&g_mutex);
close(fd);
}
```
```
$ cat hci.dump
0000 01 03 0c 00 ....
0000 04 0e 04 01 03 0c 00 .......
0000 01 03 10 00 ....
0000 04 0e 0c 01 03 10 00 ff ff 8f fe db ff 5b 87 .............[.
0000 01 01 10 00 ....
0000 04 0e 0c 01 01 10 00 06 bb 22 06 0a 00 bb 22 ........."...."
0000 01 02 10 00 ....
0000 04 0e 44 01 02 10 00 ff ff ff 03 fe ff ff ff ff ..D.............
0010 ff ff ff f3 0f e8 fe 3f f7 83 ff 1c 00 00 00 61 .......?.......a
0020 f7 ff ff 7f 00 00 00 00 00 00 00 00 00 00 00 00 ................
0030 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
0040 00 00 00 00 00 00 00 .......
0000 01 18 20 00 .. .
0000 04 0e 0c 01 18 20 00 28 82 d5 c1 83 a8 20 77 ..... .(..... w
0000 01 18 20 00 .. .
0000 04 0e 0c 01 18 20 00 f5 31 c2 34 59 9a 24 02 ..... ..1.4Y.$.
0000 01 18 20 00 .. .
0000 04 0e 0c 01 18 20 00 16 f2 89 c9 7e a5 2d 98 ..... .....~.-.
0000 01 18 20 00 .. .
0000 04 0e 0c 01 18 20 00 55 e4 ca c0 b9 24 a2 17 ..... .U....$..
0000 01 18 20 00 .. .
0000 04 0e 0c 01 18 20 00 af 06 97 87 b2 e2 f8 b6 ..... .........
0000 01 33 0c 07 4a 00 00 06 00 00 00 .3..J......
0000 04 0e 04 01 33 0c 00 ....3..
0000 01 31 0c 01 01 .1...
```
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-nuttx] btashton commented on pull request #2574: libs/libc/dumpbuffer: dump buffer enhancement
Posted by GitBox <gi...@apache.org>.
btashton commented on pull request #2574:
URL: https://github.com/apache/incubator-nuttx/pull/2574#issuecomment-749333515
@anchao since this buffer dumping is used on some of the small targets for debugging I am a little worried about what this does to the code size. Do you think we can keep `lib_dumpbuffer` minimal?
It also seemed like a strange API contract that giving a fd of -1 would call syslog, I see why you did that, but I think it might be best to not to expose that, even if that is in in an internal static function.
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-nuttx] btashton merged pull request #2574: libs/libc/dumpbuffer: dump buffer enhancement
Posted by GitBox <gi...@apache.org>.
btashton merged pull request #2574:
URL: https://github.com/apache/incubator-nuttx/pull/2574
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-nuttx] anchao commented on pull request #2574: libs/libc/dumpbuffer: dump buffer enhancement
Posted by GitBox <gi...@apache.org>.
anchao commented on pull request #2574:
URL: https://github.com/apache/incubator-nuttx/pull/2574#issuecomment-749458345
> @anchao since this buffer dumping is used on some of the small targets for debugging I am a little worried about what this does to the code size. Do you think we can keep `lib_dumpbuffer` minimal?
>
> It also seemed like a strange API contract that giving a fd of -1 would call syslog, I see why you did that, but I think it might be best to not to expose that, even if that is in in an internal static function.
Yes, it seems that the feature of dumping file descriptors increases the code size on some platforms,
I removed the dump file changes and retained the multiple buffers support, from the perspective of code size, 72 bytes increased compared to the original version on the x86_64(GCC 9.0.0):
```
$ size nuttx_modify
text data bss dec hex filename
258575 1240 4480 264295 40867 nuttx
$ size nuttx_origin
text data bss dec hex filename
258503 1240 4480 264223 4081f /home/archer/nuttx_origin
$ bloaty -d symbols nuttx_modify -- ~/nuttx_origin
FILE SIZE VM SIZE
-------------- --------------
[NEW] +724 [NEW] +684 lib_dumpvbuffer
+0.0% +423 [ = ] 0 [section .debug_info]
+0.1% +360 [ = ] 0 [section .debug_line]
+0.1% +242 [ = ] 0 [section .debug_abbrev]
+0.2% +89 [ = ] 0 [section .debug_str]
[NEW] +50 [NEW] +16 tick.3837
+0.2% +48 [ = ] 0 [section .debug_aranges]
[NEW] +42 [NEW] +8 tick.3381
[NEW] +41 [NEW] +1 initialized.3771
[NEW] +41 [NEW] +5 labels.3989
+0.2% +24 [ = ] 0 [section .symtab]
+0.3% +18 [ = ] 0 [section .strtab]
-4.2% -9 -4.2% -9 [section .text]
[DEL] -41 [DEL] -1 initialized.3756
[DEL] -41 [DEL] -5 labels.3974
[DEL] -42 [DEL] -8 tick.3366
[DEL] -50 [DEL] -16 tick.3833
-2.7% -68 [ = ] 0 [Unmapped]
-77.5% -603 -81.6% -603 lib_dumpbuffer
+0.1% +1.22Ki +0.0% +72 TOTAL
```
I don't know if this seems acceptable?
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org