X-Git-Url: https://git.cworth.org/git?a=blobdiff_plain;f=common%2Ftrace_parser.cpp;h=c70517e2461658cf18e8e6ca30c0d50b83c49c74;hb=656e70fcb18b2579e98ec3f4e6a55a89a9772b74;hp=f3aea7e7cf482f26f69e74432691bcefbb75ab1c;hpb=9db16b3989481f8d6dfc8932d760fcc16217ecbd;p=apitrace diff --git a/common/trace_parser.cpp b/common/trace_parser.cpp index f3aea7e..c70517e 100644 --- a/common/trace_parser.cpp +++ b/common/trace_parser.cpp @@ -30,6 +30,7 @@ #include #include "trace_file.hpp" +#include "trace_dump.hpp" #include "trace_parser.hpp" @@ -176,12 +177,21 @@ Call *Parser::parse_call(Mode mode) { int c = read_byte(); switch (c) { case trace::EVENT_ENTER: +#if TRACE_VERBOSE + std::cerr << "\tENTER\n"; +#endif parse_enter(mode); break; case trace::EVENT_LEAVE: +#if TRACE_VERBOSE + std::cerr << "\tLEAVE\n"; +#endif call = parse_leave(mode); - adjust_call_flags(call); - return call; + if (call) { + adjust_call_flags(call); + return call; + } + break; default: std::cerr << "error: unknown event " << c << "\n"; exit(1); @@ -449,6 +459,14 @@ Call *Parser::parse_leave(Mode mode) { } } if (!call) { + /* This might happen on random access, when an asynchronous call is stranded + * between two frames. We won't return this call, but we still need to skip + * over its data. + */ + const FunctionSig sig = {0, NULL, 0, NULL}; + call = new Call(&sig, 0, 0); + parse_call_details(call, SCAN); + delete call; return NULL; } @@ -466,11 +484,20 @@ bool Parser::parse_call_details(Call *call, Mode mode) { int c = read_byte(); switch (c) { case trace::CALL_END: +#if TRACE_VERBOSE + std::cerr << "\tCALL_END\n"; +#endif return true; case trace::CALL_ARG: +#if TRACE_VERBOSE + std::cerr << "\tCALL_ARG\n"; +#endif parse_arg(call, mode); break; case trace::CALL_RET: +#if TRACE_VERBOSE + std::cerr << "\tCALL_RET\n"; +#endif call->ret = parse_value(mode); break; default: @@ -570,7 +597,9 @@ Value *Parser::parse_value(void) { } #if TRACE_VERBOSE if (value) { - std::cerr << "\tVALUE " << value << "\n"; + std::cerr << "\tVALUE "; + trace::dump(value, std::cerr); + std::cerr << "\n"; } #endif return value;