Hi all, I redesign all my framework last week because I found it's getting more and more complicated, and It seems we really do not need so much extra extensibility.
For example, the old framework allow us to change the separator of the arguments in syscalls by just modifying one place. In order to achieve this goal, the code becomes really complicated and hard to read. And I think why we need such extensibility? It's almost meaningless to change the separator, we just want to make it support two kind output style, that's enough. There are some other similar over-designed extensibility which contribute to the complicated code. There are mainly 2 ideas in this new framework: 1, reuse the existing code as much as possible; 2, make modifications to the existing code as less as possible; There are mainly 2 situations for output: 1, in sys_* functions for the arguments in syscall; 2, the entering/exiting of a syscall; Here is an example for the 1st situation: void printfd(struct tcb *tcp, int fd) { char path[PATH_MAX + 1]; if (show_fd_path && getfdpath(tcp, fd, path, sizeof(path)) >= 0) - tprintf("%d<%s>", fd, path); + jprintf("[$, $s]", "%d<%s>", fd, path); else tprintf("%d", fd); } The most important functions in the new framework is jprintf() (The first j means ‘json’.) void jprintf(const char *json_fmt, const char *fmt, ...) The first argument only have effects when option ‘-j’ is enabled and the ‘$’ sign in the string will be replaced by the corresponding format specifying string in the second argument, and ‘$s’ will be replaced in a double quote. The jprintf() in printfd(), when ‘-j’ is passed to strace, in fact work like: tprintf("[$d, \"%s\"]", fd, path); The jprintf() will ignore the first argument and work like the old tprintf() when ‘-j’ option is not specified by the user. We can then only replace those tprintf() which indeed need be replaced, and keep the tprintf() which would work in both normal and JSON output style. The code would be much more clean after these modifications. I'm working hard these days to modify the existing code (the new framework in fact make it easy to finish such modifications), and I will post more and detail descriptions, examples and test results for this design this week. Thank you. --- YangMin ------------------------------------------------------------------------------ Infragistics Professional Build stunning WinForms apps today! Reboot your WinForms applications with our WinForms controls. Build a bridge from your legacy apps to the future. http://pubads.g.doubleclick.net/gampad/clk?id=153845071&iu=/4140/ostg.clktrk _______________________________________________ Strace-devel mailing list Strace-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/strace-devel