From: Gary Benson <gbenson@redhat.com>
To: gdb-patches@sourceware.org
Cc: "Eli Zaretskii" <eliz@gnu.org>, "Pedro Alves" <palves@redhat.com>,
"Doug Evans" <dje@google.com>,
"Iago López Galeiras" <iago@endocode.com>
Subject: [PATCH 1/9 v2] Move make_cleanup_close to common code
Date: Thu, 30 Apr 2015 14:12:00 -0000 [thread overview]
Message-ID: <1430395542-16017-2-git-send-email-gbenson@redhat.com> (raw)
In-Reply-To: <1429186791-6867-1-git-send-email-gbenson@redhat.com>
This commit moves the function make_cleanup_close from gdb/utils.[ch]
to gdb/common/cleanup-utils.[ch] to make it usable from common code.
A new file was created over putting the function in common-utils.[ch]
to avoid having to build cleanups.c into the in-process agent.
gdb/ChangeLog:
* common/cleanup-utils.h: New file.
* common/cleanup-utils.c: Likewise.
* Makefile.in (SFILES): Add common/cleanup-utils.c.
(HFILES_NO_SRCDIR): Add common/cleanup-utils.h.
(COMMON_OBS): Add cleanup-utils.o.
(cleanup-utils.o): New rule.
* common/common-utils.h (cleanup-utils.h): New include.
* utils.h (make_cleanup_close): Moved to cleanup-utils.h.
* utils.c (do_close_cleanup): Moved to cleanup-utils.c.
(make_cleanup_close): Likewise.
gdb/gdbserver/ChangeLog:
* Makefile.in (SFILES): Add common/cleanup-utils.c.
(OBS): Add cleanup-utils.o.
(cleanup-utils.o): New rule.
---
gdb/ChangeLog | 13 +++++++++++++
gdb/Makefile.in | 12 +++++++++---
gdb/common/cleanup-utils.c | 42 ++++++++++++++++++++++++++++++++++++++++++
gdb/common/cleanup-utils.h | 31 +++++++++++++++++++++++++++++++
gdb/common/common-utils.h | 2 ++
gdb/gdbserver/ChangeLog | 6 ++++++
gdb/gdbserver/Makefile.in | 6 +++++-
gdb/utils.c | 17 -----------------
gdb/utils.h | 2 +-
9 files changed, 109 insertions(+), 22 deletions(-)
create mode 100644 gdb/common/cleanup-utils.c
create mode 100644 gdb/common/cleanup-utils.h
diff --git a/gdb/Makefile.in b/gdb/Makefile.in
index 95104ef..47b216a 100644
--- a/gdb/Makefile.in
+++ b/gdb/Makefile.in
@@ -888,7 +888,7 @@ SFILES = ada-exp.y ada-lang.c ada-typeprint.c ada-valprint.c ada-tasks.c \
common/format.c common/filestuff.c btrace.c record-btrace.c ctf.c \
target/waitstatus.c common/print-utils.c common/rsp-low.c \
common/errors.c common/common-debug.c common/common-exceptions.c \
- common/btrace-common.c common/fileio.c \
+ common/btrace-common.c common/fileio.c common/cleanup-utils.c \
$(SUBDIR_GCC_COMPILE_SRCS)
LINTFILES = $(SFILES) $(YYFILES) $(CONFIG_SRCS) init.c
@@ -979,7 +979,8 @@ i386-linux-nat.h common/common-defs.h common/errors.h common/common-types.h \
common/common-debug.h common/cleanups.h common/gdb_setjmp.h \
common/common-exceptions.h target/target.h common/symbol.h \
common/common-regcache.h fbsd-tdep.h nat/linux-personality.h \
-common/fileio.h nat/x86-linux.h nat/x86-linux-dregs.h
+common/fileio.h nat/x86-linux.h nat/x86-linux-dregs.h \
+common/cleanup-utils.h
# Header files that already have srcdir in them, or which are in objdir.
@@ -1079,7 +1080,7 @@ COMMON_OBS = $(DEPFILES) $(CONFIG_OBS) $(YYOBJ) \
common-utils.o buffer.o ptid.o gdb-dlfcn.o common-agent.o \
format.o registry.o btrace.o record-btrace.o waitstatus.o \
print-utils.o rsp-low.o errors.o common-debug.o debug.o \
- common-exceptions.o btrace-common.o fileio.o \
+ common-exceptions.o btrace-common.o fileio.o cleanup-utils.o \
$(SUBDIR_GCC_COMPILE_OBS)
TSOBS = inflow.o
@@ -2260,6 +2261,11 @@ btrace-common.o: ${srcdir}/common/btrace-common.c
fileio.o: ${srcdir}/common/fileio.c
$(COMPILE) $(srcdir)/common/fileio.c
$(POSTCOMPILE)
+
+cleanup-utils.o: ${srcdir}/common/cleanup-utils.c
+ $(COMPILE) $(srcdir)/common/cleanup-utils.c
+ $(POSTCOMPILE)
+
#
# gdb/target/ dependencies
#
diff --git a/gdb/common/cleanup-utils.c b/gdb/common/cleanup-utils.c
new file mode 100644
index 0000000..829d067
--- /dev/null
+++ b/gdb/common/cleanup-utils.c
@@ -0,0 +1,42 @@
+/* Cleanup utilities for GDB, the GNU debugger.
+
+ Copyright (C) 1986-2015 Free Software Foundation, Inc.
+
+ 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 <http://www.gnu.org/licenses/>. */
+
+#include "common-defs.h"
+#include "cleanup-utils.h"
+
+/* Helper function which does the work for make_cleanup_close. */
+
+static void
+do_close_cleanup (void *arg)
+{
+ int *fd = arg;
+
+ close (*fd);
+}
+
+/* See cleanup-utils.h. */
+
+struct cleanup *
+make_cleanup_close (int fd)
+{
+ int *saved_fd = xmalloc (sizeof (fd));
+
+ *saved_fd = fd;
+ return make_cleanup_dtor (do_close_cleanup, saved_fd, xfree);
+}
diff --git a/gdb/common/cleanup-utils.h b/gdb/common/cleanup-utils.h
new file mode 100644
index 0000000..c5a0d50
--- /dev/null
+++ b/gdb/common/cleanup-utils.h
@@ -0,0 +1,31 @@
+/* Cleanup utilities for GDB, the GNU debugger.
+
+ Copyright (C) 1986-2015 Free Software Foundation, Inc.
+
+ 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 <http://www.gnu.org/licenses/>. */
+
+/* Cleanup utilities. These are not declared in cleanups.h
+ (nor defined in cleanups.c) because, while they use the
+ cleanup API, they are not part of the cleanup API. */
+
+#ifndef CLEANUP_UTILS_H
+#define CLEANUP_UTILS_H
+
+/* Return a new cleanup that closes FD. */
+
+extern struct cleanup *make_cleanup_close (int fd);
+
+#endif /* CLEANUP_UTILS_H */
diff --git a/gdb/common/common-utils.h b/gdb/common/common-utils.h
index cd2665a..dc3ceea 100644
--- a/gdb/common/common-utils.h
+++ b/gdb/common/common-utils.h
@@ -20,6 +20,8 @@
#ifndef COMMON_UTILS_H
#define COMMON_UTILS_H
+#include "cleanup-utils.h"
+
/* If possible, define FUNCTION_NAME, a macro containing the name of
the function being defined. Since this macro may not always be
defined, all uses must be protected by appropriate macro definition
diff --git a/gdb/gdbserver/Makefile.in b/gdb/gdbserver/Makefile.in
index a981ee8..8ba88d4 100644
--- a/gdb/gdbserver/Makefile.in
+++ b/gdb/gdbserver/Makefile.in
@@ -180,7 +180,7 @@ SFILES= $(srcdir)/gdbreplay.c $(srcdir)/inferiors.c $(srcdir)/dll.c \
$(srcdir)/common/common-debug.c $(srcdir)/common/cleanups.c \
$(srcdir)/common/common-exceptions.c $(srcdir)/symbol.c \
$(srcdir)/common/btrace-common.c \
- $(srcdir)/common/fileio.c
+ $(srcdir)/common/fileio.c $(srcdir)/common/cleanup-utils.c
DEPFILES = @GDBSERVER_DEPFILES@
@@ -195,6 +195,7 @@ OBS = agent.o ax.o inferiors.o regcache.o remote-utils.o server.o signals.o \
common-utils.o ptid.o buffer.o format.o filestuff.o dll.o notif.o \
tdesc.o print-utils.o rsp-low.o errors.o common-debug.o cleanups.o \
common-exceptions.o symbol.o btrace-common.o fileio.o \
+ cleanup-utils.o \
$(XML_BUILTIN) $(DEPFILES) $(LIBOBJS)
GDBREPLAY_OBS = gdbreplay.o version.o
GDBSERVER_LIBS = @GDBSERVER_LIBS@
@@ -615,6 +616,9 @@ x86-linux.o: ../nat/x86-linux.c
x86-linux-dregs.o: ../nat/x86-linux-dregs.c
$(COMPILE) $<
$(POSTCOMPILE)
+cleanup-utils.o: ../common/cleanup-utils.c
+ $(COMPILE) $<
+ $(POSTCOMPILE)
aarch64.c : $(srcdir)/../regformats/aarch64.dat $(regdat_sh)
$(SHELL) $(regdat_sh) $(srcdir)/../regformats/aarch64.dat aarch64.c
diff --git a/gdb/utils.c b/gdb/utils.c
index aaaf9c5..1c1ced4 100644
--- a/gdb/utils.c
+++ b/gdb/utils.c
@@ -191,23 +191,6 @@ make_cleanup_bfd_unref (bfd *abfd)
return make_cleanup (do_bfd_close_cleanup, abfd);
}
-static void
-do_close_cleanup (void *arg)
-{
- int *fd = arg;
-
- close (*fd);
-}
-
-struct cleanup *
-make_cleanup_close (int fd)
-{
- int *saved_fd = xmalloc (sizeof (fd));
-
- *saved_fd = fd;
- return make_cleanup_dtor (do_close_cleanup, saved_fd, xfree);
-}
-
/* Helper function which does the work for make_cleanup_fclose. */
static void
diff --git a/gdb/utils.h b/gdb/utils.h
index cae1ac0..423feb5 100644
--- a/gdb/utils.h
+++ b/gdb/utils.h
@@ -80,7 +80,7 @@ struct section_addr_info;
extern struct cleanup *(make_cleanup_free_section_addr_info
(struct section_addr_info *));
-extern struct cleanup *make_cleanup_close (int fd);
+/* For make_cleanup_close see common/cleanup-utils.h. */
extern struct cleanup *make_cleanup_fclose (FILE *file);
--
1.7.1
next prev parent reply other threads:[~2015-04-30 12:41 UTC|newest]
Thread overview: 84+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-04-16 12:19 [PATCH 0/7] GNU/Linux mount namespace support Gary Benson
2015-04-16 12:19 ` [PATCH 4/7] Remove linux_proc_pid_get_ns Gary Benson
2015-04-17 4:36 ` Doug Evans
2015-04-17 13:44 ` Gary Benson
2015-04-16 12:20 ` [PATCH 2/7] Introduce target_fileio_set_fs Gary Benson
2015-04-17 3:04 ` Doug Evans
2015-04-17 13:36 ` Gary Benson
2015-04-17 14:21 ` Pedro Alves
2015-04-17 17:28 ` Doug Evans
2015-04-17 17:46 ` Pedro Alves
2015-04-20 11:11 ` Gary Benson
2015-04-16 12:20 ` [PATCH 1/7] Move make_cleanup_close to common code Gary Benson
2015-04-17 2:47 ` Doug Evans
2015-04-16 12:27 ` [PATCH 6/7] Implement multiple-filesystem support for remote targets Gary Benson
2015-04-16 15:12 ` Eli Zaretskii
2015-04-17 15:06 ` Pedro Alves
2015-04-17 16:00 ` Gary Benson
2015-04-17 16:07 ` Pedro Alves
2015-04-17 16:20 ` Gary Benson
2015-04-17 15:31 ` Pedro Alves
2015-04-17 16:01 ` Gary Benson
2015-04-16 12:34 ` [PATCH 3/7] Introduce nat/linux-namespaces.[ch] Gary Benson
2015-04-17 4:26 ` Doug Evans
2015-04-17 13:41 ` Gary Benson
2015-04-17 14:52 ` Pedro Alves
2015-04-17 17:32 ` Doug Evans
2015-04-20 11:12 ` Gary Benson
2015-04-16 12:54 ` [PATCH 7/7] Implement vFile:setfs in gdbserver Gary Benson
2015-04-17 15:30 ` Pedro Alves
2015-04-17 16:47 ` Gary Benson
2015-04-17 16:29 ` Gary Benson
2015-04-17 17:09 ` Pedro Alves
2015-04-16 13:06 ` [PATCH 5/7] Implement multiple-filesystem support for Linux targets Gary Benson
2015-04-17 15:35 ` [PATCH 0/7] GNU/Linux mount namespace support Pedro Alves
2015-04-20 16:49 ` Iago López Galeiras
2015-04-21 7:56 ` Gary Benson
2015-04-30 12:06 ` [PATCH 5/9 v2] Add "inferior" argument to some target_fileio functions Gary Benson
2015-05-21 14:57 ` Pedro Alves
2015-04-30 12:06 ` [PATCH 3/9 v2] Remove linux_proc_pid_get_ns Gary Benson
2015-05-21 14:56 ` Pedro Alves
2015-04-30 12:06 ` [PATCH 0/9 v2] GNU/Linux mount namespace support Gary Benson
2015-06-10 14:23 ` [pushed][PATCH " Gary Benson
2015-04-30 12:06 ` [PATCH 6/9 v2] Implement mount namespace support for native Linux targets Gary Benson
2015-04-30 16:24 ` Eli Zaretskii
2015-04-30 18:05 ` Gary Benson
2015-05-21 14:59 ` Pedro Alves
2015-05-27 10:16 ` Gary Benson
2015-04-30 12:15 ` [PATCH 4/9 v2] Comment and whitespace changes Gary Benson
2015-05-21 14:57 ` Pedro Alves
2015-04-30 12:41 ` [PATCH 8/9 v2] Implement vFile:setfs in gdbserver Gary Benson
2015-05-21 15:00 ` Pedro Alves
2015-06-09 14:11 ` Gary Benson
2015-06-09 14:23 ` Pedro Alves
2015-06-10 9:01 ` Gary Benson
2015-06-10 9:41 ` Gary Benson
2015-06-10 14:53 ` Pedro Alves
2015-04-30 12:45 ` [PATCH 2/9 v2] Introduce nat/linux-namespaces.[ch] Gary Benson
[not found] ` <20150501000739.740.47967@domU-12-31-39-0A-A0-4F>
2015-05-01 9:28 ` Gary Benson
2015-05-01 13:18 ` Alban Crequy
2015-05-01 20:29 ` Gary Benson
2015-05-06 18:55 ` Alban Crequy
2015-05-07 8:42 ` Gary Benson
2015-05-07 10:39 ` Gary Benson
2015-05-21 14:56 ` Pedro Alves
2015-05-27 10:14 ` Gary Benson
2015-06-11 8:40 ` James Greenhalgh
2015-06-11 11:04 ` Pedro Alves
2015-06-11 12:42 ` [OB PATCH] Use pulongest for printing ssize_t Gary Benson
2015-06-15 15:02 ` [PATCH 2/9 v2] Introduce nat/linux-namespaces.[ch] Michael Eager
2015-06-15 22:12 ` Michael Eager
2015-06-16 8:40 ` Gary Benson
2015-06-16 14:19 ` Michael Eager
2015-06-17 9:51 ` Gary Benson
2016-01-08 10:49 ` Yao Qi
2016-01-11 16:40 ` Gary Benson
2016-01-18 11:44 ` [OB PATCH] Fix gdbserver build failure on targets without fork Gary Benson
2015-04-30 14:12 ` Gary Benson [this message]
2015-05-21 14:56 ` [PATCH 1/9 v2] Move make_cleanup_close to common code Pedro Alves
2015-05-27 9:52 ` Gary Benson
2015-04-30 14:12 ` [PATCH 7/9 v2] Implement multiple-filesystem support for remote targets Gary Benson
2015-04-30 17:10 ` Eli Zaretskii
2015-05-21 15:04 ` Pedro Alves
2015-04-30 14:14 ` [PATCH 9/9 v2] Announce new container-awareness features for GNU/Linux systems Gary Benson
2015-04-30 16:20 ` Eli Zaretskii
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1430395542-16017-2-git-send-email-gbenson@redhat.com \
--to=gbenson@redhat.com \
--cc=dje@google.com \
--cc=eliz@gnu.org \
--cc=gdb-patches@sourceware.org \
--cc=iago@endocode.com \
--cc=palves@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).