Vivek Goel
Vivek Goel

Reputation: 24160

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

 ru_inblock;       /* block input operations */

But how to get number of bytes read by function ?

Upvotes: 0

Views: 120

Answers (2)

fork0
fork0

Reputation: 3459

Use strace(1) or a debugger. You will have to postprocess the output a bit, but all the information about the data transferred by syscalls is there.

Upvotes: 0

Ignacio Vazquez-Abrams
Ignacio Vazquez-Abrams

Reputation: 799580

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.

Upvotes: 1

Related Questions