diff --git a/observation/src/threadsnoop/threadsnoop.c b/observation/src/threadsnoop/threadsnoop.c new file mode 100644 index 0000000000000000000000000000000000000000..dd8970f3ef34ebf2714825918be33e5bad48a13b --- /dev/null +++ b/observation/src/threadsnoop/threadsnoop.c @@ -0,0 +1,56 @@ +// SPDX-License-Identifier: (LGPL-2.1 OR BSD-2-Clause) +#include "commons.h" +#include "threadsnoop.h" +#include "threadsnoop.skel.h" +#include "compat.h" +#include "trace_helpers.h" +#include "uprobe_helpers.h" + +static volatile sig_atomic_t exiting; +static bool verbose = false; + +const char *argp_program_version = "threadsnoop 0.1"; +const char *argp_program_bug_address = "Jackie Liu "; +const char argp_program_doc[] = +"List new thread creation.\n" +"\n" +"USAGE: threadsnoop [-v]\n"; + +static const struct argp_option opts[] = { + { "verbose", 'v', NULL, 0, "Verbose debug output" }, + { NULL, 'h', NULL, OPTION_HIDDEN, "Show the full help" }, + {} +}; + +static error_t parse_arg(int key, char *arg, struct argp_state *state) +{ + switch (key) { + case 'h': + argp_state_help(state, stderr, ARGP_HELP_STD_HELP); + break; + case 'v': + verbose = true; + break; + default: + return ARGP_ERR_UNKNOWN; + } + + return 0; +} + +int main(int argc, char *argv[]) +{ + struct syms_cache *syms_cache = NULL; + static const struct argp argp = { + .options = opts, + .parser = parse_arg, + .doc = argp_program_doc, + }; + int err; + + err = argp_parse(&argp, argc, argv, 0, NULL, NULL); + if (err) + return err; + +return err != 0; +}