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

  • Home
  • SEARCH
  • 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 623329
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T19:04:53+00:00 2026-05-13T19:04:53+00:00

Under linux, can I use GDB to debug a process that is currently running?

  • 0

Under linux, can I use GDB to debug a process that is currently running?

  • 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-13T19:04:53+00:00Added an answer on May 13, 2026 at 7:04 pm

    Yes. Use the attach command. Check out this link for more information. Typing help attach at a GDB console gives the following:

    (gdb) help attach
    

    Attach to a process or file outside of GDB.
    This command attaches to another target, of the same type as your last
    "target" command ("info files" will show your target stack).
    The command may take as argument a process id, a process name
    (with an optional process-id as a suffix), or a device file.
    For a process id, you must have permission to send the process a signal,
    and it must have the same effective uid as the debugger.
    When using "attach" to an existing process, the debugger finds the
    program running in the process, looking first in the current working
    directory, or (if not found there) using the source file search path
    (see the "directory" command). You can also use the "file" command
    to specify the program, and to load its symbol table.


    NOTE: You may have difficulty attaching to a process due to improved security in the Linux kernel – for example attaching to the child of one shell from another.

    You’ll likely need to set /proc/sys/kernel/yama/ptrace_scope depending on your requirements. Many systems now default to 1 or higher.

    The sysctl settings (writable only with CAP_SYS_PTRACE) are:
    
    0 - classic ptrace permissions: a process can PTRACE_ATTACH to any other
        process running under the same uid, as long as it is dumpable (i.e.
        did not transition uids, start privileged, or have called
        prctl(PR_SET_DUMPABLE...) already). Similarly, PTRACE_TRACEME is
        unchanged.
    
    1 - restricted ptrace: a process must have a predefined relationship
        with the inferior it wants to call PTRACE_ATTACH on. By default,
        this relationship is that of only its descendants when the above
        classic criteria is also met. To change the relationship, an
        inferior can call prctl(PR_SET_PTRACER, debugger, ...) to declare
        an allowed debugger PID to call PTRACE_ATTACH on the inferior.
        Using PTRACE_TRACEME is unchanged.
    
    2 - admin-only attach: only processes with CAP_SYS_PTRACE may use ptrace
        with PTRACE_ATTACH, or through children calling PTRACE_TRACEME.
    
    3 - no attach: no processes may use ptrace with PTRACE_ATTACH nor via
        PTRACE_TRACEME. Once set, this sysctl value cannot be changed.
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 316k
  • Answers 316k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer To find characters not on your keyboard, select "Special Characters…"… May 13, 2026 at 11:30 pm
  • Editorial Team
    Editorial Team added an answer System::Threading::Thread::Sleep() as mentioned in another answer. But let me warn… May 13, 2026 at 11:30 pm
  • Editorial Team
    Editorial Team added an answer The most reliable way to unload an unmanaged DLL from… May 13, 2026 at 11:30 pm

Related Questions

In ruby 1.8.5, how can I check for the existence of a named network
I need to read a single file using multiple threads under Linux. There are
I want to check code from the repository http://code.sixapart.com/svn/perlbal/ . I can only access
Duplicate: How to indent a selection in gvim (win32)? How do I indent multiple
I have some directories with a number of hidden files. One example of this

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.