From: Philippe O. <pom...@ne...> - 2014-02-09 22:15:16
|
On Fri, Feb 7, 2014 at 1:36 AM, Dmitry V. Levin <ld...@al...> wrote: > On Thu, Feb 06, 2014 at 03:41:54PM +0100, Philippe Ombredanne wrote: [...] >> As a first step I think the best would be to come with a few mock >> samples of json output. -- Philippe Ombredanne > > I wonder how printxval and printflags would look like. > For example, what would be a json-like equivalent for this traditional output: > > $ printf '#include <sys/socket.h>\nint main(){return socket(AF_INET,-1,0xffff)<0;}' |gcc -Wall -xc - > $ strace -esocket ./a.out > socket(PF_INET, SOCK_CLOEXEC|SOCK_NONBLOCK|0xfff7f7ff, 0xffff /* IPPROTO_??? */) = -1 EINVAL (Invalid argument) > +++ exited with 1 +++ We would need something of a record type, as a line can be a call proper or a SIG* or +++ or (else?). For this example say we have type c: syscall, type x: process exit. Return would be a map. Args could be a list of [value, message]. To cover more ground it may need to be a map in the end. Note that for now, I do not care yet about having a compact representation, but rather expressive and easy to parse one. We could use positional lists rather than maps for more compact output. So this could look like this: [ {"type": "c", "call": "socket", "return": {"success": false, "code": "-1", "errno": "EINVAL", "message": "Invalid argument"}, "args": [ [ "PF_INET", "" ], [ "SOCK_CLOEXEC|SOCK_NONBLOCK|0xfff7f7ff", ""], [ "0xfff", "IPPROTO_???"] ] }, {"type": "x", "return": {"success": false, "code": "1"} } ] -- Philippe Ombredanne |