Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 592831
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T15:46:52+00:00 2026-05-13T15:46:52+00:00

I know how to generate a core dump on OS X when a process

  • 0

I know how to generate a core dump on OS X when a process crashes, but what I really need to do is attach to a process, generate a core dump, then resume that process (without killing it).

A long time ago (maybe a year and a half ago) I had C code that would do this… It used the OS X kernel libraries to connect to a process, read all of its thread states and memory, and write that into a Mach-O file on disk. This worked great (and it’s exactly what I’m looking for), but now I can’t seem to find that code for the life of me. I seem to recall that code was related somewhat to the OS X system internals book, but that’s just a vague recollection.

Does anyone know the code I’m talking about and could point me at it? If not does anyone know a good way of doing this preferably with some example code?

Edit: Here is the answer.

Information: http://osxbook.com/book/bonus/chapter8/core/

Program that will do it for you: http://osxbook.com/book/bonus/chapter8/core/download/gcore-1.3.tar.gz

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T15:46:52+00:00Added an answer on May 13, 2026 at 3:46 pm

    I believe you are looking for this information

    Specifically:

    /* UNIX Third Edition, circa early 1973 */
    /* ken/sig.c */
    
    core()
    {
    int s, *ip;
    extern schar;
    
    /* u is the user area */
    u.u_error = 0;          /* reset error code to "no error" */
    u.u_dirp = "core";      /* file name to search for */
    ip = namei(&schar, 1);  /* do search; schar means it's a kernel string */
    
    if (ip == NULL) {       /* failed to find */
        if (u.u_error)      /* because of some error */
            return(0);      /* so bail out */
        ip = maknode(0666); /* didn't exist; so create it */
    }
    
    if (!access(ip, IWRITE)) { /* check "write" permission; 0 means OK */
        itrunc(ip);            /* truncate the core file */
    
        /* first we write the user area */
        u.u_offset[0] = 0;     /* offset for I/O */
        u.u_offset[1] = 0;     /* offset for I/O */
        u.u_base = &u;         /* base address for I/O (user area itself) */
        u.u_count = USIZE*64;  /* bytes remaining for I/O; USIZE=8 */
        u.u_segflg = 1;        /* specify kernel address space */
        writei(ip);            /* do the write */
    
        /*
         * u_procp points to the process structure
         * p_size is the size of the process's swappable image (x 64 bytes) */
         */
        s = u.u_procp->p_size - USIZE; /* compute size left to write */
        
        /*
         * This sets up software prototype segmentation registers to implement
         * text(=0 here), data(=s here), and stack(=0 here) sizes specified.
         */
        estabur(0, s, 0);
    
        u.u_base = 0;          /* base address for I/O (start of space) */
        u.u_count = s*64;      /* s is in units of 64 bytes, so adjust */
        u.u_segflg = 0;        /* specify user address space */
        writei(ip);            /* do the write */
    }
    iput(ip);                  /* decrement inode reference count */
    return(u.u_error==0);      /* done */
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Do you know how OpenUDID generate unique device ID? Is there any chance that
Does anyone know a C# framework that can generate public/private keys, X.509 certificates and
Do you know an integrated tool that will generate the call graph of a
I have some daemon processes that crashes every now and then and I want
As we know to generate a class file there should be atleast one class
I know how to generate my Localizable.strings file from all the source (*.m) files
I know you can generate all permutations from a list, using glob or Algorithm::Permute
Does anybody know how to generate .mht file programmatically in C#, with embedded images
I would like to know how to generate help files for an applescript studio
anyone know of such stored procs to generate scripts for tables/indexex/views/sp's etc.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.