debug shared library

Suppose, I debug a *nux application and put a breakpoint into a function defined by a dynamically linked used by the application. Will that breakpoint stop any other application that makes use of the same library?

Thanks
 
When you start a process, the operating system kernel will create some data structures to manage it's information about that process: it will provide and record your process an own heap, stack, file handles, execution indicators (sometimes referred 'instruction pointer'), and some other things. The kernel will share your code(sometimes referred 'text') and const-data sections with similar processes and will reuse shared library code from other processes that have already caused this library to be loaded.

You need to keep in mind that the execution indicator is part of your process information nevertheless, i.e. two processes may be executing two distinct things within the same library without interfering ( unless one of the processes decides to modify a `const` variable or other things that would be considered poorly coded to begin with ) at the same time, and they can also execute the same thing at the same time without you needing to bother about locking memory ranges to processes (as different threads of the same process need) and so on, thanks to each process having it's own and individual heap (and stack) for any variable data, and the shared (const-) data being read-only.

Like the execution indicator is part of a process, the debug attributes also are (and some statistics that can be useful for profiling), so there may be a breakpoint for a process, but there won't be any for other processes unless they were also setuped to have a breakpoint. Against common perception, the processes not being debugged will not even run any slower or something alike, since the debug information is written into sections that are (depending on the format) either unreachable code or const-data.
Also, once a process ran into a breakpoint while in debug mode, it will receive SIGINT (iirc), and be stopped - the execution indicator will be prevented from increasing that is, therefore you won't execute any further instructions. However, the execution indicators of other processes running the same library code are not affected by this (since they didn't receive SIGINT and they also would probably not handle it), and that includes other processes of the same application you're trying to debug, because the trapped execution indicator is part of your process' information and not part of any other processes'.
 
  • Thanks
Reactions: Alt
Back
Top