首页 > 解决方案 > strace 没有显示完整的写入

问题描述

我试图查看正在使用 strace 写入 HTTP 套接字的数据然而,虽然我已经给出了 -e write=all,但我仍然看不到正在写入的所有数据

strace -o /tmp/capture.log -p <pid> -e trace=all -e write=all -e read=all -f -tt
 ..
 29620 16:09:14.723120 write(1899, "POST /task/native.wsdl HTTP/1.1\r"..., 210) = 210
 29620 16:09:14.723319 write(1899, "<soap:Envelope xmlns:soap=\"http:"..., 450) = 450

奇怪的是,它显示了在其他一些套接字写入期间的完整数据

31145 16:09:28.110571 write(359, "POST /task/native.wsdl HTTP/1.1\r"..., 210) = 210
 | 00000  50 4f 53 54 20 2f 74 61  73 6b 2f 6e 61 74 69 76  POST /task/nativ |
 | 00010  65 2e 77 73 64 6c 20 48  54 54 50 2f 31 2e 31 0d  e.wsdl HTTP/1.1. |
 | 00020  0a 43 6f 6e 74 65 6e 74  2d 54 79 70 65 3a 20 74  .Content-Type: t |
 | 00030  65 78 74 2f 78 6d 6c 3b  20 63 68 61 72 73 65 74  ext/xml; charset |
 | 00040  3d 55 54 46 2d 38 0d 0a  41 63 63 65 70 74 3a 20  =UTF-8..Accept:  |
 | 00050  2a 2f 2a 0d 0a 53 4f 41  50 41 63 74 69 6f 6e 3a  */*..SOAPAction: |
 | 00060  20 22 22 0d 0a 55 73 65  72 2d 41 67 65 6e 74 3a   ""..User-Agent: |
 | 00070  20 41 70 61 63 68 65 20  43 58 46 20 32 2e 37 2e   Apache CXF 2.7. |
 | 00080  31 31 0d 0a 48 6f 73 74  3a 20 65 73 2d 73 76 63  11..Host: es-svc |
 | 00090  73 2e 69 74 2e 61 74 74  2e 63 6f 6d 3a 37 30 30  s.it.att.com:700 |
 | 000a0  33 0d 0a 43 6f 6e 6e 65  63 74 69 6f 6e 3a 20 4b  3..Connection: K |
 | 000b0  65 65 70 2d 41 6c 69 76  65 0d 0a 43 6f 6e 74 65  eep-Alive..Conte |
 | 000c0  6e 74 2d 4c 65 6e 67 74  68 3a 20 34 35 30 0d 0a  nt-Length: 450.. |
 | 000d0  0d 0a                                             ..               |

有人可以解释一下。是否可以从所有写入中获取数据

标签: linuxstrace

解决方案


strace-e write=a,b标志显示从 a 到 b 编号的文件描述符的-e write=all写入系统调用,并显示对所有文件描述符的写入系统调用。你正在寻找的是-e abbrev=none; 参见手册页:

-e abbrev=set
    Abbreviate  the  output from printing each member of large structures.  
    The default is abbrev=all.  The -v option has the effect of abbrev=none.

推荐阅读