From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 7135 invoked by alias); 24 Feb 2011 03:51:32 -0000 Received: (qmail 7126 invoked by uid 22791); 24 Feb 2011 03:51:31 -0000 X-SWARE-Spam-Status: No, hits=-1.8 required=5.0 tests=AWL,BAYES_00,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mail.codesourcery.com (HELO mail.codesourcery.com) (38.113.113.100) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 24 Feb 2011 03:51:26 +0000 Received: (qmail 4148 invoked from network); 24 Feb 2011 03:51:22 -0000 Received: from unknown (HELO ?192.168.0.101?) (yao@127.0.0.2) by mail.codesourcery.com with ESMTPA; 24 Feb 2011 03:51:22 -0000 Message-ID: <4D65D5B7.1000902@codesourcery.com> Date: Thu, 24 Feb 2011 03:58:00 -0000 From: Yao Qi User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.13) Gecko/20101208 Lightning/1.0b2 Thunderbird/3.1.7 MIME-Version: 1.0 To: Tom Tromey CC: Pedro Alves , gdb-patches@sourceware.org Subject: Re: [rfa/rfc] Build libcommon.a for gdb and gdbserver References: <4D30E23F.3080103@codesourcery.com> <4D375F44.70504@codesourcery.com> <201101281504.38962.pedro@codesourcery.com> <4D550834.6080807@codesourcery.com> <4D55FAB4.7090001@codesourcery.com> <4D648A5F.8050607@codesourcery.com> In-Reply-To: Content-Type: multipart/mixed; boundary="------------090803050301060408000303" X-IsSubscribed: yes Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2011-02/txt/msg00670.txt.bz2 This is a multi-part message in MIME format. --------------090803050301060408000303 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Content-length: 2060 On 02/24/2011 12:33 AM, Tom Tromey wrote: > Since then I have been wondering why we need build infrastructure in > common/ at all. It seems to me that it can cause problems, but > conversely doesn't provide much benefit. > I assume the problems here are C macros confusion/conflict, mentioned in http://sourceware.org/ml/gdb-patches/2011-02/msg00466.html AFAICS, the conflict can not happen. When building libcommon, config.h is used from parent directory (gdb or gdbserver). GDB_INCLUDE in common/configure.ac makes sure correct directories are included. The only problem I can see is this: #ifdef GDBSERVER #include "server.h" #else #include "defs.h" #include "gdb_string.h" #endif #ifndef GDBSERVER enum target_signal target_signal_from_command (int num) ... #endif However, IMO, it is not a configure/make problem. The real problem here is we include some gdb-specific code in common. We can fix this problem by moving gdb-specific part to gdb/ dir. Patch attached is for this purpose. > My reasoning is based on the fact that we are going to be building two > libraries for the foreseeable future. It seems to me that it would be > simpler to just integrate the common/ build rules into > gdbserver/Makefile.in and gdb/Makefile.in. > > What do you think of that? I may write a patch to do it. The goal of this piece of work is to remove duplicated source code, and merge them together. However, the complexity of configure/make is underestimated. I am not objecting to Tom's approach, because it is simple. Personally, I still prefer a separated configure/makefile in common/, because, 1. if my patch works, configure/make is not a problem, 2. if we look forward, there should be quite a few *.c and *.h files in common in the future. Write rules in both gdb/Makefile.in and gdbserver/Makefile.in doesn't scale. I am sorry if this change makes some troubles, but it is a right direction we have to go. In short, please review my approach again, and I am not objecting to Tom's approach. -- Yao (齐尧) --------------090803050301060408000303 Content-Type: text/x-patch; name="gdb-specific-signals-0224.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="gdb-specific-signals-0224.patch" Content-length: 5892 gdb/ * common/gdb_signals.h (struct gdb_signal_desc): New. * common/signals.c: Move gdb-specific part to ... * signals.c: ... here. New. * Makefile.in (COMMON_OBS): Add signals.o diff --git a/gdb/Makefile.in b/gdb/Makefile.in index c6049fa..7ce68ff 100644 --- a/gdb/Makefile.in +++ b/gdb/Makefile.in @@ -866,6 +866,7 @@ COMMON_OBS = $(DEPFILES) $(CONFIG_OBS) $(YYOBJ) \ memattr.o mem-break.o target.o parse.o language.o buildsym.o \ findcmd.o \ std-regs.o \ + signals.o \ exec.o reverse.o \ bcache.o objfiles.o observer.o minsyms.o maint.o demangle.o \ dbxread.o coffread.o coff-pe-read.o \ diff --git a/gdb/common/gdb_signals.h b/gdb/common/gdb_signals.h index c04d795..09dd120 100644 --- a/gdb/common/gdb_signals.h +++ b/gdb/common/gdb_signals.h @@ -24,6 +24,12 @@ #include "gdb/signals.h" +struct gdb_signal_desc +{ + const char *name; + const char *string; +}; + /* Predicate to target_signal_to_host(). Return non-zero if the enum targ_signal SIGNO has an equivalent ``host'' representation. */ /* FIXME: cagney/1999-11-22: The name below was chosen in preference diff --git a/gdb/common/signals.c b/gdb/common/signals.c index 3c7ffe4..f87842b 100644 --- a/gdb/common/signals.c +++ b/gdb/common/signals.c @@ -19,13 +19,9 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ -#ifdef GDBSERVER -#include "server.h" -#else -#include "defs.h" -#include "gdb_string.h" -#endif +#include +#include "../config.h" #ifdef HAVE_SIGNAL_H #include #endif @@ -51,10 +47,7 @@ struct gdbarch; /* This table must match in order and size the signals in enum target_signal. */ -static const struct { - const char *name; - const char *string; - } signals [] = +const struct gdb_signal_desc signals [] = { #define SET(symbol, constant, name, string) { name, string }, #include "gdb/signals.def" @@ -651,45 +644,3 @@ target_signal_to_host (enum target_signal oursig) else return targ_signo; } - -#ifndef GDBSERVER - -/* In some circumstances we allow a command to specify a numeric - signal. The idea is to keep these circumstances limited so that - users (and scripts) develop portable habits. For comparison, - POSIX.2 `kill' requires that 1,2,3,6,9,14, and 15 work (and using a - numeric signal at all is obsolescent. We are slightly more - lenient and allow 1-15 which should match host signal numbers on - most systems. Use of symbolic signal names is strongly encouraged. */ - -enum target_signal -target_signal_from_command (int num) -{ - if (num >= 1 && num <= 15) - return (enum target_signal) num; - error ("Only signals 1-15 are valid as numeric signals.\n\ -Use \"info signals\" for a list of symbolic signals."); -} - -extern initialize_file_ftype _initialize_signals; /* -Wmissing-prototype */ - -void -_initialize_signals (void) -{ - if (strcmp (signals[TARGET_SIGNAL_LAST].string, "TARGET_SIGNAL_MAGIC") != 0) - internal_error (__FILE__, __LINE__, "failed internal consistency check"); -} - -int -default_target_signal_to_host (struct gdbarch *gdbarch, enum target_signal ts) -{ - return target_signal_to_host (ts); -} - -enum target_signal -default_target_signal_from_host (struct gdbarch *gdbarch, int signo) -{ - return target_signal_from_host (signo); -} - -#endif /* ! GDBSERVER */ diff --git a/gdb/signals.c b/gdb/signals.c new file mode 100644 index 0000000..512fcfb --- /dev/null +++ b/gdb/signals.c @@ -0,0 +1,64 @@ +/* Target signal translation functions for GDB. + Copyright (C) 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, + 2000, 2001, 2002, 2003, 2006, 2007, 2008, 2009, 2010, 2011 + Free Software Foundation, Inc. + Contributed by Cygnus Support. + + This file is part of GDB. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +#include "defs.h" +#include "gdb_string.h" +#include "gdb_signals.h" + +extern struct gdb_signal_desc *signals; + +/* In some circumstances we allow a command to specify a numeric + signal. The idea is to keep these circumstances limited so that + users (and scripts) develop portable habits. For comparison, + POSIX.2 `kill' requires that 1,2,3,6,9,14, and 15 work (and using a + numeric signal at all is obsolescent. We are slightly more + lenient and allow 1-15 which should match host signal numbers on + most systems. Use of symbolic signal names is strongly encouraged. */ + +enum target_signal +target_signal_from_command (int num) +{ + if (num >= 1 && num <= 15) + return (enum target_signal) num; + error ("Only signals 1-15 are valid as numeric signals.\n\ +Use \"info signals\" for a list of symbolic signals."); +} + +extern initialize_file_ftype _initialize_signals; /* -Wmissing-prototype */ + +void +_initialize_signals (void) +{ + if (strcmp (signals[TARGET_SIGNAL_LAST].string, "TARGET_SIGNAL_MAGIC") != 0) + internal_error (__FILE__, __LINE__, "failed internal consistency check"); +} + +int +default_target_signal_to_host (struct gdbarch *gdbarch, enum target_signal ts) +{ + return target_signal_to_host (ts); +} + +enum target_signal +default_target_signal_from_host (struct gdbarch *gdbarch, int signo) +{ + return target_signal_from_host (signo); +} --------------090803050301060408000303--