61
68
Bool VG_(clo_trace_syscalls) = False;
62
69
Bool VG_(clo_trace_signals) = False;
63
70
Bool VG_(clo_trace_symtab) = False;
71
HChar* VG_(clo_trace_symtab_patt) = "*";
64
72
Bool VG_(clo_trace_cfi) = False;
73
Bool VG_(clo_debug_dump_syms) = False;
74
Bool VG_(clo_debug_dump_line) = False;
75
Bool VG_(clo_debug_dump_frames) = False;
65
76
Bool VG_(clo_trace_redir) = False;
66
77
Bool VG_(clo_trace_sched) = False;
67
78
Bool VG_(clo_trace_pthreads) = False;
68
79
Int VG_(clo_dump_error) = 0;
69
80
Int VG_(clo_backtrace_size) = 12;
70
81
Char* VG_(clo_sim_hints) = NULL;
82
Bool VG_(clo_sym_offsets) = False;
71
83
Bool VG_(clo_run_libc_freeres) = True;
72
84
Bool VG_(clo_track_fds) = False;
73
85
Bool VG_(clo_show_below_main)= False;
74
Bool VG_(clo_model_pthreads) = False;
75
86
Bool VG_(clo_show_emwarns) = False;
76
Int VG_(clo_max_stackframe) = 2000000;
87
Word VG_(clo_max_stackframe) = 2000000;
77
88
Bool VG_(clo_wait_for_gdb) = False;
78
89
VgSmc VG_(clo_smc_check) = Vg_SmcStack;
79
90
HChar* VG_(clo_kernel_variant) = NULL;
93
/*====================================================================*/
94
/*=== Command line errors ===*/
95
/*====================================================================*/
97
static void revert_to_stderr ( void )
99
vg_assert( !VG_(logging_to_socket) );
100
VG_(clo_log_fd) = 2; /* stderr */
103
__attribute__((noreturn))
104
void VG_(err_bad_option) ( Char* opt )
107
VG_(printf)("valgrind: Bad option '%s'; aborting.\n", opt);
108
VG_(printf)("valgrind: Use --help for more information.\n");
112
__attribute__((noreturn))
113
void VG_(err_missing_prog) ( void )
116
VG_(printf)("valgrind: no program specified\n");
117
VG_(printf)("valgrind: Use --help for more information.\n");
121
__attribute__((noreturn))
122
void VG_(err_config_error) ( Char* msg )
125
VG_(printf)("valgrind: Startup or configuration error:\n %s\n", msg);
126
VG_(printf)("valgrind: Unable to start up properly. Giving up.\n");
130
// Copies the string, prepending it with the startup working directory, and
131
// expanding %p and %q entries. Returns a new, malloc'd string.
132
Char* VG_(expand_file_name)(Char* option_name, Char* format)
134
static Char base_dir[VKI_PATH_MAX];
135
Int len, i = 0, j = 0;
138
Bool ok = VG_(get_startup_wd)(base_dir, VKI_PATH_MAX);
141
if (VG_STREQ(format, "")) {
143
VG_(message)(Vg_UserMsg, "%s: filename is empty", option_name);
147
// If 'format' starts with a '/', do not prefix with startup dir.
148
if (format[0] != '/') {
149
j += VG_(strlen)(base_dir);
152
// The 10 is slop, it should be enough in most cases.
153
len = j + VG_(strlen)(format) + 10;
154
out = VG_(malloc)( len );
155
if (format[0] != '/') {
156
VG_(strcpy)(out, base_dir);
160
#define ENSURE_THIS_MUCH_SPACE(x) \
161
if (j + x >= len) { \
163
out = VG_(realloc)(out, len); \
167
if (format[i] != '%') {
168
ENSURE_THIS_MUCH_SPACE(1);
169
out[j++] = format[i++];
172
// We saw a '%'. What's next...
174
if ('%' == format[i]) {
175
// Replace '%%' with '%'.
176
ENSURE_THIS_MUCH_SPACE(1);
177
out[j++] = format[i++];
179
else if ('p' == format[i]) {
180
// Print the PID. Assume that it's not longer than 10 chars --
181
// reasonable since 'pid' is an Int (ie. 32 bits).
182
Int pid = VG_(getpid)();
183
ENSURE_THIS_MUCH_SPACE(10);
184
j += VG_(sprintf)(&out[j], "%d", pid);
187
else if ('q' == format[i]) {
189
if ('{' == format[i]) {
190
// Get the env var name, print its contents.
194
qualname = &format[i];
196
if (0 == format[i]) {
197
VG_(message)(Vg_UserMsg, "%s: malformed %%q specifier",
200
} else if ('}' == format[i]) {
201
// Temporarily replace the '}' with NUL to extract var
204
qual = VG_(getenv)(qualname);
206
VG_(message)(Vg_UserMsg,
207
"%s: environment variable %s is not set",
208
option_name, qualname);
209
format[i] = '}'; // Put the '}' back.
212
format[i] = '}'; // Put the '}' back.
218
ENSURE_THIS_MUCH_SPACE(VG_(strlen)(qual));
219
j += VG_(sprintf)(&out[j], "%s", qual);
221
VG_(message)(Vg_UserMsg,
222
"%s: expected '{' after '%%q'", option_name);
227
// Something else, abort.
228
VG_(message)(Vg_UserMsg,
229
"%s: expected 'p' or 'q' or '%%' after '%%'", option_name);
234
ENSURE_THIS_MUCH_SPACE(1);
240
Char* opt = // 2: 1 for the '=', 1 for the NUL.
241
VG_(malloc)( VG_(strlen)(option_name) + VG_(strlen)(format) + 2 );
242
VG_(strcpy)(opt, option_name);
243
VG_(strcat)(opt, "=");
244
VG_(strcat)(opt, format);
245
VG_(err_bad_option)(opt);
82
251
/*--------------------------------------------------------------------*/
83
252
/*--- end m_options.c ---*/
84
253
/*--------------------------------------------------------------------*/