【问题标题】:strace does not show the complete writestrace 没有显示完整的写入
【发布时间】:2020-08-09 06:11:23
【问题描述】:

我正在尝试使用 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                                             ..               |

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

【问题讨论】:

  • 这看起来像一个错误。你有什么版本的 strace?
  • [sa8331@zlpv5940 ~]$ strace -V strace -- version 4.8 [sa8331@zlpv5940 ~]$ cat /etc/redhat-release Red Hat Enterprise Linux Server release 6.10 (Santiago)

标签: linux strace


【解决方案1】:

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.

【讨论】:

  • 但是根据手册页-e write=set Perform a full hexadecimal and ASCII dump of all the data written to file descriptors listed in the specified set. For example, to see all output activity on file descriptors 3 and 5 use -e write=3,5. Note that this is independent from the normal tracing of the write(2) system call which is controlled by the option -e trace=write. 我解释这意味着所有数据都将显示为 -e write=all 除了 anotehr writes() 表明这一点
猜你喜欢
  • 1970-01-01
  • 2017-02-13
  • 2016-08-31
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-01-13
  • 2013-09-20
  • 1970-01-01
相关资源
最近更新 更多