chiark
/
gitweb
/
~ianmdlvl
/
elogind.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
keymap: Add support for Eject button on MSI GE60/GE70
[elogind.git]
/
src
/
journal
/
coredumpctl.c
diff --git
a/src/journal/coredumpctl.c
b/src/journal/coredumpctl.c
index 60bba7f0e83b0d0ecd256a56fdf8f64d43286251..5652c2f91a477b1a267f208cc3a8284d8940f012 100644
(file)
--- a/
src/journal/coredumpctl.c
+++ b/
src/journal/coredumpctl.c
@@
-19,6
+19,7
@@
along with systemd; If not, see <http://www.gnu.org/licenses/>.
***/
along with systemd; If not, see <http://www.gnu.org/licenses/>.
***/
+#include <locale.h>
#include <stdio.h>
#include <string.h>
#include <getopt.h>
#include <stdio.h>
#include <string.h>
#include <getopt.h>
@@
-33,6
+34,8
@@
#include "log.h"
#include "path-util.h"
#include "pager.h"
#include "log.h"
#include "path-util.h"
#include "pager.h"
+#include "macro.h"
+#include "journal-internal.h"
static enum {
ACTION_NONE,
static enum {
ACTION_NONE,
@@
-41,7
+44,6
@@
static enum {
ACTION_GDB,
} arg_action = ACTION_LIST;
ACTION_GDB,
} arg_action = ACTION_LIST;
-static Set *matches = NULL;
static FILE* output = NULL;
static char* field = NULL;
static FILE* output = NULL;
static char* field = NULL;
@@
-66,10
+68,9
@@
static Set *new_matches(void) {
return NULL;
}
return NULL;
}
- r = set_
put
(set, tmp);
+ r = set_
consume
(set, tmp);
if (r < 0) {
log_error("failed to add to set: %s", strerror(-r));
if (r < 0) {
log_error("failed to add to set: %s", strerror(-r));
- free(tmp);
set_free(set);
return NULL;
}
set_free(set);
return NULL;
}
@@
-87,6
+88,8
@@
static int help(void) {
"Commands:\n"
" -h --help Show this help\n"
" --version Print version string\n"
"Commands:\n"
" -h --help Show this help\n"
" --version Print version string\n"
+ " -F --field=FIELD List all values a certain field takes\n"
+ " gdb Start gdb for the first matching coredump\n"
" list List available coredumps\n"
" dump PID Print coredump to stdout\n"
" dump PATH Print coredump to stdout\n"
" list List available coredumps\n"
" dump PID Print coredump to stdout\n"
" dump PATH Print coredump to stdout\n"
@@
-100,7
+103,7
@@
static int add_match(Set *set, const char *match) {
unsigned pid;
const char* prefix;
char *pattern = NULL;
unsigned pid;
const char* prefix;
char *pattern = NULL;
-
char _cleanup_free_
*p = NULL;
+
_cleanup_free_ char
*p = NULL;
if (strchr(match, '='))
prefix = "";
if (strchr(match, '='))
prefix = "";
@@
-121,22
+124,21
@@
static int add_match(Set *set, const char *match) {
if (!pattern)
goto fail;
if (!pattern)
goto fail;
- r = set_put(set, pattern);
+ log_debug("Adding pattern: %s", pattern);
+ r = set_consume(set, pattern);
if (r < 0) {
if (r < 0) {
- log_error("
f
ailed to add pattern '%s': %s",
+ log_error("
F
ailed to add pattern '%s': %s",
pattern, strerror(-r));
goto fail;
}
pattern, strerror(-r));
goto fail;
}
- log_debug("Added pattern: %s", pattern);
return 0;
fail:
return 0;
fail:
- free(pattern);
- log_error("failed to add match: %s", strerror(-r));
+ log_error("Failed to add match: %s", strerror(-r));
return r;
}
return r;
}
-static int parse_argv(int argc, char *argv[]) {
+static int parse_argv(int argc, char *argv[]
, Set *matches
) {
enum {
ARG_VERSION = 0x100,
ARG_NO_PAGER,
enum {
ARG_VERSION = 0x100,
ARG_NO_PAGER,
@@
-167,7
+169,6
@@
static int parse_argv(int argc, char *argv[]) {
case ARG_VERSION:
puts(PACKAGE_STRING);
case ARG_VERSION:
puts(PACKAGE_STRING);
- puts(DISTRIBUTION);
puts(SYSTEMD_FEATURES);
arg_action = ACTION_NONE;
return 0;
puts(SYSTEMD_FEATURES);
arg_action = ACTION_NONE;
return 0;
@@
-259,14
+260,14
@@
static int retrieve(const void *data,
return 0;
*var = strndup((const char*)data + ident, len - ident);
return 0;
*var = strndup((const char*)data + ident, len - ident);
- if (!var)
+ if (!
*
var)
return log_oom();
return 0;
}
static void print_field(FILE* file, sd_journal *j) {
return log_oom();
return 0;
}
static void print_field(FILE* file, sd_journal *j) {
-
const char _cleanup_free_
*value = NULL;
+
_cleanup_free_ const char
*value = NULL;
const void *d;
size_t l;
const void *d;
size_t l;
@@
-279,7
+280,7
@@
static void print_field(FILE* file, sd_journal *j) {
}
static int print_entry(FILE* file, sd_journal *j, int had_legend) {
}
static int print_entry(FILE* file, sd_journal *j, int had_legend) {
- const char _cleanup_free_
+ _cleanup_free_ const char
*pid = NULL, *uid = NULL, *gid = NULL,
*sgnl = NULL, *exe = NULL;
const void *d;
*pid = NULL, *uid = NULL, *gid = NULL,
*sgnl = NULL, *exe = NULL;
const void *d;
@@
-339,6
+340,11
@@
static int dump_list(sd_journal *j) {
assert(j);
assert(j);
+ /* The coredumps are likely to compressed, and for just
+ * listing them we don#t need to decompress them, so let's
+ * pick a fairly low data threshold here */
+ sd_journal_set_data_threshold(j, 4096);
+
SD_JOURNAL_FOREACH(j) {
if (field)
print_field(stdout, j);
SD_JOURNAL_FOREACH(j) {
if (field)
print_field(stdout, j);
@@
-378,6
+384,9
@@
static int dump_core(sd_journal* j) {
assert(j);
assert(j);
+ /* We want full data, nothing truncated. */
+ sd_journal_set_data_threshold(j, 0);
+
r = focus(j);
if (r < 0)
return r;
r = focus(j);
if (r < 0)
return r;
@@
-425,6
+434,8
@@
static int run_gdb(sd_journal *j) {
assert(j);
assert(j);
+ sd_journal_set_data_threshold(j, 0);
+
r = focus(j);
if (r < 0)
return r;
r = focus(j);
if (r < 0)
return r;
@@
-507,11
+518,13
@@
finish:
}
int main(int argc, char *argv[]) {
}
int main(int argc, char *argv[]) {
-
sd_journal
*j = NULL;
+
_cleanup_journal_close_ sd_journal
*j = NULL;
const char* match;
Iterator it;
int r = 0;
const char* match;
Iterator it;
int r = 0;
+ _cleanup_set_free_free_ Set *matches = NULL;
+ setlocale(LC_ALL, "");
log_parse_environment();
log_open();
log_parse_environment();
log_open();
@@
-521,7
+534,7
@@
int main(int argc, char *argv[]) {
goto end;
}
goto end;
}
- r = parse_argv(argc, argv);
+ r = parse_argv(argc, argv
, matches
);
if (r < 0)
goto end;
if (r < 0)
goto end;
@@
-547,7
+560,7
@@
int main(int argc, char *argv[]) {
case ACTION_LIST:
if (!arg_no_pager)
case ACTION_LIST:
if (!arg_no_pager)
- pager_open();
+ pager_open(
false
);
r = dump_list(j);
break;
r = dump_list(j);
break;
@@
-565,11
+578,6
@@
int main(int argc, char *argv[]) {
}
end:
}
end:
- if (j)
- sd_journal_close(j);
-
- set_free_free(matches);
-
pager_close();
if (output)
pager_close();
if (output)