<div dir="ltr">Hi,Thanks So which are the available syscalls for which i can implement the decoders?<br></div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Mar 22, 2017 at 7:12 AM, Eugene Syromyatnikov <span dir="ltr"><<a href="mailto:evgsyr@gmail.com" target="_blank">evgsyr@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">On Sun, Mar 19, 2017 at 01:47:22AM +0530, Rishi Bhatt wrote:<br>
> Hi,<br>
> Well i am currently understanding how to implement a parser,so i am<br>
> starting with the simple ones first i.e umask.c,readahead.c,mount.c.<br>
><br>
> What i know about the implementation of parser:<br>
> What we do in these are use the tcb struct(u_arg[]) to get the values that<br>
> are passed in as arguments,i am not going into that detail for now (or<br>
> should i go?),i guess for now i should just accept it.<br>
</span>You can check trace_syscall_entering() and specifically get_syscall_args()<br>
linux/*/get_syscall_args.c for the code which retrieves data from the tracee in<br>
case you are wondering how it is implemented. Basically, it retrieves<br>
data from registers used for passing function call arguments. For the most<br>
part, they trivially map on function arguments, except some peculiarities like<br>
passing 64-bit argument on 32-bit architectures.<br>
<span class=""><br>
> Now taking an example of a parser lets say mount.c:<br>
> arguments of mount:source,target,<wbr>filesystem,mountflags and data.<br>
><br>
> So if i am implementing a mount parser i have to get the values that is<br>
> being passed in this syscall that i can get from registers(somehow), also<br>
> the return value and error values.<br>
</span>This is done already in the beginning of trace_syscall_{entering,<wbr>exiting}().<br>
<span class=""><br>
> Also we have to consider printing the<br>
> appropriate things with appropriate wrappers like if we are printing source<br>
> and target in mount.c we are using printpath and if address ,it is prinnted<br>
> by printaddr and etc.<br>
</span>Well, this is the current state of things. Printing is handled by<br>
decoders, there are some helpers defined in defs.h/util.c for printing<br>
specific formats, but in most cases it boils down to set of tprintf/tprints with<br>
appropriately casted/processed arguments.<br>
<span class=""><br>
> And we have to first know what can be value of a specific parameter in<br>
> different condition,like in mount.c we are printing "mount_filesystem" as a<br>
> address or as string.(ignore_type)<br>
</span>Yes, this is a part of mount syscall semantics.<br>
<span class=""><br>
> So this should be the info to start implementing a parser?<br>
><br>
> So please fill me up with more detail if i am missing something or i am<br>
> interpreting something in a wrong way,and if possible can you give me some<br>
> small parser related thing to implement so i can understand it better.So i<br>
> can try to start implementing a parser.<br>
<br>
</span>First, which parser you want to implement? Usually it starts with<br>
figuring out the syscall argument semantics and the way arguments are<br>
handled by the kernel—strace tries to show the way kernel sees<br>
arguments, so one (while it uses strace) could try to extrapolate what kernel<br>
would do with them. Once this understanding is obtained, decoder implementation<br>
itself is relatively easy. Other tricky part is figuring out proper test cases<br>
which check whether decoder prints what it is intended to be printed as much as<br>
possible.<br>
<br>
Please, do not hesitate to ask specific questions.<br>
<br>
------------------------------<wbr>------------------------------<wbr>------------------<br>
Check out the vibrant tech community on one of the world's most<br>
engaging tech sites, Slashdot.org! <a href="http://sdm.link/slashdot" rel="noreferrer" target="_blank">http://sdm.link/slashdot</a><br>
______________________________<wbr>_________________<br>
Strace-devel mailing list<br>
<a href="mailto:Strace-devel@lists.sourceforge.net">Strace-devel@lists.<wbr>sourceforge.net</a><br>
<a href="https://lists.sourceforge.net/lists/listinfo/strace-devel" rel="noreferrer" target="_blank">https://lists.sourceforge.net/<wbr>lists/listinfo/strace-devel</a><br>
</blockquote></div><br></div>