libclues
Linux C++ Tracing Library
Loading...
Searching...
No Matches
Args.cxx
1#include "Args.hxx"
2
3namespace clues {
4
5Args::Args() :
6 m_abi_constraint{getABIs()},
7 cmdline{"Command line process tracer.\nTo use clues as a front-end pass the command line to execute after '--'", ' ', "0.1"},
8 attach_proc{
9 "p", "process",
10 "attach to the given already running process for tracing.",
11 false,
12 cosmos::to_integral(cosmos::ProcessID::INVALID),
13 "Process ID"},
14 follow_execve{
15 "", "follow-execve",
16 "What to do upon execve() in a tracee: 'yes' (continue tracing; default), 'no' (detach from tracee), 'ask' (interactively ask what to do), 'path:<path>' (continue if new executable matches path), 'glob:<pattern>' (continue if new executable matches glob pattern).",
17 false,
18 "",
19 "configuration string"
20 },
21 follow_children{
22 "", "follow-children",
23 "What to do upon new child processes appearing via [v]fork() or clone(): 'yes' (automatically attach), 'no' (ignore; default), 'ask' (interactively ask what to do), 'threads' (only follow threads of the same process).",
24 false,
25 "",
26 "configuration string"
27 },
28 follow_threads{
29 "", "threads",
30 "follow/attach all threads within the process. Do not follow fork(). synonym for '--follow-children threads'.",
31 false},
32 // TODO: it seems we need a better command line parsing library to
33 // handle this in a more traditional manner
34 follow_children_switch{
35 "f", "follow",
36 "synonym for '--follow-children yes'.",
37 false},
38 no_initial_threads_attach{
39 "1", "no-initial-threads-attach",
40 "when attaching to a running process, don't attach all of the process's threads, only the one specified via -p, even if --follow-children is set.",
41 false},
42 print_fd_info{
43 "", "fd-info",
44 "Print detailed information about file descriptors (e.g. type, path, etc.)",
45 false},
46 verbose{
47 "v", "verbose",
48 "increase verbosity of tracing output",
49 false},
50 max_value_len{
51 "s", "max-len",
52 "maximum length of parameter values to print. 0 to to print not at all, -1 to disable truncation.",
53 false,
54 64,
55 "number of bytes"},
56 list_syscalls{
57 "", "list-syscalls",
58 "list all known system calls names, then exit.",
59 false},
60 list_abi_syscalls{
61 "", "list-abi-syscalls",
62 "list all system calls names and their numbers for the given system call ABI.",
63 false,
64 "",
65 &m_abi_constraint
66 },
67 list_abis{
68 "", "list-abis",
69 "list the names of system call ABIs supported on this system.",
70 false
71 },
72 syscall_filter{
73 "e", "filter",
74 "configuration of system call filters. comma separated list of system call names, optionally prefixed with '!' to negate the meaning.",
75 false,
76 "",
77 "comma separated list of system call names"} {
78
79 cmdline.add(attach_proc);
80 cmdline.add(follow_execve);
81 cmdline.add(follow_children);
82 cmdline.add(follow_threads);
83 cmdline.add(follow_children_switch);
84 cmdline.add(no_initial_threads_attach);
85 cmdline.add(print_fd_info);
86 cmdline.add(verbose);
87 cmdline.add(max_value_len);
88 cmdline.add(list_syscalls);
89 cmdline.add(list_abi_syscalls);
90 cmdline.add(list_abis);
91 cmdline.add(syscall_filter);
92}
93
94std::vector<std::string> Args::getABIs() {
95 return std::vector<std::string>{
96 "i386", "x86-64", "x32", "aarch64"
97 };
98}
99
100} // end ns