From john.ogness at linutronix.de Mon Sep 18 10:21:27 2017 From: john.ogness at linutronix.de (John Ogness) Date: Mon, 18 Sep 2017 10:21:27 +0200 Subject: [minicoredumper] [PATCH 0/2] Rework get_stack_pointer for linux above 4.8 In-Reply-To: <20170802153001.7653-1-Marco.Felsch@preh.de> (Marco Felsch's message of "Wed, 2 Aug 2017 17:29:59 +0200") References: <20170802153001.7653-1-Marco.Felsch@preh.de> Message-ID: <8760cg76yg.fsf@linutronix.de> Hello Marco, I appreciate your hard work on this issue. After much thought I have decided that we should not begin manually interpretting the core data to find the stack pointer. There are too many platforms that would need to be supported (and tested!). This is a Linux user API regression issue and is being handled as such [0]. Once that change makes it to the appropriate stable branches, this issue will resolve itself. John Ogness [0] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=fd7d56270b526ca3ed0c224362e3c64a0f86687a On 2017-08-02, Marco Felsch wrote: > The stack pointer isn't reported to the proc-fs since linux kernel 4.9. > It turned out [0] that we need to parse the kernel coredump ELF-header to > obtain the stack pointers for each thread. This has the disadvantage of > architecture depency. Therefore we keep the proc-fs methode for kernel > below 4.9 and inform the user if he use a kernel > 4.9 and use a > unsupported architecture. > > This patch series is an approach to parse the stack pointer from the > ELF-header. Currently only the arm64 is supported because of my target arch. > I've tested it with a linux kernel 4.9 and it works as it should. > > [0] http://lists.linutronix.de/pipermail/minicoredumper/2017-July/000044.html > > Marco Felsch (2): > minicoredumper: add new task_info struct > minicoredumper: add new get_stack_pointer function > > configure.ac | 14 ++- > src/minicoredumper/corestripper.c | 214 +++++++++++++++++++++++++++++++++++++- > src/minicoredumper/corestripper.h | 7 ++ > 3 files changed, 232 insertions(+), 3 deletions(-) From michael at mipisi.de Sat Sep 30 11:49:13 2017 From: michael at mipisi.de (Michael) Date: Sat, 30 Sep 2017 11:49:13 +0200 Subject: [minicoredumper] Write core dumps even if they have not existed before Message-ID: <71eb62b5-be56-4dfb-34d0-0c15d3129298@mipisi.de> Hi members of minicoredumper at linutronix.de , I started using minicoredumper for our projects. Very nice and handy tool! Just an idea on how it could be made even more handy. Motivation: On embedded system an enduser should not see any core dumps on the device. So core dumps are something you only need for development. There is a nice feature of minicoredumper that allows to customize the path where core files are stored. My problem here is that this path needs to exist in filesystem. What I have done is setting the customized core dump path to /home/root/crash and patch the minicoredump to not fail if dir does not exist. Instead now the sub directory "crash" is created when the first crash occurs. For me and my colleagues (especially for fieldtest) this is nice, because then you see: If a dir crash exists, something went wrong, else all fine. To achieve this I patched the minicoredumper source: From a89bb8711d3521cd11d69ef0531918d0345aa5c9 Mon Sep 17 00:00:00 2001 From: "Bode, Michael (BSH)" Date: Sat, 30 Sep 2017 11:03:35 +0200 Subject: [PATCH] Modify mkdir function to generate core dump also if dir have ?not existed before --- ?src/minicoredumper/corestripper.c | 20 +++++++++++++++++++- ?1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/src/minicoredumper/corestripper.c b/src/minicoredumper/corestripper.c index f4e7fcd..dce1170 100644 --- a/src/minicoredumper/corestripper.c +++ b/src/minicoredumper/corestripper.c @@ -308,6 +308,24 @@ out: ???? return err; ?} + +static int mkpath(char *dir, mode_t mode) +{ +??? struct stat sb; + +??? if (!dir) { +??????? errno = EINVAL; +??????? return 1; +??? } + +??? if (!stat(dir, &sb)) +??????? return 0; + +??? mkpath(dirname(strdupa(dir)), mode); + +??? return mkdir(dir, mode); +} + ?static int init_di(struct dump_info *di, char **argv, int argc) ?{ ???? const char *recept; @@ -430,7 +448,7 @@ static int init_di(struct dump_info *di, char **argv, int argc) ???? } ???? di->dst_dir = tmp_path; -??? if (mkdir(di->dst_dir, 0700) == -1) { +??? if (mkpath(di->dst_dir, 0700) == -1) { ???? ??? info("unable to create directory \'%s\': %s", di->dst_dir, ???? ??? ???? strerror(errno)); ???? ??? return 1; -- 2.7.4 Please don't take my implementation proposal too serious. I just want to give you the idea here. If you agree that this is an improvement maybe it would be even better to have an option in JSON file if you want to write non-existing paths. Br, Michael -------------- next part -------------- An HTML attachment was scrubbed... URL: