From 042d62126a0ca8b6b9d2fb4d417f07691be90536 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Sat, 23 Apr 2011 17:21:17 +0200 Subject: mass replace of crash_data with problem_data Signed-off-by: Denys Vlasenko --- src/include/Makefile.am | 4 +- src/include/abrt_crash_data.h | 100 ----------------------------------- src/include/abrt_problem_data.h | 100 +++++++++++++++++++++++++++++++++++ src/include/abrtlib.h | 10 ++-- src/include/report/crash_data.h | 106 -------------------------------------- src/include/report/dump_dir.h | 2 +- src/include/report/problem_data.h | 106 ++++++++++++++++++++++++++++++++++++++ src/include/report/run_event.h | 4 +- 8 files changed, 216 insertions(+), 216 deletions(-) delete mode 100644 src/include/abrt_crash_data.h create mode 100644 src/include/abrt_problem_data.h delete mode 100644 src/include/report/crash_data.h create mode 100644 src/include/report/problem_data.h (limited to 'src/include') diff --git a/src/include/Makefile.am b/src/include/Makefile.am index e6f0387b..eaebe3a1 100644 --- a/src/include/Makefile.am +++ b/src/include/Makefile.am @@ -1,6 +1,6 @@ libreport_includedir = $(includedir)/report libreport_include_HEADERS = \ - report/crash_data.h \ + report/problem_data.h \ report/dump_dir.h \ report/run_event.h \ report/event_config.h @@ -9,5 +9,5 @@ libabrt_includedir = $(includedir)/abrt libabrt_include_HEADERS = \ abrtlib.h \ abrt_types.h \ - abrt_crash_data.h \ + abrt_problem_data.h \ xfuncs.h diff --git a/src/include/abrt_crash_data.h b/src/include/abrt_crash_data.h deleted file mode 100644 index 237a3d01..00000000 --- a/src/include/abrt_crash_data.h +++ /dev/null @@ -1,100 +0,0 @@ -/* - Copyright (C) 2009 Abrt team. - Copyright (C) 2009 RedHat inc. - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -*/ -#ifndef ABRT_CRASH_DUMP_H_ -#define ABRT_CRASH_DUMP_H_ - -#include "crash_data.h" -#include "abrt_types.h" - -// Text bigger than this usually is attached, not added inline -#define CD_TEXT_ATT_SIZE (2*1024) - -// Filenames in dump directory: -// filled by a hook: -#define FILENAME_REASON "reason" /* mandatory */ -#define FILENAME_UID "uid" /* mandatory */ -#define FILENAME_TIME "time" /* mandatory */ -#define FILENAME_ANALYZER "analyzer" -#define FILENAME_EXECUTABLE "executable" -#define FILENAME_BINARY "binary" -#define FILENAME_CMDLINE "cmdline" -#define FILENAME_COREDUMP "coredump" -#define FILENAME_BACKTRACE "backtrace" -#define FILENAME_MAPS "maps" -#define FILENAME_SMAPS "smaps" -#define FILENAME_ENVIRON "environ" -#define FILENAME_DUPHASH "global_uuid" /* name is compat, to be renamed to "duphash" */ -// Name of the function where the application crashed. -// Optional. -#define FILENAME_CRASH_FUNCTION "crash_function" -// filled by CDebugDump::Create() (which also fills FILENAME_UID): -#define FILENAME_ARCHITECTURE "architecture" -#define FILENAME_KERNEL "kernel" -// From /etc/system-release or /etc/redhat-release -#define FILENAME_OS_RELEASE "os_release" -// Filled by -#define FILENAME_PACKAGE "package" -#define FILENAME_COMPONENT "component" -#define FILENAME_COMMENT "comment" -#define FILENAME_RATING "rating" -#define FILENAME_HOSTNAME "hostname" -// Optional. Set to "1" by abrt-handle-upload for every unpacked crashdump -#define FILENAME_REMOTE "remote" -#define FILENAME_TAINTED "kernel_tainted" -// TODO: TicketUploader also has open-coded "TICKET", "CUSTOMER" files - -#define FILENAME_UUID "uuid" -#define FILENAME_COUNT "count" -/* Multi-line list of places problem was reported. - * Recommended line format: - * "Reporter: VAR=VAL VAR=VAL" - * Use add_reported_to(dd, "line_without_newline"): it adds line - * only if it is not already there. - */ -#define FILENAME_REPORTED_TO "reported_to" -#define FILENAME_EVENT_LOG "event_log" -// Not stored as files, added "on the fly": -#define CD_DUMPDIR "DumpDir" -// "Which events are possible (make sense) on this crash dump?" -// (a string with "\n" terminated event names) -#define CD_EVENTS "Events" - -/* FILENAME_EVENT_LOG is trimmed to below LOW_WATERMARK - * when it reaches HIGH_WATERMARK size - */ -enum { - EVENT_LOG_HIGH_WATERMARK = 30 * 1024, - EVENT_LOG_LOW_WATERMARK = 20 * 1024, -}; - -#ifdef __cplusplus -extern "C" { -#endif - -#define add_reported_to abrt_add_reported_to -void add_reported_to(struct dump_dir *dd, const char *line); - -#define log_crash_data abrt_log_crash_data -void log_crash_data(crash_data_t *crash_data, const char *pfx); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/src/include/abrt_problem_data.h b/src/include/abrt_problem_data.h new file mode 100644 index 00000000..3ab6679c --- /dev/null +++ b/src/include/abrt_problem_data.h @@ -0,0 +1,100 @@ +/* + Copyright (C) 2009 Abrt team. + Copyright (C) 2009 RedHat inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +*/ +#ifndef ABRT_PROBLEM_DATA_H_ +#define ABRT_PROBLEM_DATA_H_ + +#include "problem_data.h" +#include "abrt_types.h" + +// Text bigger than this usually is attached, not added inline +#define CD_TEXT_ATT_SIZE (2*1024) + +// Filenames in dump directory: +// filled by a hook: +#define FILENAME_REASON "reason" /* mandatory */ +#define FILENAME_UID "uid" /* mandatory */ +#define FILENAME_TIME "time" /* mandatory */ +#define FILENAME_ANALYZER "analyzer" +#define FILENAME_EXECUTABLE "executable" +#define FILENAME_BINARY "binary" +#define FILENAME_CMDLINE "cmdline" +#define FILENAME_COREDUMP "coredump" +#define FILENAME_BACKTRACE "backtrace" +#define FILENAME_MAPS "maps" +#define FILENAME_SMAPS "smaps" +#define FILENAME_ENVIRON "environ" +#define FILENAME_DUPHASH "global_uuid" /* name is compat, to be renamed to "duphash" */ +// Name of the function where the application crashed. +// Optional. +#define FILENAME_CRASH_FUNCTION "crash_function" +// filled by CDebugDump::Create() (which also fills FILENAME_UID): +#define FILENAME_ARCHITECTURE "architecture" +#define FILENAME_KERNEL "kernel" +// From /etc/system-release or /etc/redhat-release +#define FILENAME_OS_RELEASE "os_release" +// Filled by +#define FILENAME_PACKAGE "package" +#define FILENAME_COMPONENT "component" +#define FILENAME_COMMENT "comment" +#define FILENAME_RATING "rating" +#define FILENAME_HOSTNAME "hostname" +// Optional. Set to "1" by abrt-handle-upload for every unpacked dump +#define FILENAME_REMOTE "remote" +#define FILENAME_TAINTED "kernel_tainted" +// TODO: TicketUploader also has open-coded "TICKET", "CUSTOMER" files + +#define FILENAME_UUID "uuid" +#define FILENAME_COUNT "count" +/* Multi-line list of places problem was reported. + * Recommended line format: + * "Reporter: VAR=VAL VAR=VAL" + * Use add_reported_to(dd, "line_without_newline"): it adds line + * only if it is not already there. + */ +#define FILENAME_REPORTED_TO "reported_to" +#define FILENAME_EVENT_LOG "event_log" +// Not stored as files, added "on the fly": +#define CD_DUMPDIR "DumpDir" +// "Which events are possible (make sense) on this dump dir?" +// (a string with "\n" terminated event names) +#define CD_EVENTS "Events" + +/* FILENAME_EVENT_LOG is trimmed to below LOW_WATERMARK + * when it reaches HIGH_WATERMARK size + */ +enum { + EVENT_LOG_HIGH_WATERMARK = 30 * 1024, + EVENT_LOG_LOW_WATERMARK = 20 * 1024, +}; + +#ifdef __cplusplus +extern "C" { +#endif + +#define add_reported_to abrt_add_reported_to +void add_reported_to(struct dump_dir *dd, const char *line); + +#define log_problem_data abrt_log_problem_data +void log_problem_data(problem_data_t *problem_data, const char *pfx); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/src/include/abrtlib.h b/src/include/abrtlib.h index 6d9337d5..19ce7ad9 100644 --- a/src/include/abrtlib.h +++ b/src/include/abrtlib.h @@ -77,7 +77,7 @@ int vdprintf(int d, const char *format, va_list ap); #include "strbuf.h" #include "hash_sha1.h" -#include "abrt_crash_data.h" +#include "abrt_problem_data.h" #include "abrt_types.h" #include "dump_dir.h" #include "hooklib.h" @@ -239,13 +239,13 @@ int daemon_is_ok(); char *iso_date_string(time_t *pt); #define make_description_bz abrt_make_description_bz -char* make_description_bz(crash_data_t *crash_data); +char* make_description_bz(problem_data_t *problem_data); #define make_description_comment abrt_make_description_comment -char* make_description_comment(crash_data_t *crash_data); +char* make_description_comment(problem_data_t *problem_data); #define make_description_logger abrt_make_description_logger -char* make_description_logger(crash_data_t *crash_data); +char* make_description_logger(problem_data_t *problem_data); #define make_description_mailx abrt_make_description_mailx -char* make_description_mailx(crash_data_t *crash_data); +char* make_description_mailx(problem_data_t *problem_data); #define parse_release_for_bz abrt_parse_release_for_bz void parse_release_for_bz(const char *pRelease, char **product, char **version); diff --git a/src/include/report/crash_data.h b/src/include/report/crash_data.h deleted file mode 100644 index e152c63f..00000000 --- a/src/include/report/crash_data.h +++ /dev/null @@ -1,106 +0,0 @@ -/* - Copyright (C) 2009 Abrt team. - Copyright (C) 2009 RedHat inc. - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -*/ -#ifndef CRASH_DATA_H_ -#define CRASH_DATA_H_ - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -struct dump_dir; - -enum { - CD_FLAG_BIN = (1 << 0), - CD_FLAG_TXT = (1 << 1), - CD_FLAG_ISEDITABLE = (1 << 2), - CD_FLAG_ISNOTEDITABLE = (1 << 3), - /* Show this element in "short" info (abrt-cli -l) */ - CD_FLAG_LIST = (1 << 4), - CD_FLAG_UNIXTIME = (1 << 5), -}; - -struct crash_item { - char *content; - unsigned flags; -}; -typedef struct crash_item crash_item; - -char *format_crash_item(struct crash_item *item); - -/* In-memory crash data structure and accessors */ - -typedef GHashTable crash_data_t; - -crash_data_t *new_crash_data(void); - -static inline void free_crash_data(crash_data_t *crash_data) -{ - if (crash_data) - g_hash_table_destroy(crash_data); -} - -void add_to_crash_data_ext(crash_data_t *crash_data, - const char *name, - const char *content, - unsigned flags); -/* Uses CD_FLAG_TXT + CD_FLAG_ISNOTEDITABLE flags */ -void add_to_crash_data(crash_data_t *crash_data, - const char *name, - const char *content); - -static inline struct crash_item *get_crash_data_item_or_NULL(crash_data_t *crash_data, const char *key) -{ - return (struct crash_item *)g_hash_table_lookup(crash_data, key); -} -const char *get_crash_item_content_or_NULL(crash_data_t *crash_data, const char *key); -/* Aborts if key is not found: */ -const char *get_crash_item_content_or_die(crash_data_t *crash_data, const char *key); - - -/* Vector of these structures */ - -typedef GPtrArray vector_of_crash_data_t; - -static inline crash_data_t *get_crash_data(vector_of_crash_data_t *vector, unsigned i) -{ - return (crash_data_t *)g_ptr_array_index(vector, i); -} - -vector_of_crash_data_t *new_vector_of_crash_data(void); -static inline void free_vector_of_crash_data(vector_of_crash_data_t *vector) -{ - if (vector) - g_ptr_array_free(vector, TRUE); -} - - -/* Conversions between in-memory and on-disk formats */ - -void load_crash_data_from_dump_dir(crash_data_t *crash_data, struct dump_dir *dd); -crash_data_t *create_crash_data_from_dump_dir(struct dump_dir *dd); - -struct dump_dir *create_dump_dir_from_crash_data(crash_data_t *crash_data, const char *base_dir_name); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/src/include/report/dump_dir.h b/src/include/report/dump_dir.h index 026571b7..c88ebe7f 100644 --- a/src/include/report/dump_dir.h +++ b/src/include/report/dump_dir.h @@ -1,5 +1,5 @@ /* - On-disk storage of crash dumps + On-disk storage of problem data Copyright (C) 2009 Zdenek Prikryl (zprikryl@redhat.com) Copyright (C) 2009 RedHat inc. diff --git a/src/include/report/problem_data.h b/src/include/report/problem_data.h new file mode 100644 index 00000000..1481654f --- /dev/null +++ b/src/include/report/problem_data.h @@ -0,0 +1,106 @@ +/* + Copyright (C) 2009 Abrt team. + Copyright (C) 2009 RedHat inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +*/ +#ifndef PROBLEM_DATA_H_ +#define PROBLEM_DATA_H_ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +struct dump_dir; + +enum { + CD_FLAG_BIN = (1 << 0), + CD_FLAG_TXT = (1 << 1), + CD_FLAG_ISEDITABLE = (1 << 2), + CD_FLAG_ISNOTEDITABLE = (1 << 3), + /* Show this element in "short" info (abrt-cli -l) */ + CD_FLAG_LIST = (1 << 4), + CD_FLAG_UNIXTIME = (1 << 5), +}; + +struct problem_item { + char *content; + unsigned flags; +}; +typedef struct problem_item problem_item; + +char *format_problem_item(struct problem_item *item); + +/* In-memory problem data structure and accessors */ + +typedef GHashTable problem_data_t; + +problem_data_t *new_problem_data(void); + +static inline void free_problem_data(problem_data_t *problem_data) +{ + if (problem_data) + g_hash_table_destroy(problem_data); +} + +void add_to_problem_data_ext(problem_data_t *problem_data, + const char *name, + const char *content, + unsigned flags); +/* Uses CD_FLAG_TXT + CD_FLAG_ISNOTEDITABLE flags */ +void add_to_problem_data(problem_data_t *problem_data, + const char *name, + const char *content); + +static inline struct problem_item *get_problem_data_item_or_NULL(problem_data_t *problem_data, const char *key) +{ + return (struct problem_item *)g_hash_table_lookup(problem_data, key); +} +const char *get_problem_item_content_or_NULL(problem_data_t *problem_data, const char *key); +/* Aborts if key is not found: */ +const char *get_problem_item_content_or_die(problem_data_t *problem_data, const char *key); + + +/* Vector of these structures */ + +typedef GPtrArray vector_of_problem_data_t; + +static inline problem_data_t *get_problem_data(vector_of_problem_data_t *vector, unsigned i) +{ + return (problem_data_t *)g_ptr_array_index(vector, i); +} + +vector_of_problem_data_t *new_vector_of_problem_data(void); +static inline void free_vector_of_problem_data(vector_of_problem_data_t *vector) +{ + if (vector) + g_ptr_array_free(vector, TRUE); +} + + +/* Conversions between in-memory and on-disk formats */ + +void load_problem_data_from_dump_dir(problem_data_t *problem_data, struct dump_dir *dd); +problem_data_t *create_problem_data_from_dump_dir(struct dump_dir *dd); + +struct dump_dir *create_dump_dir_from_problem_data(problem_data_t *problem_data, const char *base_dir_name); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/src/include/report/run_event.h b/src/include/report/run_event.h index 7fd8edea..8bd86543 100644 --- a/src/include/report/run_event.h +++ b/src/include/report/run_event.h @@ -19,7 +19,7 @@ #ifndef RUN_EVENT_H_ #define RUN_EVENT_H_ -#include "crash_data.h" +#include "problem_data.h" #ifdef __cplusplus extern "C" { @@ -65,7 +65,7 @@ void free_commands(struct run_event_state *state); * of post_run_callback. If all actions are successful, returns 0. */ int run_event_on_dir_name(struct run_event_state *state, const char *dump_dir_name, const char *event); -int run_event_on_crash_data(struct run_event_state *state, crash_data_t *data, const char *event); +int run_event_on_problem_data(struct run_event_state *state, problem_data_t *data, const char *event); /* Querying for possible events */ -- cgit