Re: [PATCH] Support gzip compressed exec and core files in gdb

Michael Eager
2015-03-27T15:26:31Z

[-- Attachment #1: Type: text/plain, Size: 2448 bytes --]

Removed binutils@sourceware.org.

On 03/20/15 15:16, Mike Frysinger wrote:
> On 18 Mar 2015 17:58, Michael Eager wrote:
>> --- a/gdb/utils.c
>> +++ b/gdb/utils.c
>>
>> +#define COMPRESS_BUF_SIZE (1024*1024)
>
> space around the *
>
> would be nice to have a comment noting where the 1MiB comes from

I added a comment, but the buffer size is arbitrary.

>> + /* Create temporary file name for uncompressed file. */
>> + if (!(tmpdir = getenv ("TMPDIR")))
>> + tmpdir = "/tmp";
>> +
>> + if (!asprintf (&template, "%s/%s-XXXXXX", tmpdir, basename (filename)))
>> + return 0;
>> +
>> + decomp_fd = mkstemp (template);
>
> ignoring that assigningments in if statements are frowned upon, looks like you
> can just use make_temp_file(NULL) from libiberty

Fixed assignment. make_temp_file() generates an anonymous file; I want to
keep the user-specified file name as part of the uncompressed file name.
(I could update libiberty to add an alternate to make_temp_file() which
takes a basename, I guess.) I replaced getenv("TMPDIR") with choose_tmpdir()
from libiberty.

> you would also leak the fopen() handle here. probably want to go through this
> code again looking for such leaks. and maybe try breaking the func up into more
> utility related chunks when possible.

I refactored the gdb_uncompress() function and broke it into 3 functions.

> you've got more missing tabs in this file. i'm going to stop checking.

I cleaned up the white space. I hope I got all the tabs this time.

gdb/ChangeLog:
* utils.c (struct compressed_file_cache_search, eq_compressed_file,
is_gzip, decompress_gzip, do_compressed_cleanup, identify_compression,
uncompress_to_temporary, gdb_uncompress): New.
* utils.h (gdb_uncompress): Declare.
* corelow.c (core_open): Uncompress core file.
* exec.c (exec_file_attach): Uncompress exec file.
* symfile.c (symfile_bfd_open): Uncompress sym (exec) file.
* NEWS: Mention new functionality.

gdb/doc:
* gdb.texinfo (Files): Mention gzipped exec and core files.

I'm not fond of whitespace patches, but there were many whitespace errors
in these files unrelated to my patch. I've attached a second patch to clean
this up.

gdb/ChangeLog:
* corelow.c: Replace leading whitespace with tabs, eliminate trailing blanks.
* exec.c: Ditto.
* symfile.c: Ditto.
* utils.c: Ditto
* utils.h: Ditto

--
Michael Eager eager@eagercon.com
1960 Park Blvd., Palo Alto, CA 94306 650-325-8077

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-GDB-support-compressed-exec-and-core-files.patch --]
[-- Type: text/x-patch; name="0001-GDB-support-compressed-exec-and-core-files.patch", Size: 12454 bytes --]

From a2a0b14bda48e9e2af9842029d7774001e2e9132 Mon Sep 17 00:00:00 2001
From: Michael Eager <eager@eagercon.com>
Date: Thu, 26 Mar 2015 16:55:59 -0700
Subject: [PATCH 1/2] GDB support compressed exec and core files.

Add support to automatically unzip compressed executable and core files.
Files will be uncompressed into temporary directory (/tmp or $TMPDIR)
and are deleted when GDB exits. This should be transparent to users,
except for disk space requirements. The name of the uncompressed file is
mentioned, but all references to the file in GDB messages is to the file
which the user specified.

gdb/ChangeLog:
* utils.c (struct compressed_file_cache_search, eq_compressed_file,
is_gzip, decompress_gzip, do_compressed_cleanup, identify_compression,
uncompress_to_temporar, gdb_uncompress): New.
* utils.h (gdb_uncompress): Declare.
* corelow.c (core_open): Uncompress core file.
* exec.c (exec_file_attach): Uncompress exec file.
* symfile.c (symfile_bfd_open): Uncompress sym (exec) file.
* NEWS: Mention new functionality.

gdb/doc:
* gdb.texinfo (Files): Mention gzipped exec and core files.
---
gdb/NEWS | 3 +
gdb/corelow.c | 11 ++-
gdb/doc/gdb.texinfo | 5 ++
gdb/exec.c | 14 +++-
gdb/symfile.c | 13 +++-
gdb/utils.c | 221 ++++++++++++++++++++++++++++++++++++++++++++++++++++
gdb/utils.h | 4 +
7 files changed, 268 insertions(+), 3 deletions(-)

diff --git a/gdb/NEWS b/gdb/NEWS
index bda4a35..b132196 100644
--- a/gdb/NEWS
+++ b/gdb/NEWS
@@ -89,6 +89,9 @@ vFile:fstat:

* Removed targets and native configurations

+* GDB will automatically uncompress executable and core files
+ which have been compressed using gzip.
+
HP/PA running HP-UX hppa*-*-hpux*
Itanium running HP-UX ia64-*-hpux*

diff --git a/gdb/corelow.c b/gdb/corelow.c
index 9218003..8211595 100644
--- a/gdb/corelow.c
+++ b/gdb/corelow.c
@@ -279,6 +279,7 @@ core_open (const char *arg, int from_tty)
int scratch_chan;
int flags;
char *filename;
+ char *uncompressed_filename;

target_preopen (from_tty);
if (!arg)
@@ -310,12 +311,20 @@ core_open (const char *arg, int from_tty)
if (scratch_chan < 0)
perror_with_name (filename);

- temp_bfd = gdb_bfd_fopen (filename, gnutarget,
+ temp_bfd = gdb_bfd_fopen (filename, gnutarget,
write_files ? FOPEN_RUB : FOPEN_RB,
scratch_chan);
if (temp_bfd == NULL)
perror_with_name (filename);

+ if (!write_files && gdb_uncompress (filename, &uncompressed_filename))
+ {
+ close (scratch_chan);
+ scratch_chan = gdb_open_cloexec (uncompressed_filename, flags, 0);
+ temp_bfd = gdb_bfd_fopen (uncompressed_filename, gnutarget,
+ FOPEN_RB, scratch_chan);
+ }
+
if (!bfd_check_format (temp_bfd, bfd_core)
&& !gdb_check_format (temp_bfd))
{
diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo
index 9e71642..4c9c3f3 100644
--- a/gdb/doc/gdb.texinfo
+++ b/gdb/doc/gdb.texinfo
@@ -17375,6 +17375,11 @@ via @code{gdbserver} (@pxref{Server, file, Using the @code{gdbserver}
Program}). In these situations the @value{GDBN} commands to specify
new files are useful.

+Executable and core files may be compressed using @command{gzip}. These
+files will be uncompressed into temporary files in the system-wide
+temporary directory (e.g., @file{/tmp} on some systems). The files will
+have a unique name and will be deleted when @value{GDBN} terminates.
+
@table @code
@cindex executable file
@kindex file
diff --git a/gdb/exec.c b/gdb/exec.c
index b1f6157..4b84d65 100644
--- a/gdb/exec.c
+++ b/gdb/exec.c
@@ -155,6 +155,7 @@ void
exec_file_attach (const char *filename, int from_tty)
{
struct cleanup *cleanups;
+ char *uncompressed_filename = NULL;

/* First, acquire a reference to the current exec_bfd. We release
this at the end of the function; but acquiring it now lets the
@@ -209,7 +210,18 @@ exec_file_attach (const char *filename, int from_tty)
exec_bfd = gdb_bfd_fopen (canonical_pathname, gnutarget,
FOPEN_RUB, scratch_chan);
else
- exec_bfd = gdb_bfd_open (canonical_pathname, gnutarget, scratch_chan);
+ {
+ if (!gdb_uncompress (canonical_pathname, &uncompressed_filename))
+ exec_bfd = gdb_bfd_open (canonical_pathname, gnutarget, scratch_chan);
+ else
+ {
+ close (scratch_chan);
+ scratch_chan = openp ("", 0, uncompressed_filename,
+ O_RDONLY | O_BINARY, &scratch_pathname);
+
+ exec_bfd = gdb_bfd_open (uncompressed_filename, gnutarget, scratch_chan);
+ }
+ }

if (!exec_bfd)
{
diff --git a/gdb/symfile.c b/gdb/symfile.c
index bd3a366..e24517f 100644
--- a/gdb/symfile.c
+++ b/gdb/symfile.c
@@ -56,6 +56,7 @@
#include "stack.h"
#include "gdb_bfd.h"
#include "cli/cli-utils.h"
+#include "utils.h"

#include <sys/types.h>
#include <fcntl.h>
@@ -1744,6 +1745,7 @@ symfile_bfd_open (const char *cname)
bfd *sym_bfd;
int desc;
char *name, *absolute_name;
+ char *uncompressed_filename;
struct cleanup *back_to;

if (remote_filename_p (cname))
@@ -1788,7 +1790,16 @@ symfile_bfd_open (const char *cname)
name = absolute_name;
back_to = make_cleanup (xfree, name);

- sym_bfd = gdb_bfd_open (name, gnutarget, desc);
+ if (!gdb_uncompress (name, &uncompressed_filename))
+ sym_bfd = gdb_bfd_open (name, gnutarget, desc);
+ else
+ {
+ close (desc);
+ desc = openp ("", 0, uncompressed_filename, O_RDONLY | O_BINARY, &absolute_name);
+
+ sym_bfd = gdb_bfd_open (uncompressed_filename, gnutarget, desc);
+ }
+
if (!sym_bfd)
error (_("`%s': can't open to read symbols: %s."), name,
bfd_errmsg (bfd_get_error ()));
diff --git a/gdb/utils.c b/gdb/utils.c
index 7172bba..e9f86e5 100644
--- a/gdb/utils.c
+++ b/gdb/utils.c
@@ -29,6 +29,10 @@
#include <sys/resource.h>
#endif /* HAVE_SYS_RESOURCE_H */

+#ifdef HAVE_ZLIB_H
+#include <zlib.h>
+#endif
+
#ifdef TUI
#include "tui/tui.h" /* For tui_get_command_dimension. */
#endif
@@ -126,6 +130,10 @@ int immediate_quit;
as octal escapes. Zero means just print the value (e.g. it's an
international character, and the terminal or window can cope.) */

+/* Type of file compression. */
+
+enum file_compression_t {NONE, GZIP, BZIP2};
+
int sevenbit_strings = 0;
static void
show_sevenbit_strings (struct ui_file *file, int from_tty,
@@ -3486,6 +3494,219 @@ gdb_filename_fnmatch (const char *pattern, const char *string, int flags)

return fnmatch (pattern, string, flags);
}
+\f
+#ifdef HAVE_ZLIB_H
+/* Hash table of compressed files. */
+
+static htab_t compressed_file_cache;
+
+struct compressed_file_cache_search
+{
+ char *filename;
+ char *uncompressed_filename;
+ time_t mtime;
+};
+
+static int
+eq_compressed_file (const void *a, const void *b)
+{
+ const struct compressed_file_cache_search *entry = a;
+ const struct compressed_file_cache_search *search = b;
+
+ return (strcmp (entry->filename, search->filename) == 0);
+}
+#endif
+
+/* Test if file is compressed with gzip. */
+
+static inline int
+is_gzip (unsigned char *buf)
+{
+ return (buf[0] == 037 && buf[1] == 0213); /* From /usr/share/magic. */
+}
+
+/* Alloc 1Mb buffer to uncompress data. */
+#define COMPRESS_BUF_SIZE (1024 * 1024)
+static int
+decompress_gzip (const char *filename, FILE *tmp)
+{
+#ifdef HAVE_ZLIB_H
+ char *buf = xmalloc (COMPRESS_BUF_SIZE);
+ gzFile compressed = gzopen (filename, "r");
+ int count, res;
+
+ if (buf == NULL || compressed == NULL)
+ {
+ fprintf_filtered (gdb_stderr, _("error copying gzip file\n"));
+ free (buf);
+ return 0;
+ }
+
+ while ((count = gzread (compressed, buf, COMPRESS_BUF_SIZE)))
+ {
+ res = fwrite (buf, 1, count, tmp);
+ if (res != count)
+ {
+ fprintf_filtered (gdb_stderr, _("error decompressing gzip file\n"));
+ free (buf);
+ return 0;
+ }
+ }
+
+ gzclose (compressed);
+ free (buf);
+ return 1;
+#else
+ return 0;
+#endif
+}
+
+/* Delete uncompressed temp file when terminating. */
+static void
+do_compressed_cleanup (void *filename)
+{
+ unlink (filename);
+ xfree (filename);
+}
+
+/* Identify type of file compression used. */
+static enum file_compression_t
+identify_compression (const char *filename)
+{
+ FILE *handle;
+ enum file_compression_t file_compression = NONE;
+ unsigned char buffer[1024];
+ size_t count;
+
+ handle = fopen (filename, FOPEN_RB);
+ if (handle == NULL)
+ return 0;
+
+ count = fread (buffer, 1, sizeof buffer, handle);
+ if (count > 0)
+ {
+ if (is_gzip (buffer))
+ file_compression = GZIP;
+ }
+
+ fclose (handle);
+
+ return file_compression;
+}
+
+/* Uncompress into temporary file. Return temp file name. */
+static char *
+uncompress_to_temporary (const char *filename)
+{
+ enum file_compression_t file_compression;
+ char *template;
+ int ret = 0;
+ int decomp_fd;
+ FILE *decomp_file;
+
+ file_compression = identify_compression (filename);
+ if (file_compression != GZIP)
+ /* Only gzip supported at this time. */
+ return NULL;
+
+ /* Create temporary file name for uncompressed file. */
+ if (!asprintf (&template, "%s%s-XXXXXX", choose_tmpdir (),
+ basename (filename)))
+ return NULL;
+
+ decomp_fd = mkstemp (template);
+ if (decomp_fd == -1)
+ return NULL;
+
+ decomp_file = fdopen (decomp_fd, FOPEN_WUB);
+
+ if (file_compression == GZIP)
+ {
+ printf (_("Decompressing %s to %s\n"), filename, template);
+ ret = decompress_gzip (filename, decomp_file);
+ }
+
+ if (!ret)
+ {
+ xfree (template);
+ template = NULL;
+ }
+
+ fclose (decomp_file);
+ return template;
+}
+
+/* If file is compressed, uncompress it into a temporary. */
+int
+gdb_uncompress (const char *filename, char **uncompressed_filename)
+{
+ struct compressed_file_cache_search search, *found;
+ struct stat st;
+ hashval_t hash;
+ void **slot;
+ char *temp_filename;
+
+ if (compressed_file_cache == NULL)
+ compressed_file_cache = htab_create_alloc (1, htab_hash_string,
+ eq_compressed_file,
+ NULL, xcalloc, xfree);
+ if (stat (filename, &st) < 0)
+ return 0;
+
+ search.filename = (char *) filename;
+ search.uncompressed_filename = NULL;
+
+ hash = htab_hash_string (filename);
+ found = htab_find_with_hash (compressed_file_cache, &search, hash);
+
+ if (found)
+ {
+ /* We previously uncompressed the file. */
+ if (found->mtime == st.st_mtime)
+ {
+ /* Return file if compressed file not changed. */
+ *uncompressed_filename = found->uncompressed_filename;
+ return 1;
+ }
+ else
+ {
+ /* Delete old uncompressed file. */
+ unlink (found->uncompressed_filename);
+ xfree (found->filename);
+ xfree (found->uncompressed_filename);
+ }
+ }
+
+ temp_filename = uncompress_to_temporary (filename);
+ if (temp_filename)
+ {
+ if (!found)
+ {
+ slot = htab_find_slot_with_hash (compressed_file_cache,
+ &search, hash, INSERT);
+ gdb_assert (slot && !*slot);
+ found = xmalloc (sizeof (struct compressed_file_cache_search));
+ *slot = found;
+ }
+
+ found->filename = strdup (filename);
+ found->mtime = st.st_mtime;
+ found->uncompressed_filename = temp_filename;
+ }
+ else
+ {
+ warning (_("Decompression failed\n"));
+ return 0;
+ }
+
+ /* Schedule delete of temp file when gdb ends. */
+ make_final_cleanup (do_compressed_cleanup, xstrdup (temp_filename));
+
+ *uncompressed_filename = temp_filename;
+
+ return 1;
+}
+\f

/* Provide a prototype to silence -Wmissing-prototypes. */
extern initialize_file_ftype _initialize_utils;
diff --git a/gdb/utils.h b/gdb/utils.h
index b8e1aff..10d9c08 100644
--- a/gdb/utils.h
+++ b/gdb/utils.h
@@ -367,4 +367,8 @@ extern void dump_core (void);

extern char *make_hex_string (const gdb_byte *data, size_t length);

+/* Uncompress file if compressed. */
+
+int gdb_uncompress (const char *filename, char **uncompressed_filename);
+
#endif /* UTILS_H */
--
1.8.1.4

[-- Attachment #3: 0002-GDB-Fix-leading-trailing-whitespace.patch --]
[-- Type: text/x-patch, Size: 21452 bytes --]

From 1cee9b02f6821921de761a33c7ee7e78b73f85b9 Mon Sep 17 00:00:00 2001
From: Michael Eager <eager@eagercon.com>
Date: Thu, 26 Mar 2015 17:18:02 -0700
Subject: [PATCH 2/2] GDB - Fix leading & trailing whitespace

* corelow.c: Replace leading whitespace with tabs, eliminate trailing blanks.
* exec.c: Ditto.
* symfile.c: Ditto.
* utils.c: Ditto
* utils.h: Ditto
---
gdb/corelow.c | 10 +++++-----
gdb/exec.c | 22 ++++++++++-----------
gdb/symfile.c | 62 +++++++++++++++++++++++++++++------------------------------
gdb/utils.c | 60 ++++++++++++++++++++++++++++-----------------------------
gdb/utils.h | 4 ++--
5 files changed, 79 insertions(+), 79 deletions(-)

diff --git a/gdb/corelow.c b/gdb/corelow.c
index 8211595..ee5b872 100644
--- a/gdb/corelow.c
+++ b/gdb/corelow.c
@@ -198,7 +198,7 @@ core_close (struct target_ops *self)
exit_inferior_silent (pid);

/* Clear out solib state while the bfd is still open. See
- comments in clear_solib in solib.c. */
+ comments in clear_solib in solib.c. */
clear_solib ();

if (core_data)
@@ -330,8 +330,8 @@ core_open (const char *arg, int from_tty)
{
/* Do it after the err msg */
/* FIXME: should be checking for errors from bfd_close (for one
- thing, on error it does not free all the storage associated
- with the bfd). */
+ thing, on error it does not free all the storage associated
+ with the bfd). */
make_cleanup_bfd_unref (temp_bfd);
error (_("\"%s\" is not a core dump: %s"),
filename, bfd_errmsg (bfd_get_error ()));
@@ -954,7 +954,7 @@ core_read_description (struct target_ops *target)
{
const struct target_desc *result;

- result = gdbarch_core_read_description (core_gdbarch,
+ result = gdbarch_core_read_description (core_gdbarch,
target, core_bfd);
if (result != NULL)
return result;
@@ -1055,7 +1055,7 @@ init_core_ops (void)
core_ops.to_magic = OPS_MAGIC;

if (core_target)
- internal_error (__FILE__, __LINE__,
+ internal_error (__FILE__, __LINE__,
_("init_core_ops: core target already exists (\"%s\")."),
core_target->to_longname);
core_target = &core_ops;
diff --git a/gdb/exec.c b/gdb/exec.c
index 4b84d65..b3c1459 100644
--- a/gdb/exec.c
+++ b/gdb/exec.c
@@ -1,4 +1,4 @@
-/* Work with executable files, for GDB.
+/* Work with executable files, for GDB.

Copyright (C) 1988-2015 Free Software Foundation, Inc.

@@ -171,7 +171,7 @@ exec_file_attach (const char *filename, int from_tty)
if (!filename)
{
if (from_tty)
- printf_unfiltered (_("No executable file now.\n"));
+ printf_unfiltered (_("No executable file now.\n"));

set_gdbarch_from_file (NULL);
}
@@ -283,7 +283,7 @@ exec_file_attach (const char *filename, int from_tty)
Note that we have to explicitly ignore additional args, since we can
be called from file_command(), which also calls symbol_file_command()
which can take multiple args.
-
+
If ARGS is NULL, we just want to close the exec file. */

static void
@@ -302,16 +302,16 @@ exec_file_command (char *args, int from_tty)
struct cleanup *cleanups;

/* Scan through the args and pick up the first non option arg
- as the filename. */
+ as the filename. */

argv = gdb_buildargv (args);
cleanups = make_cleanup_freeargv (argv);

for (; (*argv != NULL) && (**argv == '-'); argv++)
- {;
- }
+ {;
+ }
if (*argv == NULL)
- error (_("No executable file name was specified"));
+ error (_("No executable file name was specified"));

filename = tilde_expand (*argv);
make_cleanup (xfree, filename);
@@ -716,7 +716,7 @@ section_table_xfer_memory_partial (gdb_byte *readbuf, const gdb_byte *writebuf,
if (section_name && strcmp (section_name, asect->name) != 0)
continue; /* not the section we need. */
if (memaddr >= p->addr)
- {
+ {
if (memend <= p->endaddr)
{
/* Entire transfer is within this section. */
@@ -762,7 +762,7 @@ section_table_xfer_memory_partial (gdb_byte *readbuf, const gdb_byte *writebuf,
else
return TARGET_XFER_EOF;
}
- }
+ }
}

return TARGET_XFER_EOF; /* We can't help. */
@@ -832,8 +832,8 @@ print_section_info (struct target_section_table *t, bfd *abfd)
warning (_("Cannot find section for the entry point of %s."),
bfd_get_filename (abfd));

- entry_point = gdbarch_addr_bits_remove (gdbarch,
- bfd_get_start_address (abfd)
+ entry_point = gdbarch_addr_bits_remove (gdbarch,
+ bfd_get_start_address (abfd)
+ displacement);
printf_filtered (_("\tEntry point: %s\n"),
paddress (gdbarch, entry_point));
diff --git a/gdb/symfile.c b/gdb/symfile.c
index e24517f..37ea11c 100644
--- a/gdb/symfile.c
+++ b/gdb/symfile.c
@@ -265,7 +265,7 @@ alloc_section_addr_info (size_t num_sections)

extern struct section_addr_info *
build_section_addr_info_from_section_table (const struct target_section *start,
- const struct target_section *end)
+ const struct target_section *end)
{
struct section_addr_info *sap;
const struct target_section *stp;
@@ -507,7 +507,7 @@ relative_addr_info_to_section_offsets (struct section_offsets *section_offsets,

/* Record all sections in offsets. */
/* The section_offsets in the objfile are here filled in using
- the BFD index. */
+ the BFD index. */
section_offsets->offsets[osp->sectindex] = osp->addr;
}
}
@@ -918,7 +918,7 @@ init_entry_point_info (struct objfile *objfile)
if (bfd_get_file_flags (objfile->obfd) & EXEC_P)
{
/* Executable file -- record its entry point so we'll recognize
- the startup file because it contains the entry point. */
+ the startup file because it contains the entry point. */
ei->entry_point = bfd_get_start_address (objfile->obfd);
ei->entry_point_p = 1;
}
@@ -1017,7 +1017,7 @@ syms_from_objfile_1 (struct objfile *objfile,

objfile->num_sections = num_sections;
objfile->section_offsets
- = obstack_alloc (&objfile->objfile_obstack, size);
+ = obstack_alloc (&objfile->objfile_obstack, size);
memset (objfile->section_offsets, 0, size);
return;
}
@@ -1039,7 +1039,7 @@ syms_from_objfile_1 (struct objfile *objfile,
if (mainline)
{
/* We will modify the main symbol table, make sure that all its users
- will be cleaned up if an error occurs during symbol reading. */
+ will be cleaned up if an error occurs during symbol reading. */
make_cleanup (clear_symtab_users_cleanup, 0 /*ignore*/);

/* Since no error yet, throw away the old symbol table. */
@@ -1051,9 +1051,9 @@ syms_from_objfile_1 (struct objfile *objfile,
}

/* Currently we keep symbols from the add-symbol-file command.
- If the user wants to get rid of them, they should do "symbol-file"
- without arguments first. Not sure this is the best behavior
- (PR 2207). */
+ If the user wants to get rid of them, they should do "symbol-file"
+ without arguments first. Not sure this is the best behavior
+ (PR 2207). */

(*objfile->sf->sym_new_init) (objfile);
}
@@ -1279,8 +1279,8 @@ symbol_file_add_separate (bfd *bfd, const char *name, int symfile_flags,

struct objfile *
symbol_file_add_from_bfd (bfd *abfd, const char *name, int add_flags,
- struct section_addr_info *addrs,
- int flags, struct objfile *parent)
+ struct section_addr_info *addrs,
+ int flags, struct objfile *parent)
{
return symbol_file_add_with_addrs (abfd, name, add_flags, addrs, flags,
parent);
@@ -2137,9 +2137,9 @@ generic_load (const char *args, int from_tty)
cbdata.load_offset = strtoulst (argv[1], &endptr, 0);

/* If the last word was not a valid number then
- treat it as a file name with spaces in. */
+ treat it as a file name with spaces in. */
if (argv[1] == endptr)
- error (_("Invalid download offset:%s."), argv[1]);
+ error (_("Invalid download offset:%s."), argv[1]);

if (argv[2] != NULL)
error (_("Too many parameters."));
@@ -2392,7 +2392,7 @@ add_symbol_file_command (char *args, int from_tty)
addr = parse_and_eval_address (val);

/* Here we store the section offsets in the order they were
- entered on the command line. */
+ entered on the command line. */
section_addrs->other[sec_num].name = sec;
section_addrs->other[sec_num].addr = addr;
printf_unfiltered ("\t%s_addr = %s\n", sec,
@@ -2751,7 +2751,7 @@ reread_symbols (void)
observer_notify_new_objfile (objfile);

/* At least one objfile has changed, so we can consider that
- the executable we're debugging has changed too. */
+ the executable we're debugging has changed too. */
observer_notify_executable_changed ();
}

@@ -3181,7 +3181,7 @@ section_is_mapped (struct obj_section *osect)
return 0; /* overlay debugging off */
case ovly_auto: /* overlay debugging automatic */
/* Unles there is a gdbarch_overlay_update function,
- there's really nothing useful to do here (can't really go auto). */
+ there's really nothing useful to do here (can't really go auto). */
gdbarch = get_objfile_arch (osect->objfile);
if (gdbarch_overlay_update_p (gdbarch))
{
@@ -3434,7 +3434,7 @@ map_overlay_command (char *args, int from_tty)
sec->ovly_mapped = 1;

/* Next, make a pass and unmap any sections that are
- overlapped by this new section: */
+ overlapped by this new section: */
ALL_OBJSECTIONS (objfile2, sec2)
if (sec2->ovly_mapped && sec != sec2 && sections_overlap (sec, sec2))
{
@@ -3630,8 +3630,8 @@ simple_read_overlay_table (void)
if (! novlys_msym.minsym)
{
error (_("Error reading inferior's overlay table: "
- "couldn't find `_novlys' variable\n"
- "in inferior. Use `overlay manual' mode."));
+ "couldn't find `_novlys' variable\n"
+ "in inferior. Use `overlay manual' mode."));
return 0;
}

@@ -3639,8 +3639,8 @@ simple_read_overlay_table (void)
if (! ovly_table_msym.minsym)
{
error (_("Error reading inferior's overlay table: couldn't find "
- "`_ovly_table' array\n"
- "in inferior. Use `overlay manual' mode."));
+ "`_ovly_table' array\n"
+ "in inferior. Use `overlay manual' mode."));
return 0;
}

@@ -3654,8 +3654,8 @@ simple_read_overlay_table (void)
= (void *) xmalloc (cache_novlys * sizeof (*cache_ovly_table));
cache_ovly_table_base = BMSYMBOL_VALUE_ADDRESS (ovly_table_msym);
read_target_long_array (cache_ovly_table_base,
- (unsigned int *) cache_ovly_table,
- cache_novlys * 4, word_size, byte_order);
+ (unsigned int *) cache_ovly_table,
+ cache_novlys * 4, word_size, byte_order);

return 1; /* SUCCESS */
}
@@ -3779,7 +3779,7 @@ symfile_dummy_outputs (bfd *abfd, asection *sectp, void *dummy)

bfd_byte *
default_symfile_relocate (struct objfile *objfile, asection *sectp,
- bfd_byte *buf)
+ bfd_byte *buf)
{
/* Use sectp->owner instead of objfile->obfd. sectp may point to a
DWO file. */
@@ -3813,7 +3813,7 @@ default_symfile_relocate (struct objfile *objfile, asection *sectp,

bfd_byte *
symfile_relocate_debug_section (struct objfile *objfile,
- asection *sectp, bfd_byte *buf)
+ asection *sectp, bfd_byte *buf)
{
gdb_assert (objfile->sf->sym_relocate);

@@ -3881,17 +3881,17 @@ symfile_map_offsets_to_segments (bfd *abfd,
gdb_assert (0 <= which && which <= data->num_segments);

/* Don't bother computing offsets for sections that aren't
- loaded as part of any segment. */
+ loaded as part of any segment. */
if (! which)
- continue;
+ continue;

/* Use the last SEGMENT_BASES entry as the address of any extra
- segments mentioned in DATA->segment_info. */
+ segments mentioned in DATA->segment_info. */
if (which > num_segment_bases)
- which = num_segment_bases;
+ which = num_segment_bases;

offsets->offsets[i] = (segment_bases[which - 1]
- - data->segment_bases[which - 1]);
+ - data->segment_bases[which - 1]);
}

return 1;
@@ -4087,9 +4087,9 @@ Set printing of symbol loading messages."), _("\
Show printing of symbol loading messages."), _("\
off == turn all messages off\n\
brief == print messages for the executable,\n\
- and brief messages for shared libraries\n\
+ and brief messages for shared libraries\n\
full == print messages for the executable,\n\
- and messages for each shared library."),
+ and messages for each shared library."),
NULL,
NULL,
&setprintlist, &showprintlist);
diff --git a/gdb/utils.c b/gdb/utils.c
index e9f86e5..1bc4fa7 100644
--- a/gdb/utils.c
+++ b/gdb/utils.c
@@ -696,13 +696,13 @@ internal_vproblem (struct internal_problem *problem,
abort_with_message (msg);
default:
dejavu = 3;
- /* Newer GLIBC versions put the warn_unused_result attribute
- on write, but this is one of those rare cases where
- ignoring the return value is correct. Casting to (void)
- does not fix this problem. This is the solution suggested
- at http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25509. */
+ /* Newer GLIBC versions put the warn_unused_result attribute
+ on write, but this is one of those rare cases where
+ ignoring the return value is correct. Casting to (void)
+ does not fix this problem. This is the solution suggested
+ at http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25509. */
if (write (STDERR_FILENO, msg, sizeof (msg)) != sizeof (msg))
- abort (); /* NOTE: GDB has only three calls to abort(). */
+ abort (); /* NOTE: GDB has only three calls to abort(). */
exit (1);
}
}
@@ -751,7 +751,7 @@ internal_vproblem (struct internal_problem *problem,
if (!confirm || !filtered_printing_initialized ())
quit_p = 1;
else
- quit_p = query (_("%s\nQuit this debugging session? "), reason);
+ quit_p = query (_("%s\nQuit this debugging session? "), reason);
}
else if (problem->should_quit == internal_problem_yes)
quit_p = 1;
@@ -1058,7 +1058,7 @@ quit (void)
#else
if (job_control
/* If there is no terminal switching for this target, then we can't
- possibly get screwed by the lack of job control. */
+ possibly get screwed by the lack of job control. */
|| !target_supports_terminal_ours ())
throw_quit ("Quit");
else
@@ -1299,15 +1299,15 @@ defaulted_query (const char *ctlstr, const char defchar, va_list args)
if (answer >= 'a')
answer -= 040;
/* Check answer. For the non-default, the user must specify
- the non-default explicitly. */
+ the non-default explicitly. */
if (answer == not_def_answer)
{
retval = !def_value;
break;
}
/* Otherwise, if a default was specified, the user may either
- specify the required input or have it default by entering
- nothing. */
+ specify the required input or have it default by entering
+ nothing. */
if (answer == def_answer
|| (defchar != '\0' && answer == '\0'))
{
@@ -1323,7 +1323,7 @@ defaulted_query (const char *ctlstr, const char defchar, va_list args)
gettimeofday (&prompt_ended, NULL);
timeval_sub (&prompt_delta, &prompt_ended, &prompt_started);
timeval_add (&prompt_for_continue_wait_time,
- &prompt_for_continue_wait_time, &prompt_delta);
+ &prompt_for_continue_wait_time, &prompt_delta);

xfree (prompt);
if (annotation_level > 1)
@@ -1686,8 +1686,8 @@ init_page_info (void)
chars_per_line = cols;

/* Readline should have fetched the termcap entry for us.
- Only try to use tgetnum function if rl_get_screen_size
- did not return a useful value. */
+ Only try to use tgetnum function if rl_get_screen_size
+ did not return a useful value. */
if (((rows <= 0) && (tgetnum ("li") < 0))
/* Also disable paging if inside EMACS. */
|| getenv ("EMACS"))
@@ -1745,7 +1745,7 @@ struct cleanup *
set_batch_flag_and_make_cleanup_restore_page_info (void)
{
struct cleanup *back_to = make_cleanup_restore_page_info ();
-
+
make_cleanup_restore_integer (&batch_flag);
batch_flag = 1;
init_page_info ();
@@ -1826,7 +1826,7 @@ prompt_for_continue (void)
strcat (cont_prompt, "\n\032\032prompt-for-continue\n");

/* We must do this *before* we call gdb_readline, else it will eventually
- call us -- thinking that we're trying to print beyond the end of the
+ call us -- thinking that we're trying to print beyond the end of the
screen. */
reinitialize_more_filter ();

@@ -1852,7 +1852,7 @@ prompt_for_continue (void)
gettimeofday (&prompt_ended, NULL);
timeval_sub (&prompt_delta, &prompt_ended, &prompt_started);
timeval_add (&prompt_for_continue_wait_time,
- &prompt_for_continue_wait_time, &prompt_delta);
+ &prompt_for_continue_wait_time, &prompt_delta);

if (annotation_level > 1)
printf_unfiltered (("\n\032\032post-prompt-for-continue\n"));
@@ -1960,11 +1960,11 @@ wrap_here (char *indent)
}
}

-/* Print input string to gdb_stdout, filtered, with wrap,
+/* Print input string to gdb_stdout, filtered, with wrap,
arranging strings in columns of n chars. String can be
- right or left justified in the column. Never prints
+ right or left justified in the column. Never prints
trailing spaces. String should never be longer than
- width. FIXME: this could be useful for the EXAMINE
+ width. FIXME: this could be useful for the EXAMINE
command, which currently doesn't tabulate very well. */

void
@@ -2075,8 +2075,8 @@ fputs_maybe_filtered (const char *linebuffer, struct ui_file *stream,
else
fputc_unfiltered ('\t', stream);
/* Shifting right by 3 produces the number of tab stops
- we have already passed, and then adding one and
- shifting left 3 advances to the next tab stop. */
+ we have already passed, and then adding one and
+ shifting left 3 advances to the next tab stop. */
chars_printed = ((chars_printed >> 3) + 1) << 3;
lineptr++;
}
@@ -2097,8 +2097,8 @@ fputs_maybe_filtered (const char *linebuffer, struct ui_file *stream,
chars_printed = 0;
lines_printed++;
/* If we aren't actually wrapping, don't output newline --
- if chars_per_line is right, we probably just overflowed
- anyway; if it's wrong, let us keep going. */
+ if chars_per_line is right, we probably just overflowed
+ anyway; if it's wrong, let us keep going. */
if (wrap_column)
fputc_unfiltered ('\n', stream);

@@ -2638,7 +2638,7 @@ strcmp_iw_ordered (const char *string1, const char *string2)

if (case_pass == case_sensitive_on)
return 0;
-
+
/* Otherwise the strings were equal in case insensitive way, make
a more fine grained comparison in a case sensitive way. */

@@ -2918,7 +2918,7 @@ gdb_realpath_keepfile (const char *filename)
char *real_path;
char *result;

- /* Extract the basename of filename, and return immediately
+ /* Extract the basename of filename, and return immediately
a copy of filename if it does not contain any directory prefix. */
if (base_name == filename)
return xstrdup (filename);
@@ -3196,7 +3196,7 @@ gdb_bfd_errmsg (bfd_error_type error_tag, char **matching)
return bfd_errmsg (error_tag);

ret_len = strlen (bfd_errmsg (error_tag)) + strlen (AMBIGUOUS_MESS1)
- + strlen (AMBIGUOUS_MESS2);
+ + strlen (AMBIGUOUS_MESS2);
for (p = matching; *p; p++)
ret_len += strlen (*p) + 1;
ret = xmalloc (ret_len + 1);
@@ -3302,9 +3302,9 @@ producer_is_gcc (const char *producer, int *major, int *minor)
*/
cs = &producer[strlen ("GNU ")];
while (*cs && !isspace (*cs))
- cs++;
+ cs++;
if (*cs && isspace (*cs))
- cs++;
+ cs++;
if (sscanf (cs, "%d.%d", major, minor) == 2)
return 1;
}
@@ -3356,7 +3356,7 @@ substitute_path_component (char **stringp, const char *from, const char *to)

if ((s == string || IS_DIR_SEPARATOR (s[-1])
|| s[-1] == DIRNAME_SEPARATOR)
- && (s[from_len] == '\0' || IS_DIR_SEPARATOR (s[from_len])
+ && (s[from_len] == '\0' || IS_DIR_SEPARATOR (s[from_len])
|| s[from_len] == DIRNAME_SEPARATOR))
{
char *string_new;
diff --git a/gdb/utils.h b/gdb/utils.h
index 10d9c08..33ed914 100644
--- a/gdb/utils.h
+++ b/gdb/utils.h
@@ -77,8 +77,8 @@ extern struct cleanup *
make_cleanup_ui_out_redirect_pop (struct ui_out *uiout);

struct section_addr_info;
-extern struct cleanup *(make_cleanup_free_section_addr_info
- (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);

--
1.8.1.4