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 7038361
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T01:39:35+00:00 2026-05-28T01:39:35+00:00

Say I am writing and compiling a program with user alice. The program is

  • 0

Say I am writing and compiling a program with user alice. The program is then run by user bob on the same machine, but from a location that alice cannot access.

alice@localhost:/home/alice$ g++ helloworld.cpp -o helloworld -g

bob@localhost:/home/bob$ cp ../alice/helloworld .
bob@localhost:/home/bob$ ./helloworld

Now, alice wants to debug what bob is doing. Out of the box, this is not possible:

alice@localhost:/home/alice$ pidof helloworld
1234
alice@localhost:/home/alice$ gdb
[...]
(gdb) attach <pidof helloworld>
Attaching to process 1234
ptrace: Operation not permitted.

What should Alice do?

  • 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-28T01:39:36+00:00Added an answer on May 28, 2026 at 1:39 am

    Remote debugging

    Alice and Bob should use remote debugging. Bob starts gdbserver with specifying the port (in this example port 2345) …

    a) to run the program

    bob@localhost:/home/bob$ gdbserver :2345 ./helloworld
    

    or

    b) to connect to the running process (in this case with the example PID 133245)

    bob@localhost:/home/bob$ gdbserver --attach :2345 133245
    

    And Alice connects to it:

    alice@localhost:/home/alice$ gdb
    [...]
    (gdb) file helloworld
    Reading symbols from /home/alice/helloworld...done.
    (gdb) target remote :2345
    Remote debugging using :2345
    [...]
    0x00007fbdc6329af0 in _start () from /lib64/ld-linux-x86-64.so.2
    

    Remote debugging with absolute paths

    This works in this simple case. However, some more sophistication is required when Bob uses absolute paths for his shared libraries:

    bob@localhost:/home/bob$ ls
    helloworld  libmylib.so
    bob@localhost:/home/bob$ LD_LIBRARY_PATH=/home/bob gdbserver :2345 ./helloworld
    

    Now, alice can’t find the shared library:

    alice@localhost:/home/alice$ gdb
    [...]
    (gdb) file helloworld
    Reading symbols from /home/alice/helloworld...done.
    (gdb) target remote :2345
    Remote debugging using :2345
    [...]
    (gdb) break helloWorld() 
    Breakpoint 1 at 0x400480
    (gdb) c
    Continuing.
    Error while mapping shared library sections:
    /home/bob/libmylib.so: No such file or directory.
    

    To solve this, Alice creates a virtual root folder with links to its on binaries:

    alice@localhost:/home/alice$ mkdir -p gdb-symbols/home/
    alice@localhost:/home/alice$ ln -s /home/alice gdb-symbols/home/bob
    alice@localhost:/home/alice$ ln -s /lib gdb-symbols/lib
    alice@localhost:/home/alice$ ln -s /lib64 gdb-symbols/lib64
    [and so forth for every shared library that cannot be found...]
    

    And is now able to debug with all symbols loaded:

    alice@localhost:/home/alice$ gdb
    [...]
    (gdb) file helloworld
    Reading symbols from /home/alice/helloworld...done.
    (gdb) target remote :2345
    Remote debugging using :2345
    [...]
    Reading symbols from /home/alice/gdb-symbols/home/bob/libmylib.so...done.
    Loaded symbols from /home/alice/gdb-symbols/home/bob/libmylib.so
    (gdb)
    

    As an alternative with reasonable new GDB versions Alice connects with

    (gdb) target extended-remote :2345
    Remote debugging using :2345
    

    and by default GDB will load all the necessary symbols from the server.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Lets say that I am writing a program that supports plugins and I write
Say you are writing an application that must implement the HTTP protocol. Protocols are
Let's say I'm writing a PHP (>= 5.0) class that's meant to be a
Let's say I am writing installation script for the program which contains executable file
That is to say, let's say I'm writing something that's hosted on foo.com .
Say for instance I was writing a function that was designed to accept multiple
Say that you're writing a library to display things on the screen, so you
Say we're writing a simple recursive function fib(n) that calculates the nth Fibonacci number.
I'm writing a python program that deals with a fair amount of strings/files. My
Let's say I am writing a software that needs accesing to WebSphere API -

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.