X-Git-Url: https://git.cworth.org/git?a=blobdiff_plain;f=retrace.cpp;h=07ee5b56b5dc98936be7b4f80ed3befdb6963ff3;hb=c592957de1083b4e32ee58c0ea2e5feaa9085b47;hp=e5089a72f52829bb371bebf224e3041bad42fe6b;hpb=32871ed473727ee7628bda7cad6a9e4130d0374a;p=apitrace diff --git a/retrace.cpp b/retrace.cpp index e5089a7..07ee5b5 100644 --- a/retrace.cpp +++ b/retrace.cpp @@ -24,6 +24,9 @@ **************************************************************************/ +#include +#include + #include "retrace.hpp" @@ -33,4 +36,30 @@ namespace retrace { int verbosity = 0; +void ignore(Trace::Call &call) { + (void)call; +} + +void retrace_unknown(Trace::Call &call) { + if (verbosity >= 0) { + std::cerr << call.no << ": warning: unknown call " << call.name() << "\n"; + } +} + +void dispatch(Trace::Call &call, const Entry *entries, unsigned num_entries) +{ + /* TODO: do a bisection instead of a linear search */ + + const char *name = call.name(); + for (unsigned i = 0; i < num_entries; ++i) { + if (strcmp(name, entries[i].name) == 0) { + entries[i].callback(call); + return; + } + } + + retrace_unknown(call); +} + + } /* namespace retrace */