简体   繁体   English

C ++获取函数读取的字节数

[英]C++ Getting number of bytes read by a function

Is there a way to get number of bytes read by the function ? 有没有办法获取该函数读取的字节数?

Using function **getrusage** I can get the count of 使用函数**getrusage**我可以得到

 ru_inblock;       /* block input operations */

But how to get number of bytes read by function ? 但是如何获得函数读取的字节数呢?

You can't. 你不能 You will need to preload your own SO that overrides read(2) which calls it and counts how many bytes are actually read. 您将需要预加载自己的SO,该SO将覆盖read(2)并调用它,并计算实际读取的字节数。

Use strace(1) or a debugger. 使用strace(1)或调试器。 You will have to postprocess the output a bit, but all the information about the data transferred by syscalls is there. 您将不得不对输出进行一点后处理,但是有关syscall传输的数据的所有信息都已存在。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM