LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 03-07-2011, 12:20 PM   #1
pike87
LQ Newbie
 
Registered: Mar 2011
Posts: 7

Rep: Reputation: 0
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
 
Click here to see the post LQ members have rated as the most helpful post in this thread.
Old 03-07-2011, 04:36 PM   #2
Ygrex
Member
 
Registered: Nov 2004
Location: Russia (St.Petersburg)
Distribution: Debian
Posts: 657

Rep: Reputation: 66
sure, other applications should stop by a contagion magic
 
1 members found this post helpful.
Old 03-07-2011, 04:41 PM   #3
johnsfine
Guru
 
Registered: Dec 2007
Distribution: Centos
Posts: 5,051

Rep: Reputation: 1100Reputation: 1100Reputation: 1100Reputation: 1100Reputation: 1100Reputation: 1100Reputation: 1100Reputation: 1100Reputation: 1100
Quote:
Originally Posted by pike87 View Post
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?
No. When your process (or the debugger for your process) writes to a page of the shared area, the kernel copies that whole page (4096 bytes) to give your process a private copy of that page.

Quote:
Originally Posted by Ygrex View Post
sure, other applications should stop by a contagion magic
Sarcasm really wasn't called for. If you know the basics of how shared objects work and you know the basics of how breakpoints work, you would have legitimate reason to be concerned about the issue the OP raised.

Most code pages of a .so are shared by all processes using that .so at the same time. Breakpoints are implemented by the debugger changing a byte of an instruction into a breakpoint instruction. So it is normal to wonder why those two facts don't combine to put that breakpoint instruction into the address space of every process using that .so.

There are a number of different situations in Linux in which a page of virtual memory is shareable by multiple processes as long as none of them write to it, but any process writing to the page gets a private copy. I don't know the exact details of how that mechanism is used for breakpoints in .so mappings, but that is the basic concept.

Last edited by johnsfine; 03-07-2011 at 04:50 PM.
 
2 members found this post helpful.
Old 03-08-2011, 12:26 AM   #4
pike87
LQ Newbie
 
Registered: Mar 2011
Posts: 7

Original Poster
Rep: Reputation: 0
johnsfine, Thanks!

Anyone can give a detailed example please?
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
shared library : libfg.so: cannot open shared object file error 40 x_gaurav Programming 2 06-28-2009 06:29 AM
ldd reports shared library missing, but library exists on disk athv_gr Linux - Newbie 7 05-13-2009 12:31 PM
gcc link shared library against another shared library qcp Linux - Newbie 1 07-25-2008 11:15 AM
LINUX - linking archive (static library) with shared (dynamic) library gurkama Programming 5 03-04-2007 11:11 PM
howto compile bin with my library using all-static and shared linked standart library stpg Programming 4 06-29-2004 04:20 AM


All times are GMT -5. The time now is 11:43 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration