[minicoredumper] [PATCH 1/2] minicoredumper: add new task_info struct

Marco Felsch Marco.Felsch at preh.de
Wed Aug 2 17:30:00 CEST 2017


The struct will be needed for the refactored get_stack_pointer
implementation.

Signed-off-by: Marco Felsch <Marco.Felsch at preh.de>
---
 src/minicoredumper/corestripper.c | 17 +++++++++++++++++
 src/minicoredumper/corestripper.h |  7 +++++++
 2 files changed, 24 insertions(+)

diff --git a/src/minicoredumper/corestripper.c b/src/minicoredumper/corestripper.c
index 9b57d97..26501e2 100644
--- a/src/minicoredumper/corestripper.c
+++ b/src/minicoredumper/corestripper.c
@@ -388,6 +388,7 @@ static int copy_file(const char *dest, const char *src)
 static int get_task_list(struct dump_info *di)
 {
 	pid_t *pidlist = NULL;
+	struct tsk_info *tsklist = NULL;
 	struct dirent *de;
 	int count = 0;
 	char buf[64];
@@ -397,6 +398,7 @@ static int get_task_list(struct dump_info *di)
 	int i;
 
 	di->tsks = NULL;
+	di->tsk_list = NULL;
 	di->ntsks = 0;
 
 	snprintf(buf, sizeof(buf), "/proc/%d/task", di->pid);
@@ -427,6 +429,12 @@ static int get_task_list(struct dump_info *di)
 		goto out;
 	}
 
+	tsklist = calloc(count, sizeof(struct tsk_info));
+	if (!tsklist) {
+		err = 1;
+		goto out;
+	}
+
 	rewinddir(d);
 
 	/* read the actual tasks */
@@ -447,6 +455,7 @@ static int get_task_list(struct dump_info *di)
 		}
 
 		pidlist[i] = pid;
+		tsklist[i].task = pid;
 
 		i++;
 	}
@@ -459,12 +468,16 @@ static int get_task_list(struct dump_info *di)
 
 	di->tsks = pidlist;
 	pidlist = NULL;
+	di->tsk_list = tsklist;
+	tsklist = NULL;
 	di->ntsks = count;
 out:
 	closedir(d);
 
 	if (pidlist)
 		free(pidlist);
+	if (tsklist)
+		free(tsklist);
 
 	return err;
 }
@@ -1877,6 +1890,10 @@ static void cleanup_di(struct dump_info *di)
 		free(di->tsks);
 		di->tsks = NULL;
 	}
+	if (di->tsk_list) {
+		free(di->tsk_list);
+		di->tsk_list = NULL;
+	}
 	if (di->core_path) {
 		free(di->core_path);
 		di->core_path = NULL;
diff --git a/src/minicoredumper/corestripper.h b/src/minicoredumper/corestripper.h
index 5cd588e..c7ca57f 100644
--- a/src/minicoredumper/corestripper.h
+++ b/src/minicoredumper/corestripper.h
@@ -62,6 +62,11 @@ struct sym_data {
 	struct sym_data *next;
 };
 
+struct tsk_info {
+	uint64_t sp;
+	pid_t task;
+};
+
 struct dump_info {
 	struct config *cfg;
 
@@ -94,6 +99,8 @@ struct dump_info {
 
 	pid_t *tsks;
 	int ntsks;
+	/* needed for the refactored get_stack_pointer function */
+	struct tsk_info *tsk_list;
 
 	unsigned long vma_start;
 	unsigned long vma_end;
-- 
2.11.0




More information about the minicoredumper mailing list