[9/9,v7] Remove one GDBSERVER use from linux-waitpid.c
Commit Message
This commit makes nat/linux-waitpid.c include common-defs.h rather
than defs.h or server.h. Some debug code previously only built for
gdbserver is now also built for GDB, and a use of GDBSERVER has had
to remain in order to select the variable used to determine whether
debug printing should be enabled.
This patch differs from the version I posted on August 1
(https://sourceware.org/ml/gdb-patches/2014-08/msg00016.html)
in that previously debug printing was only built for gdbserver
(enabled when debug_threads is set) but now it is also built
for GDB (enabled when debug_linux_nat is set). I had to make
debug_linux_nat nonstatic to do this.
gdb/ChangeLog:
* linux-nat.c (debug_linux_nat): Make nonstatic.
* nat/linux-waitpid.c: Include common-defs.h.
Don't include defs.h, server.h or signal.h.
(debug_linux_waitpid): New macro and extern.
(linux_debug): Use debug_linux_waitpid and debug_vprintf.
---
gdb/ChangeLog | 8 ++++++++
gdb/linux-nat.c | 3 ++-
gdb/nat/linux-waitpid.c | 25 +++++++++++++------------
3 files changed, 23 insertions(+), 13 deletions(-)
Comments
On 08/29/2014 02:51 PM, Gary Benson wrote:
>
> -static unsigned int debug_linux_nat;
> +unsigned int debug_linux_nat;
> +
> +#define debug_linux_waitpid debug_linux_nat
> #endif
> +extern int debug_linux_waitpid;
>
The dangers of extern... This ends up undefined code, as
the variable is defined as signed, and then declared here
as signed.
Sorry, but now that I see it, IMO the end up resulting code
doesn't really look better than what we already have. :-/ We
end up with #ifdef GDBSERVER anyway, so might be best to
either leave this be until we come up with a complete solution.
Thanks,
Pedro Alves
@@ -204,7 +204,8 @@ static target_xfer_partial_ftype *super_xfer_partial;
Called by our to_close. */
static void (*super_close) (struct target_ops *);
-static unsigned int debug_linux_nat;
+unsigned int debug_linux_nat;
+
static void
show_debug_linux_nat (struct ui_file *file, int from_tty,
struct cmd_list_element *c, const char *value)
@@ -17,16 +17,20 @@
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
+#include "common-defs.h"
+#include "linux-nat.h"
+#include "linux-waitpid.h"
+#include "gdb_wait.h"
+
+/* FIXME: Need a common variable to select Linux debug output. */
+
#ifdef GDBSERVER
-#include "server.h"
+#define debug_linux_waitpid debug_threads
#else
-#include "defs.h"
-#include "signal.h"
+#define debug_linux_waitpid debug_linux_nat
#endif
-#include "linux-nat.h"
-#include "linux-waitpid.h"
-#include "gdb_wait.h"
+extern int debug_linux_waitpid;
/* Print debugging output based on the format string FORMAT and
its parameters. */
@@ -34,17 +38,14 @@
static inline void
linux_debug (const char *format, ...)
{
-#ifdef GDBSERVER
- if (debug_threads)
+ if (debug_linux_waitpid)
{
va_list args;
+
va_start (args, format);
- vfprintf (stderr, format, args);
+ debug_vprintf (format, args);
va_end (args);
}
-#else
- /* GDB-specific debugging output. */
-#endif
}
/* Convert wait status STATUS to a string. Used for printing debug