[11/11,v5] Remove one GDBSERVER use from linux-waitpid.c

Message ID 1406888377-25795-12-git-send-email-gbenson@redhat.com
State Superseded
Headers

Commit Message

Gary Benson Aug. 1, 2014, 10:19 a.m. UTC
  This commit makes nat/linux-waitpid.c include common-defs.h rather
than defs.h or server.h.  A use of GDBSERVER had to be left in to
support some some thread_db debug code.  This hack will be removed
when the Linux thread_db code is unified and made shared.

gdb/
2014-08-01  Gary Benson  <gbenson@redhat.com>

	* nat/linux-waitpid.c: Include common-defs.h.
	Don't include defs.h or server.h.
	(linux_debug) [GDBSERVER]: Declare debug_threads.
---
 gdb/ChangeLog           |    6 ++++++
 gdb/nat/linux-waitpid.c |   10 +++-------
 2 files changed, 9 insertions(+), 7 deletions(-)
  

Comments

Doug Evans Aug. 6, 2014, 6:35 p.m. UTC | #1
Gary Benson writes:
 > This commit makes nat/linux-waitpid.c include common-defs.h rather
 > than defs.h or server.h.  A use of GDBSERVER had to be left in to
 > support some some thread_db debug code.  This hack will be removed
 > when the Linux thread_db code is unified and made shared.
 > 
 > gdb/
 > 2014-08-01  Gary Benson  <gbenson@redhat.com>
 > 
 > 	* nat/linux-waitpid.c: Include common-defs.h.
 > 	Don't include defs.h or server.h.
 > 	(linux_debug) [GDBSERVER]: Declare debug_threads.
 > ---
 >  gdb/ChangeLog           |    6 ++++++
 >  gdb/nat/linux-waitpid.c |   10 +++-------
 >  2 files changed, 9 insertions(+), 7 deletions(-)
 > 
 > diff --git a/gdb/nat/linux-waitpid.c b/gdb/nat/linux-waitpid.c
 > index 53847ac..d04a3af 100644
 > --- a/gdb/nat/linux-waitpid.c
 > +++ b/gdb/nat/linux-waitpid.c
 > @@ -17,13 +17,7 @@
 >     You should have received a copy of the GNU General Public License
 >     along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 >  
 > -#ifdef GDBSERVER
 > -#include "server.h"
 > -#else
 > -#include "defs.h"
 > -#include "signal.h"
 > -#endif
 > -
 > +#include "common-defs.h"
 >  #include "linux-nat.h"
 >  #include "linux-waitpid.h"
 >  #include "gdb_wait.h"
 > @@ -35,6 +29,8 @@ static inline void
 >  linux_debug (const char *format, ...)
 >  {
 >  #ifdef GDBSERVER
 > +  extern int debug_threads;
 > +

Recognizing that this is a temporary hack, ok by me.
Can I ask you to add a FIXME here though?

 >    if (debug_threads)
 >      {
 >        va_list args;
 > -- 
 > 1.7.1
 >
  
Gary Benson Aug. 7, 2014, 12:38 p.m. UTC | #2
Doug Evans wrote:
> Gary Benson writes:
>  > @@ -35,6 +29,8 @@ static inline void
>  >  linux_debug (const char *format, ...)
>  >  {
>  >  #ifdef GDBSERVER
>  > +  extern int debug_threads;
>  > +
> 
> Recognizing that this is a temporary hack, ok by me.
> Can I ask you to add a FIXME here though?

I added:

  /* FIXME: This conditional code and hacky extern are necessary now,
      but should be removed when GDB's and gdbserver's Linux thread_db
      implementations are unified and moved into the nat directory.  */
  
Thanks,
Gary
  
Pedro Alves Aug. 20, 2014, 3:04 p.m. UTC | #3
On 08/07/2014 01:38 PM, Gary Benson wrote:
> Doug Evans wrote:
>> Gary Benson writes:
>>  > @@ -35,6 +29,8 @@ static inline void
>>  >  linux_debug (const char *format, ...)
>>  >  {
>>  >  #ifdef GDBSERVER
>>  > +  extern int debug_threads;
>>  > +
>>
>> Recognizing that this is a temporary hack, ok by me.
>> Can I ask you to add a FIXME here though?
> 
> I added:
> 
>   /* FIXME: This conditional code and hacky extern are necessary now,
>       but should be removed when GDB's and gdbserver's Linux thread_db
>       implementations are unified and moved into the nat directory.  */

No.

This file (linux-waitpid.c) really has nothing to do with thread_db
(glibc interface).  It's part of the kernel/ptrace layer.
If we wanted this particular debug output enabled on GDB, then it'd
be guarded by 'debug_linux_nat' (set debug lin-lwp 1).  There's really
no good reason for GDB and GDBserver to be different here, other than
the history of this waitpid wrapper and how it ended up used in gdb
as well.

The "threads" in "debug_threads" in gdbserver is just a historic wart.
That global really means "global/generic debug traces enabled".
It was the only debug flag that existed in gdbserver for a long
while, and nobody ever renamed it.
  

Patch

diff --git a/gdb/nat/linux-waitpid.c b/gdb/nat/linux-waitpid.c
index 53847ac..d04a3af 100644
--- a/gdb/nat/linux-waitpid.c
+++ b/gdb/nat/linux-waitpid.c
@@ -17,13 +17,7 @@ 
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifdef GDBSERVER
-#include "server.h"
-#else
-#include "defs.h"
-#include "signal.h"
-#endif
-
+#include "common-defs.h"
 #include "linux-nat.h"
 #include "linux-waitpid.h"
 #include "gdb_wait.h"
@@ -35,6 +29,8 @@  static inline void
 linux_debug (const char *format, ...)
 {
 #ifdef GDBSERVER
+  extern int debug_threads;
+
   if (debug_threads)
     {
       va_list args;