mirror of
https://github.com/espressif/binutils-gdb.git
synced 2025-06-25 13:27:26 +08:00
Make gdbreplay use more common routines
This makes gdbreplay share a bit more code with gdbserver, and paves the way to share more in future. Including common-defs.h pulls in defines and headers that gdb and gdbserver assume are always defined/available too, such as for example _(), ansidecl.h or a set of system headers. Including that revealed (static vs extern conflict) gdbreplay had a local copy of perror_with_name (which exited directly instead of throwing an error). So I removed gdbreplay's local copy, and then added enough .o files until gdbreplay linked successfully. Also, use xstrdup instead of strdup. gdb/gdbserver/ChangeLog: 2018-06-08 Pedro Alves <palves@redhat.com> * Makefile.in (GDBREPLAY_OBS): Add common/cleanups.o, common/common-exceptions.o, common/common-utils.o, common/errors.o, common/print-utils.o and utils.o. * gdbreplay.c: Include "common-defs.h" instead of the two 'config.h's here. Don't include stdio.h, errno.h, stdlib.h, string.h or alloca.h. (perror_with_name): Delete. (remote_open): Use xstrdup instead of strdup. (main): Rename to ... (captured_main): ... this. (main): New.
This commit is contained in:
@ -1,3 +1,17 @@
|
|||||||
|
2018-06-08 Pedro Alves <palves@redhat.com>
|
||||||
|
|
||||||
|
* Makefile.in (GDBREPLAY_OBS): Add common/cleanups.o,
|
||||||
|
common/common-exceptions.o, common/common-utils.o,
|
||||||
|
common/errors.o, common/print-utils.o and utils.o.
|
||||||
|
* gdbreplay.c: Include "common-defs.h" instead of the two
|
||||||
|
'config.h's here. Don't include stdio.h, errno.h, stdlib.h,
|
||||||
|
string.h or alloca.h.
|
||||||
|
(perror_with_name): Delete.
|
||||||
|
(remote_open): Use xstrdup instead of strdup.
|
||||||
|
(main): Rename to ...
|
||||||
|
(captured_main): ... this.
|
||||||
|
(main): New.
|
||||||
|
|
||||||
2018-06-08 Tom Tromey <tom@tromey.com>
|
2018-06-08 Tom Tromey <tom@tromey.com>
|
||||||
|
|
||||||
* linux-low.c (linux_low_read_btrace): Update.
|
* linux-low.c (linux_low_read_btrace): Update.
|
||||||
|
@ -284,7 +284,16 @@ OBS = \
|
|||||||
$(LIBOBJS) \
|
$(LIBOBJS) \
|
||||||
$(XML_BUILTIN)
|
$(XML_BUILTIN)
|
||||||
|
|
||||||
GDBREPLAY_OBS = gdbreplay.o version.o
|
GDBREPLAY_OBS = \
|
||||||
|
common/cleanups.o \
|
||||||
|
common/common-exceptions.o \
|
||||||
|
common/common-utils.o \
|
||||||
|
common/errors.o \
|
||||||
|
common/print-utils.o \
|
||||||
|
gdbreplay.o \
|
||||||
|
utils.o \
|
||||||
|
version.o
|
||||||
|
|
||||||
GDBSERVER_LIBS = @GDBSERVER_LIBS@
|
GDBSERVER_LIBS = @GDBSERVER_LIBS@
|
||||||
XM_CLIBS = @LIBS@
|
XM_CLIBS = @LIBS@
|
||||||
CDEPS = $(srcdir)/proc-service.list
|
CDEPS = $(srcdir)/proc-service.list
|
||||||
|
@ -17,11 +17,9 @@
|
|||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||||
|
|
||||||
#include "config.h"
|
#include "common-defs.h"
|
||||||
#include "build-gnulib-gdbserver/config.h"
|
|
||||||
#include "version.h"
|
#include "version.h"
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
#if HAVE_SYS_FILE_H
|
#if HAVE_SYS_FILE_H
|
||||||
#include <sys/file.h>
|
#include <sys/file.h>
|
||||||
#endif
|
#endif
|
||||||
@ -32,9 +30,6 @@
|
|||||||
#if HAVE_FCNTL_H
|
#if HAVE_FCNTL_H
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#endif
|
#endif
|
||||||
#include <errno.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#ifdef HAVE_NETINET_IN_H
|
#ifdef HAVE_NETINET_IN_H
|
||||||
#include <netinet/in.h>
|
#include <netinet/in.h>
|
||||||
@ -49,8 +44,6 @@
|
|||||||
#include <netinet/tcp.h>
|
#include <netinet/tcp.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <alloca.h>
|
|
||||||
|
|
||||||
#if USE_WIN32API
|
#if USE_WIN32API
|
||||||
#include <winsock2.h>
|
#include <winsock2.h>
|
||||||
#endif
|
#endif
|
||||||
@ -115,32 +108,6 @@ strerror (DWORD error)
|
|||||||
|
|
||||||
#endif /* __MINGW32CE__ */
|
#endif /* __MINGW32CE__ */
|
||||||
|
|
||||||
/* Print the system error message for errno, and also mention STRING
|
|
||||||
as the file name for which the error was encountered.
|
|
||||||
Then return to command level. */
|
|
||||||
|
|
||||||
static void
|
|
||||||
perror_with_name (const char *string)
|
|
||||||
{
|
|
||||||
#ifndef STDC_HEADERS
|
|
||||||
extern int errno;
|
|
||||||
#endif
|
|
||||||
const char *err;
|
|
||||||
char *combined;
|
|
||||||
|
|
||||||
err = strerror (errno);
|
|
||||||
if (err == NULL)
|
|
||||||
err = "unknown error";
|
|
||||||
|
|
||||||
combined = (char *) alloca (strlen (err) + strlen (string) + 3);
|
|
||||||
strcpy (combined, string);
|
|
||||||
strcat (combined, ": ");
|
|
||||||
strcat (combined, err);
|
|
||||||
fprintf (stderr, "\n%s.\n", combined);
|
|
||||||
fflush (stderr);
|
|
||||||
exit (1);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
sync_error (FILE *fp, const char *desc, int expect, int got)
|
sync_error (FILE *fp, const char *desc, int expect, int got)
|
||||||
{
|
{
|
||||||
@ -422,8 +389,11 @@ gdbreplay_usage (FILE *stream)
|
|||||||
fprintf (stream, "Report bugs to \"%s\".\n", REPORT_BUGS_TO);
|
fprintf (stream, "Report bugs to \"%s\".\n", REPORT_BUGS_TO);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
/* Main function. This is called by the real "main" function,
|
||||||
main (int argc, char *argv[])
|
wrapped in a TRY_CATCH that handles any uncaught exceptions. */
|
||||||
|
|
||||||
|
static void ATTRIBUTE_NORETURN
|
||||||
|
captured_main (int argc, char *argv[])
|
||||||
{
|
{
|
||||||
FILE *fp;
|
FILE *fp;
|
||||||
int ch;
|
int ch;
|
||||||
@ -471,3 +441,25 @@ main (int argc, char *argv[])
|
|||||||
remote_close ();
|
remote_close ();
|
||||||
exit (0);
|
exit (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
main (int argc, char *argv[])
|
||||||
|
{
|
||||||
|
TRY
|
||||||
|
{
|
||||||
|
captured_main (argc, argv);
|
||||||
|
}
|
||||||
|
CATCH (exception, RETURN_MASK_ALL)
|
||||||
|
{
|
||||||
|
if (exception.reason == RETURN_ERROR)
|
||||||
|
{
|
||||||
|
fflush (stdout);
|
||||||
|
fprintf (stderr, "%s\n", exception.message);
|
||||||
|
}
|
||||||
|
|
||||||
|
exit (1);
|
||||||
|
}
|
||||||
|
END_CATCH
|
||||||
|
|
||||||
|
gdb_assert_not_reached ("captured_main should never return");
|
||||||
|
}
|
||||||
|
Reference in New Issue
Block a user