Replace readdir_r with readdir
[platform/upstream/ltrace.git] / options.h
1 /*
2  * This file is part of ltrace.
3  * Copyright (C) 2012,2013 Petr Machata, Red Hat Inc.
4  * Copyright (C) 2009,2010 Joe Damato
5  * Copyright (C) 1998,2002,2008 Juan Cespedes
6  * Copyright (C) 2006 Ian Wienand
7  * Copyright (C) 2006 Steve Fink
8  *
9  * This program is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU General Public License as
11  * published by the Free Software Foundation; either version 2 of the
12  * License, or (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful, but
15  * WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17  * General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program; if not, write to the Free Software
21  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
22  * 02110-1301 USA
23  */
24
25 #ifndef OPTIONS_H
26 #define OPTIONS_H
27
28 #include <stdio.h>
29 #include <sys/types.h>
30 #include <sys/time.h>
31
32 #include "forward.h"
33 #include "vect.h"
34
35 struct options_t {
36         int align;      /* -a: default alignment column for results */
37         char * user;    /* -u: username to run command as */
38         int syscalls;   /* -S: display system calls */
39         int demangle;   /* -C: demangle low-level names into user-level names */
40         int indent;     /* -n: indent trace output according to program flow */
41         FILE *output;   /* output to a specific file */
42         int summary;    /* count time, calls, and report a summary on program exit */
43         int debug;      /* debug */
44         size_t arraylen;   /* default maximum # of array elements printed */
45         size_t strlen;     /* default maximum # of bytes printed in strings */
46         int follow;     /* trace child processes */
47         int no_signals; /* don't print signals */
48 #if defined(HAVE_UNWINDER)
49         int bt_depth;    /* how may levels of stack frames to show */
50 #endif /* defined(HAVE_UNWINDER) */
51         struct filter *plt_filter;
52         struct filter *static_filter;
53
54         /* A filter matching library names of libraries, whose
55          * exported symbols we wish to trace.  */
56         struct filter *export_filter;
57
58         int hide_caller; /* Whether caller library should be hidden.  */
59 };
60 extern struct options_t options;
61
62 extern int opt_i;               /* instruction pointer */
63 extern int opt_r;               /* print relative timestamp */
64 extern int opt_t;               /* print absolute timestamp */
65 extern int opt_T;               /* show the time spent inside each call */
66
67 struct opt_p_t {
68         pid_t pid;
69         struct opt_p_t *next;
70 };
71
72 extern struct opt_p_t *opt_p;   /* attach to process with a given pid */
73
74 enum opt_F_kind {
75         OPT_F_UNKNOWN = 0,
76         OPT_F_BROKEN,
77         OPT_F_FILE,
78         OPT_F_DIR,
79 };
80
81 struct opt_F_t {
82         char *pathname;
83         int own_pathname : 1;
84         enum opt_F_kind kind : 2;
85 };
86
87 /* If entry->kind is OPT_F_UNKNOWN, figure out whether it should be
88  * OPT_F_FILE or OPT_F_DIR, cache the result, and return it.  Return
89  * OPT_F_BROKEN on failure.  Error message will have been printed in
90  * that case.  */
91 enum opt_F_kind opt_F_get_kind(struct opt_F_t *entry);
92
93 /* Destroy and release any memory associated with ENTRY (but don't
94  * free ENTRY itself).  */
95 void opt_F_destroy(struct opt_F_t *entry);
96
97 /* PATHS contains colon-separated list of values, akin to enviroment
98  * variables PATH, PYTHONPATH, and others.  No escaping is possible.
99  * The list is split and added to VEC, which shall be a vector
100  * initialized like VECT_INIT(VEC, struct opt_F_t); Returns 0 on
101  * success or a negative value on failure.  */
102 int parse_colon_separated_list(const char *paths, struct vect *vec);
103
104 /* Vector of struct opt_F_t.  */
105 extern struct vect opt_F;
106
107 extern char **process_options(int argc, char **argv);
108
109 #endif /* OPTIONS_H */