Petr Machata | e99af27 | 2012-10-26 00:29:52 +0200 | [diff] [blame] | 1 | /* |
| 2 | * This file is part of ltrace. |
Petr Machata | 8a730f3 | 2013-11-21 20:43:51 +0100 | [diff] [blame] | 3 | * Copyright (C) 2012,2013 Petr Machata, Red Hat Inc. |
Petr Machata | e99af27 | 2012-10-26 00:29:52 +0200 | [diff] [blame] | 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 | */ |
Petr Machata | 395a4e3 | 2013-01-07 18:07:31 +0100 | [diff] [blame] | 24 | #ifndef _OPTIONS_H_ |
| 25 | #define _OPTIONS_H_ |
Petr Machata | e99af27 | 2012-10-26 00:29:52 +0200 | [diff] [blame] | 26 | |
Juan Cespedes | 5e01f65 | 1998-03-08 22:31:44 +0100 | [diff] [blame] | 27 | #include <stdio.h> |
Juan Cespedes | a485083 | 2002-03-03 02:37:50 +0100 | [diff] [blame] | 28 | #include <sys/types.h> |
Petr Machata | 8a9ad08 | 2012-12-04 17:44:55 +0100 | [diff] [blame] | 29 | #include <sys/time.h> |
Juan Cespedes | 5e01f65 | 1998-03-08 22:31:44 +0100 | [diff] [blame] | 30 | |
Petr Machata | 8bd9c19 | 2012-09-25 22:47:42 +0200 | [diff] [blame] | 31 | #include "forward.h" |
Petr Machata | 418584d | 2012-12-04 17:53:56 +0100 | [diff] [blame] | 32 | #include "vect.h" |
Petr Machata | 1e4fed2 | 2012-04-01 00:45:22 +0200 | [diff] [blame] | 33 | |
Juan Cespedes | ce377d5 | 2008-12-16 19:38:10 +0100 | [diff] [blame] | 34 | struct options_t { |
Joe Damato | 59e3fb1 | 2009-11-06 19:45:10 -0800 | [diff] [blame] | 35 | int align; /* -a: default alignment column for results */ |
| 36 | char * user; /* -u: username to run command as */ |
| 37 | int syscalls; /* -S: display system calls */ |
Joe Damato | 59e3fb1 | 2009-11-06 19:45:10 -0800 | [diff] [blame] | 38 | int demangle; /* -C: demangle low-level names into user-level names */ |
| 39 | int indent; /* -n: indent trace output according to program flow */ |
| 40 | FILE *output; /* output to a specific file */ |
| 41 | int summary; /* count time, calls, and report a summary on program exit */ |
| 42 | int debug; /* debug */ |
Zachary T Welch | ba6aca2 | 2010-12-08 18:55:09 -0800 | [diff] [blame] | 43 | size_t arraylen; /* default maximum # of array elements printed */ |
| 44 | size_t strlen; /* default maximum # of bytes printed in strings */ |
Joe Damato | 59e3fb1 | 2009-11-06 19:45:10 -0800 | [diff] [blame] | 45 | int follow; /* trace child processes */ |
Joe Damato | 59e3fb1 | 2009-11-06 19:45:10 -0800 | [diff] [blame] | 46 | int no_signals; /* don't print signals */ |
Mark Wielaard | dfefa9f | 2014-01-07 21:00:44 +0100 | [diff] [blame] | 47 | #if defined(HAVE_UNWINDER) |
Joe Damato | ab3b72c | 2010-10-31 00:21:53 -0700 | [diff] [blame] | 48 | int bt_depth; /* how may levels of stack frames to show */ |
Mark Wielaard | dfefa9f | 2014-01-07 21:00:44 +0100 | [diff] [blame] | 49 | #endif /* defined(HAVE_UNWINDER) */ |
Petr Machata | b5f80ac | 2012-04-04 01:46:18 +0200 | [diff] [blame] | 50 | struct filter *plt_filter; |
Petr Machata | da3edbf | 2012-04-04 02:20:21 +0200 | [diff] [blame] | 51 | struct filter *static_filter; |
Petr Machata | 51e74ac | 2012-09-27 23:43:25 +0200 | [diff] [blame] | 52 | |
| 53 | /* A filter matching library names of libraries, whose |
| 54 | * exported symbols we wish to trace. */ |
| 55 | struct filter *export_filter; |
| 56 | |
Petr Machata | 0367389 | 2012-04-03 13:51:09 +0200 | [diff] [blame] | 57 | int hide_caller; /* Whether caller library should be hidden. */ |
Juan Cespedes | ce377d5 | 2008-12-16 19:38:10 +0100 | [diff] [blame] | 58 | }; |
| 59 | extern struct options_t options; |
| 60 | |
Ian Wienand | 2d45b1a | 2006-02-20 22:48:07 +0100 | [diff] [blame] | 61 | extern int opt_i; /* instruction pointer */ |
Ian Wienand | 2d45b1a | 2006-02-20 22:48:07 +0100 | [diff] [blame] | 62 | extern int opt_r; /* print relative timestamp */ |
| 63 | extern int opt_t; /* print absolute timestamp */ |
Ian Wienand | 2d45b1a | 2006-02-20 22:48:07 +0100 | [diff] [blame] | 64 | extern int opt_T; /* show the time spent inside each call */ |
Juan Cespedes | 5e01f65 | 1998-03-08 22:31:44 +0100 | [diff] [blame] | 65 | |
| 66 | struct opt_p_t { |
| 67 | pid_t pid; |
Ian Wienand | 2d45b1a | 2006-02-20 22:48:07 +0100 | [diff] [blame] | 68 | struct opt_p_t *next; |
Juan Cespedes | 5e01f65 | 1998-03-08 22:31:44 +0100 | [diff] [blame] | 69 | }; |
| 70 | |
Ian Wienand | 2d45b1a | 2006-02-20 22:48:07 +0100 | [diff] [blame] | 71 | extern struct opt_p_t *opt_p; /* attach to process with a given pid */ |
Juan Cespedes | 5e01f65 | 1998-03-08 22:31:44 +0100 | [diff] [blame] | 72 | |
Petr Machata | 418584d | 2012-12-04 17:53:56 +0100 | [diff] [blame] | 73 | enum opt_F_kind { |
| 74 | OPT_F_UNKNOWN = 0, |
| 75 | OPT_F_BROKEN, |
| 76 | OPT_F_FILE, |
| 77 | OPT_F_DIR, |
| 78 | }; |
| 79 | |
| 80 | struct opt_F_t { |
| 81 | char *pathname; |
| 82 | int own_pathname : 1; |
| 83 | enum opt_F_kind kind : 2; |
| 84 | }; |
| 85 | |
| 86 | /* If entry->kind is OPT_F_UNKNOWN, figure out whether it should be |
| 87 | * OPT_F_FILE or OPT_F_DIR, cache the result, and return it. Return |
| 88 | * OPT_F_BROKEN on failure. Error message will have been printed in |
| 89 | * that case. */ |
| 90 | enum opt_F_kind opt_F_get_kind(struct opt_F_t *entry); |
| 91 | |
| 92 | /* Destroy and release any memory associated with ENTRY (but don't |
| 93 | * free ENTRY itself). */ |
| 94 | void opt_F_destroy(struct opt_F_t *entry); |
| 95 | |
| 96 | /* PATHS contains colon-separated list of values, akin to enviroment |
| 97 | * variables PATH, PYTHONPATH, and others. No escaping is possible. |
| 98 | * The list is split and added to VEC, which shall be a vector |
| 99 | * initialized like VECT_INIT(VEC, struct opt_F_t); Returns 0 on |
| 100 | * success or a negative value on failure. */ |
| 101 | int parse_colon_separated_list(const char *paths, struct vect *vec); |
| 102 | |
| 103 | /* Vector of struct opt_F_t. */ |
| 104 | extern struct vect opt_F; |
Steve Fink | 58c73a7 | 2006-07-17 23:18:35 +0200 | [diff] [blame] | 105 | |
Ian Wienand | 2d45b1a | 2006-02-20 22:48:07 +0100 | [diff] [blame] | 106 | extern char **process_options(int argc, char **argv); |
Petr Machata | 395a4e3 | 2013-01-07 18:07:31 +0100 | [diff] [blame] | 107 | |
| 108 | #endif /* _OPTIONS_H_ */ |