Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduced an API to collect the core from an unrelated process #11

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ramkums
Copy link

@ramkums ramkums commented Dec 2, 2024

The API WritePidCoreDumpWith() will take argument pid, and try to collect the core from the process with pid, this uses the existing logic to identify the threads under the given process and to identify the maps and the properties of each memory maps. Then read the memory content from /proc/[pid]/mem, we assume that the caller has the permission to trace and read the mem from process [pid].

A tool also introduced, which will use the API WritePidCoreDumpWith and provide a convenient CLI for the user, which will help in creating core dump of any process that the user has permission to trace.

include/coredumper/coredumper.h Outdated Show resolved Hide resolved
src/coredumper.c Outdated Show resolved Hide resolved
src/elfcore.cc Outdated Show resolved Hide resolved
src/elfcore.cc Outdated Show resolved Hide resolved
src/elfcore.cc Outdated Show resolved Hide resolved
tool/CMakeLists.txt Show resolved Hide resolved
tool/main.c Outdated Show resolved Hide resolved
tool/main.c Show resolved Hide resolved
tool/main.c Outdated Show resolved Hide resolved
tool/main.c Outdated Show resolved Hide resolved
include/coredumper/coredumper.h Outdated Show resolved Hide resolved
src/elfcore.cc Outdated Show resolved Hide resolved
src/elfcore.cc Outdated Show resolved Hide resolved
src/libcoredumper.sym Outdated Show resolved Hide resolved
/* If pid belong to the one called the library no need to proceed */
if (expid == 0 && pid == clone_pid) continue;

strcat(strcpy(fname, "/proc/"), entry->d_name);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's fine

tool/main.c Outdated Show resolved Hide resolved
tool/main.c Show resolved Hide resolved
src/elfcore.cc Outdated Show resolved Hide resolved
src/elfcore.cc Outdated Show resolved Hide resolved
tool/main.c Outdated Show resolved Hide resolved
Copy link

@jlevon jlevon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks, I think this looks good to me now

The API WriteCoreDumpOfPID() will take argument pid, and try to
collect the core from the process with pid, this uses the
existing logic to identify the threads under the given process
and to identify the maps and the properties of each memory maps.
Then read the memory content from /proc/[pid]/mem, we assume that
the caller has the permission to trace and read the mem from
process [pid].

A tool also introduced, which will use the API WriteCoreDumpOfPID
and provide a convenient CLI for the user, which will help in
creating core dump of any process that the user has permission to trace.

Following is the help from the tool:
Usage: ./coredumper_tool <-c corefile> <-p pid> [-s core_size] [-z]
<-h>               Show this message and exit
<-c core_file>     Collect the core dump into a file core_file
<-p pid>           Collect the core dump of process with pid
<-s core_size>     Limit the size of core_file to core_size
<-z>               Compress the core_file on the fly with gzip
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants