|
Packit |
8ea169 |
/*
|
|
Packit |
8ea169 |
* Copyright (C) 2015 ABRT team
|
|
Packit |
8ea169 |
* Copyright (C) 2015 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 |
#ifndef _ABRT_XORG_UTILS_H_
|
|
Packit |
8ea169 |
#define _ABRT_XORG_UTILS_H_
|
|
Packit |
8ea169 |
|
|
Packit |
8ea169 |
#include "libabrt.h"
|
|
Packit |
8ea169 |
|
|
Packit |
8ea169 |
/* How many problem dirs to create at most?
|
|
Packit |
8ea169 |
* Also causes cooldown sleep with -t if exceeded -
|
|
Packit |
8ea169 |
* useful when called from a log watcher.
|
|
Packit |
8ea169 |
*/
|
|
Packit |
8ea169 |
#define ABRT_OOPS_MAX_DUMPED_COUNT 5
|
|
Packit |
8ea169 |
|
|
Packit |
8ea169 |
#ifdef __cplusplus
|
|
Packit |
8ea169 |
extern "C" {
|
|
Packit |
8ea169 |
#endif
|
|
Packit |
8ea169 |
|
|
Packit |
8ea169 |
#define XORG_SEARCH_STRING "Backtrace:"
|
|
Packit |
8ea169 |
|
|
Packit |
8ea169 |
enum {
|
|
Packit |
8ea169 |
ABRT_XORG_THROTTLE_CREATION = 1 << 0,
|
|
Packit |
8ea169 |
ABRT_XORG_WORLD_READABLE = 1 << 1,
|
|
Packit |
8ea169 |
ABRT_XORG_PRINT_STDOUT = 1 << 2,
|
|
Packit |
8ea169 |
};
|
|
Packit |
8ea169 |
|
|
Packit |
8ea169 |
int g_abrt_xorg_sleep_woke_up_on_signal;
|
|
Packit |
8ea169 |
int abrt_xorg_signaled_sleep(int seconds);
|
|
Packit |
8ea169 |
|
|
Packit |
8ea169 |
/*
|
|
Packit |
8ea169 |
* Information about found xorg crash
|
|
Packit |
8ea169 |
*/
|
|
Packit |
8ea169 |
struct xorg_crash_info
|
|
Packit |
8ea169 |
{
|
|
Packit |
8ea169 |
char *backtrace;
|
|
Packit |
8ea169 |
char *reason;
|
|
Packit |
8ea169 |
char *exe;
|
|
Packit |
8ea169 |
};
|
|
Packit |
8ea169 |
|
|
Packit |
8ea169 |
/*
|
|
Packit |
8ea169 |
* Free xorg crash info data
|
|
Packit |
8ea169 |
*/
|
|
Packit |
8ea169 |
void xorg_crash_info_free(struct xorg_crash_info *crash_info);
|
|
Packit |
8ea169 |
|
|
Packit |
8ea169 |
/*
|
|
Packit |
8ea169 |
* Skip log line prefixes
|
|
Packit |
8ea169 |
*
|
|
Packit |
8ea169 |
* Example:
|
|
Packit |
8ea169 |
* "[ 28.900] (EE) Foo" -> "Foo"
|
|
Packit |
8ea169 |
* "(EE) Foo" -> "Foo"
|
|
Packit |
8ea169 |
* " Foo" -> "Foo"
|
|
Packit |
8ea169 |
* "Foo" -> "Foo"
|
|
Packit |
8ea169 |
*
|
|
Packit |
8ea169 |
* @param str line from log file
|
|
Packit |
8ea169 |
* @returns line without prefixes
|
|
Packit |
8ea169 |
*/
|
|
Packit |
8ea169 |
char *skip_pfx(char *str);
|
|
Packit |
8ea169 |
|
|
Packit |
8ea169 |
/*
|
|
Packit |
8ea169 |
* Prints information about found xorg crash
|
|
Packit |
8ea169 |
*
|
|
Packit |
8ea169 |
* @param crash_info extracted xorg crash information
|
|
Packit |
8ea169 |
*/
|
|
Packit |
8ea169 |
void xorg_crash_info_print_crash(struct xorg_crash_info *crash_info);
|
|
Packit |
8ea169 |
|
|
Packit |
8ea169 |
/*
|
|
Packit |
8ea169 |
* Get next line from given stream (FILE *)
|
|
Packit |
8ea169 |
* Use as wrapper for reading function
|
|
Packit |
8ea169 |
*
|
|
Packit |
8ea169 |
* @param fd open FILE * as void *
|
|
Packit |
8ea169 |
* @returns malloced and unlimited line without railing \n
|
|
Packit |
8ea169 |
*/
|
|
Packit |
8ea169 |
char *xorg_get_next_line_from_fd(void *fd);
|
|
Packit |
8ea169 |
|
|
Packit |
8ea169 |
/*
|
|
Packit |
8ea169 |
* Process Xorg Backtrace
|
|
Packit |
8ea169 |
* This function is called after the key word "Backtrace:" was found in log.
|
|
Packit |
8ea169 |
*
|
|
Packit |
8ea169 |
* @param get_next_line function used for reading lines from data
|
|
Packit |
8ea169 |
* @param data is used as get_nex_line function parameter
|
|
Packit |
8ea169 |
* @returns extracted xorg crash data or NULL in case of error
|
|
Packit |
8ea169 |
*/
|
|
Packit |
8ea169 |
struct xorg_crash_info *process_xorg_bt(char *(*get_next_line)(void *), void *data);
|
|
Packit |
8ea169 |
|
|
Packit |
8ea169 |
/*
|
|
Packit |
8ea169 |
* Saves Xorg crash details in the dump directory
|
|
Packit |
8ea169 |
*
|
|
Packit |
8ea169 |
* @param dd The destination directory
|
|
Packit |
8ea169 |
* @param crash_info the crash details
|
|
Packit |
8ea169 |
* @returns non-0 value in case of an error; otherwise 0
|
|
Packit |
8ea169 |
*/
|
|
Packit |
8ea169 |
int xorg_crash_info_save_in_dump_dir(struct xorg_crash_info *crash_info, struct dump_dir *dd);
|
|
Packit |
8ea169 |
|
|
Packit |
8ea169 |
/*
|
|
Packit |
8ea169 |
* Create dump dir from given xorg crash info data
|
|
Packit |
8ea169 |
*
|
|
Packit |
8ea169 |
* @param crash_info xorg crash information
|
|
Packit |
8ea169 |
* @param path where the dump dir will be created
|
|
Packit |
8ea169 |
* @param world_readable make the dump dir world readable
|
|
Packit |
8ea169 |
*/
|
|
Packit |
8ea169 |
void xorg_crash_info_create_dump_dir(struct xorg_crash_info *crash_info, const char *dump_location,
|
|
Packit |
8ea169 |
bool world_readable);
|
|
Packit |
8ea169 |
|
|
Packit |
8ea169 |
#ifdef __cplusplus
|
|
Packit |
8ea169 |
}
|
|
Packit |
8ea169 |
#endif
|
|
Packit |
8ea169 |
|
|
Packit |
8ea169 |
#endif /*_ABRT_XORG_UTILS_H_*/
|