|
Packit |
8ea169 |
/*
|
|
Packit |
8ea169 |
Copyright (C) 2011 ABRT team
|
|
Packit |
8ea169 |
Copyright (C) 2011 RedHat Inc
|
|
Packit |
8ea169 |
|
|
Packit |
8ea169 |
This program is free software; you can redistribute it and/or modify
|
|
Packit |
8ea169 |
it under the terms of the GNU General Public License as published by
|
|
Packit |
8ea169 |
the Free Software Foundation; either version 2 of the License, or
|
|
Packit |
8ea169 |
(at your option) any later version.
|
|
Packit |
8ea169 |
|
|
Packit |
8ea169 |
This program is distributed in the hope that it will be useful,
|
|
Packit |
8ea169 |
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Packit |
8ea169 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
Packit |
8ea169 |
GNU General Public License for more details.
|
|
Packit |
8ea169 |
|
|
Packit |
8ea169 |
You should have received a copy of the GNU General Public License along
|
|
Packit |
8ea169 |
with this program; if not, write to the Free Software Foundation, Inc.,
|
|
Packit |
8ea169 |
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
Packit |
8ea169 |
*/
|
|
Packit |
8ea169 |
#include <satyr/abrt.h>
|
|
Packit |
8ea169 |
#include <satyr/utils.h>
|
|
Packit |
8ea169 |
|
|
Packit |
8ea169 |
#include "libabrt.h"
|
|
Packit |
8ea169 |
|
|
Packit |
8ea169 |
int main(int argc, char **argv)
|
|
Packit |
8ea169 |
{
|
|
Packit |
8ea169 |
/* I18n */
|
|
Packit |
8ea169 |
setlocale(LC_ALL, "");
|
|
Packit |
8ea169 |
#if ENABLE_NLS
|
|
Packit |
8ea169 |
bindtextdomain(PACKAGE, LOCALEDIR);
|
|
Packit |
8ea169 |
textdomain(PACKAGE);
|
|
Packit |
8ea169 |
#endif
|
|
Packit |
8ea169 |
|
|
Packit |
8ea169 |
abrt_init(argv);
|
|
Packit |
8ea169 |
|
|
Packit |
8ea169 |
const char *dump_dir_name = ".";
|
|
Packit |
8ea169 |
int raw_fingerprints = 0; /* must be _int_, OPT_BOOL expects that! */
|
|
Packit |
8ea169 |
|
|
Packit |
8ea169 |
/* Can't keep these strings/structs static: _() doesn't support that */
|
|
Packit |
8ea169 |
const char *program_usage_string = _(
|
|
Packit |
8ea169 |
"& [-v] [-r] -d DIR\n"
|
|
Packit |
8ea169 |
"\n"
|
|
Packit |
8ea169 |
"Creates coredump-level backtrace from core dump and corresponding binary"
|
|
Packit |
8ea169 |
);
|
|
Packit |
8ea169 |
enum {
|
|
Packit |
8ea169 |
OPT_v = 1 << 0,
|
|
Packit |
8ea169 |
OPT_d = 1 << 1,
|
|
Packit |
8ea169 |
OPT_r = 1 << 2,
|
|
Packit |
8ea169 |
};
|
|
Packit |
8ea169 |
/* Keep enum above and order of options below in sync! */
|
|
Packit |
8ea169 |
struct options program_options[] = {
|
|
Packit |
8ea169 |
OPT__VERBOSE(&g_verbose),
|
|
Packit |
8ea169 |
OPT_STRING('d', NULL, &dump_dir_name, "DIR", _("Problem directory")),
|
|
Packit |
8ea169 |
OPT_BOOL('r', "raw", &raw_fingerprints, _("Do not hash fingerprints")),
|
|
Packit |
8ea169 |
OPT_END()
|
|
Packit |
8ea169 |
};
|
|
Packit |
8ea169 |
/*unsigned opts =*/ parse_opts(argc, argv, program_options, program_usage_string);
|
|
Packit |
8ea169 |
|
|
Packit |
8ea169 |
export_abrt_envvars(0);
|
|
Packit |
8ea169 |
|
|
Packit |
8ea169 |
if (g_verbose > 1)
|
|
Packit |
8ea169 |
sr_debug_parser = true;
|
|
Packit |
8ea169 |
|
|
Packit |
8ea169 |
/* Let user know what's going on */
|
|
Packit |
8ea169 |
log_notice(_("Generating core_backtrace"));
|
|
Packit |
8ea169 |
|
|
Packit |
8ea169 |
char *error_message = NULL;
|
|
Packit |
8ea169 |
bool success;
|
|
Packit |
8ea169 |
|
|
Packit |
8ea169 |
#ifdef ENABLE_NATIVE_UNWINDER
|
|
Packit |
8ea169 |
|
|
Packit |
8ea169 |
success = sr_abrt_create_core_stacktrace(dump_dir_name, !raw_fingerprints,
|
|
Packit |
8ea169 |
&error_message);
|
|
Packit |
8ea169 |
#else /* ENABLE_NATIVE_UNWINDER */
|
|
Packit |
8ea169 |
|
|
Packit |
8ea169 |
/* The value 240 was taken from abrt-action-generate-backtrace.c. */
|
|
Packit |
8ea169 |
int exec_timeout_sec = 240;
|
|
Packit |
8ea169 |
|
|
Packit |
8ea169 |
char *gdb_output = get_backtrace(dump_dir_name, exec_timeout_sec, NULL);
|
|
Packit |
8ea169 |
if (!gdb_output)
|
|
Packit |
8ea169 |
{
|
|
Packit |
8ea169 |
log_warning(_("Error: GDB did not return any data"));
|
|
Packit |
8ea169 |
return 1;
|
|
Packit |
8ea169 |
}
|
|
Packit |
8ea169 |
|
|
Packit |
8ea169 |
success = sr_abrt_create_core_stacktrace_from_gdb(dump_dir_name,
|
|
Packit |
8ea169 |
gdb_output,
|
|
Packit |
8ea169 |
!raw_fingerprints,
|
|
Packit |
8ea169 |
&error_message);
|
|
Packit |
8ea169 |
free(gdb_output);
|
|
Packit |
8ea169 |
|
|
Packit |
8ea169 |
#endif /* ENABLE_NATIVE_UNWINDER */
|
|
Packit |
8ea169 |
|
|
Packit |
8ea169 |
if (!success)
|
|
Packit |
8ea169 |
{
|
|
Packit |
8ea169 |
log_warning(_("Error: %s"), error_message);
|
|
Packit |
8ea169 |
free(error_message);
|
|
Packit |
8ea169 |
return 1;
|
|
Packit |
8ea169 |
}
|
|
Packit |
8ea169 |
|
|
Packit |
8ea169 |
return 0;
|
|
Packit |
8ea169 |
}
|