gcore - Linux


gcore is a utility specifically designed to assist in debugging and troubleshooting multithreaded applications running on Linux systems. It generates a core dump that includes information about the entire process, not just the main thread. This allows developers to analyze and debug problems in multithreaded environments where traditional core dumps may not capture all necessary data.


gcore [options] <pid> [<output file>]


  • <pid>: The process ID (PID) of the target process.
  • <output file>: (Optional) The file path where the core dump will be saved. Defaults to core.<pid> if not specified.


  • -b: Batch debug – Useful for debugging processes in batch systems when the standard error stream may not be available. Writes debug information to a file instead.
  • -c: Show command line – Includes the command line arguments used to start the process in the core dump.
  • -d: Debug – Outputs detailed debugging information about gcore‘s execution.
  • -e: Include environment variables – Preserves the process environment variables in the core dump.
  • -h: Help – Displays usage information.
  • -o <path>: Output file override – Specifies a custom output file path, overriding the default.
  • -s: Summary – Generates a summarized version of the core dump, saving space and time.
  • -t <threads>: Limit threads – Specifies the maximum number of threads to include in the core dump (default: all threads).
  • -u <username>: Unprivileged – Runs gcore as the specified user, if permitted.
  • -v: Version – Displays version information about gcore.


Simple usage

To generate a core dump for a process with the PID 1234 and save it to the file my_core.dump:

gcore -o my_core.dump 1234

Complete debugging information

To create a core dump with complete debugging information, including the command line, environment variables, and detailed output:

gcore -c -e -d 1234

Common Issues

  • Permission denied: Ensure that you have sufficient permissions to create and write to the core dump file location.
  • Process not found: Verify that the specified PID is valid and that the process is still running.
  • Core file too large: Use the -s option to generate a summarized core dump if the default size is too large.


gcore complements a range of debugging tools and workflows. It can be used with:

  • Debuggers like GDB for analyzing core dumps in detail.
  • Error reporting systems to gather core dumps automatically for remote analysis.
  • Testing frameworks to generate core dumps when tests fail for easier debugging.

Related Commands

  • gdb: A powerful debugger that can analyze core dumps.
  • kill and pkill: Commands to terminate processes, often used to trigger core dump generation.
  • ulimit: A command to set resource limits, including core dump size.