[PATCH] kernel 2.4.0-test8

From: Jason Villarreal (villarre@cs.ucr.edu)
Date: Mon Sep 18 2000 - 17:52:12 EST


Attached, for possible inclusion in the Linux kernel, is a patch for the
Linux-2.4.0-test8 kernel that causes core dumps to output appropriate
information for multithreaded programs for use by gdb. Currently only ELF
files are supported but other formats can easily add their own functions
to support this feature if desired.

Affected Files:

fs/binfmt_elf.c
fs/exec.c
include/linux/binfmts.h
include/linux/sysctl.h
kernel/sysctl.c

Summary of the changes:

To opt out the changes we made to the dumping of elf cores, we added an
integer named dumptcores into the proc interface. This integer is located
at /proc/sys/kernel/dumptcores

We added a function pointer named tcore_dump to the end of the binfmt
structure.

In the initialization of the elf_binfmt structure, we initialize
tcore_dump to point at elf_tcore_dump. Due to the C specification, the
initializations that do not set this function pointer set it to NULL.

We added a tcore_list_node structure that holds the thread-specific
information that we will output.

We added several list mainpulating functions to operate on that list.

We added a check in do_coredump to see if tcore_dump exists-if so, we call
it.

We added the function elf_tcore_dump which grabs the registers and other
pertinant information from current, and stores them on a linked list for
later use.

We modified the elf_core_dump procedure so that it creates a new PT_NOTE
section in the core and outputs all of the thread-specific information to
that section.

Usage:

echo 1 > /proc/sys/kernel/dumptcores to turn on multithreaded elf core
dumping. Any other number will result in the previous style of core
dumps. The default value of this number is 0.

Turning it on at any time does not pose a problem but, once enabled, if
it is turned off a memory leak may occur if a multithreaded program was
currently dumping a core. Therefore once enabled it should not be
disabled.

After this, run gdb as normal on any core files and all the thread
information will be available to you through the "thread" commands
inside gdb.

Tests:

We tested this patch on programs with several hundred threads running
concurrently. It was also tested by Spinway, Inc. on some
of their code.

Please respond to us with any suggestions/comments about this patch.

Jason Villarreal (villarre@cs.ucr.edu)
John Jones (jjones@cs.ucr.edu)



-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Sat Sep 23 2000 - 21:00:19 EST