This is the mail archive of the systemtap@sourceware.org mailing list for the systemtap project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: How to get write/read offset?


One more think I am curious about:

How can I get a full, non truncated list of all variables I can access
in a tapset? Like traversing everything shown by $$parms$
printf("%s\n", $$parms$)

like:
printf("%s\n", $file->f_inode$)
printf("%s\n", $file->f_inode->f_uid)

because of the string length limitation I can't figure out all vars
stored in $file->f_inode$ for example

I am not very familiar with the syntax :-(

Greetings,
Bjoern


On Thu, Mar 10, 2016 at 8:12 PM, David Smith <dsmith@redhat.com> wrote:
> On 03/10/2016 06:32 AM, Olausson, Bjoern wrote:
>> Hello Systemtap users,
>>
>> is there some straight forward way to get the offset for any read,
>> write, pwrite etc. syscall?
>>
>> So for example if I trace the the IO to a file and the program issues
>> a "seek" and writes reads n bytes starting from this position, is
>> there any way to get that start position (offset) except from probing
>> for an "seek" before a write/read?
>>
>> For example:
>>
>> probe syscall.write.return {
>>  if (pid() == target()) {
>>   time_stamp = timestamp()
>>   p = pid()
>>   fd = $fd
>>   bytes = $return
>>   latency = gettimeofday_us() - @entry(gettimeofday_us())
>>   printf("%d;%d;%s;%s;%d;%d;%d\n", p, fd, filehandles[p, fd], name,
>> bytes, time_stamp, latency)
>>  }
>> }
>>
>> If there is no straight forward way to get this information, what is
>> the most native way to get the offset alongside with the time, latency
>> and bytes_written/read?
>
> To get the file offset, you'll have to probe 1 level down. syscall.read
> (sys_read()) is basically a wrapper around vfs.read (vfs_read()).
> syscall.write (sys_write()) is basically a wrapper around vfs.write
> (vfs_write()).
>
> So, you can (almost) replace syscall.write.return in your example above
> with vfs.write.return. One of the differences are that you don't get $fd
> anymore, instead you get a 'struct file' pointer.
>
>
> --
> David Smith
> dsmith@redhat.com
> Red Hat
> http://www.redhat.com
> 256.217.0141 (direct)
> 256.837.0057 (fax)


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]