Find the answer to your Linux question:
Results 1 to 5 of 5
Hi, Is there a way to detect if my program is being run under any debugger. I am intrested in detecing below two cases 1. If my running program is ...
  1. #1
    Just Joined!
    Join Date
    Mar 2009
    Posts
    2

    Program being run under debugger

    Hi,
    Is there a way to detect if my program is being run under any debugger. I am intrested in detecing below two cases

    1. If my running program is atttached to some debugger
    2. If my program is started under debugger itself.

    Please share your ideas regarding this.

    Thanks in advance,
    Kris.

  2. #2
    Linux Enthusiast gerard4143's Avatar
    Join Date
    Dec 2007
    Location
    Canada, Prince Edward Island
    Posts
    714
    I don't know your answers outright but you should be able to find most of them be investigating the debug registers and related flags...does Linux have a library or function(s) to accomplish this task? I really don't know...Gerard4143

    Note: AMD/Intel has all their manuals posted on the web
    Make mine Arch Linux

  3. #3
    Just Joined!
    Join Date
    Mar 2009
    Posts
    2
    Thanks gerard4143 for replying . I also have not heard any such function which can access such low level stuff . If at all available, can you brief a bit as of how can we use them to determine if my program is being run under a debugger

    Thanks
    Kristo

  4. #4
    Trusted Penguin Cabhan's Avatar
    Join Date
    Jan 2005
    Location
    Seattle, WA, USA
    Posts
    3,230
    You could check if your problem was started by a debugger by using the getppid() system call to get the parent's PID. Then check /proc/PID/exec (I think that's the symlink) to find out what executable the parent is and check it against a list of known debuggers.

    I don't know about other debuggers (though I suspect they're the same), but gdb does its debugging by using the ptrace() system call. I don't know if a process can tell if it's being traced, but if you can detect this, then you would know if someone is tracing you. In theory, it could be anything, but in practice, it's very likely to be a debugger.
    DISTRO=Arch
    Registered Linux User #388732

  5. #5
    Linux Enthusiast gerard4143's Avatar
    Join Date
    Dec 2007
    Location
    Canada, Prince Edward Island
    Posts
    714
    Maybe I'm getting too low level with this....mmmh you really should investigate gdb's info/man pages and especially look into gdbserver but before you do this you really should strip your executable of all debug symbols...no symbols no debugger....Gerard4143

    But if you insist on low level then I recommend AMD manual "AMD64 Architecture Programmer's Manual Volume 2: System Programming - 13 section Debug and Performance Resources "

    AMD64 Architecture Tech Docs
    Make mine Arch Linux

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...