aboutsummaryrefslogtreecommitdiff
path: root/gas/listing.c
diff options
context:
space:
mode:
authorNick Clifton <nickc@redhat.com>2003-12-19 15:23:41 +0000
committerNick Clifton <nickc@redhat.com>2003-12-19 15:23:41 +0000
commit5a1964ecbd3d7a66c626e2bb5edd7780b99f5aa9 (patch)
treed74dd9613386288ff8eb98abd1c5b449c20b30de /gas/listing.c
parent10ecffb9b24b79b6a9f373d0c9df0f4c447864a5 (diff)
downloadgdb-5a1964ecbd3d7a66c626e2bb5edd7780b99f5aa9.zip
gdb-5a1964ecbd3d7a66c626e2bb5edd7780b99f5aa9.tar.gz
gdb-5a1964ecbd3d7a66c626e2bb5edd7780b99f5aa9.tar.bz2
Fix calls to as_perror() so that the errno system message will be printed.
Fix as_perror() so that errno is not corrupted.
Diffstat (limited to 'gas/listing.c')
-rw-r--r--gas/listing.c149
1 files changed, 66 insertions, 83 deletions
diff --git a/gas/listing.c b/gas/listing.c
index 635cb3a..aa22c5e 100644
--- a/gas/listing.c
+++ b/gas/listing.c
@@ -1,27 +1,26 @@
/* listing.c - maintain assembly listings
Copyright 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
- 2001, 2002
+ 2001, 2002, 2003
Free Software Foundation, Inc.
-This file is part of GAS, the GNU Assembler.
+ This file is part of GAS, the GNU Assembler.
-GAS 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 2, or (at your option)
-any later version.
+ GAS 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 2, or (at your option)
+ any later version.
-GAS 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.
+ GAS 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 GAS; see the file COPYING. If not, write to the Free
-Software Foundation, 59 Temple Place - Suite 330, Boston, MA
-02111-1307, USA. */
+ You should have received a copy of the GNU General Public License
+ along with GAS; see the file COPYING. If not, write to the Free
+ Software Foundation, 59 Temple Place - Suite 330, Boston, MA
+ 02111-1307, USA. */
-/*
- Contributed by Steve Chamberlain <sac@cygnus.com>
+/* Contributed by Steve Chamberlain <sac@cygnus.com>
A listing page looks like:
@@ -88,8 +87,7 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA
LISTING_LHS_CONT_LINES Max number of lines to use up for a continuation
LISTING_RHS_WIDTH Number of chars from the input file to print
- on a line
-*/
+ on a line. */
#include "as.h"
#include "obstack.h"
@@ -119,7 +117,8 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA
#endif
/* This structure remembers which .s were used. */
-typedef struct file_info_struct {
+typedef struct file_info_struct
+{
struct file_info_struct * next;
char * filename;
long pos;
@@ -129,12 +128,14 @@ typedef struct file_info_struct {
/* This structure remembers which line from which file goes into which
frag. */
-struct list_info_struct {
+struct list_info_struct
+{
/* Frag which this line of source is nearest to. */
fragS *frag;
/* The actual line in the source file. */
unsigned int line;
+
/* Pointer to the file info struct for the file which this line
belongs to. */
file_info_type *file;
@@ -148,21 +149,23 @@ struct list_info_struct {
/* Pointer to the file info struct for the high level language
source line that belongs here. */
file_info_type *hll_file;
+
/* High level language source line. */
unsigned int hll_line;
/* Pointer to any error message associated with this line. */
char *message;
- enum {
- EDICT_NONE,
- EDICT_SBTTL,
- EDICT_TITLE,
- EDICT_NOLIST,
- EDICT_LIST,
- EDICT_NOLIST_NEXT,
- EDICT_EJECT
- } edict;
+ enum
+ {
+ EDICT_NONE,
+ EDICT_SBTTL,
+ EDICT_TITLE,
+ EDICT_NOLIST,
+ EDICT_LIST,
+ EDICT_NOLIST_NEXT,
+ EDICT_EJECT
+ } edict;
char *edict_arg;
/* Nonzero if this line is to be omitted because it contains
@@ -204,19 +207,17 @@ static FILE *list_file;
static char *data_buffer;
/* Prototypes. */
-static void listing_message (const char *name, const char *message);
-static file_info_type *file_info (const char *file_name);
+static void listing_message (const char *, const char *);
+static file_info_type *file_info (const char *);
static void new_frag (void);
-static char *buffer_line (file_info_type *file, char *line, unsigned int size);
-static void listing_page (list_info_type *list);
-static unsigned int calc_hex (list_info_type *list);
-static void print_lines (list_info_type *, unsigned int,
- char *, unsigned int);
+static char *buffer_line (file_info_type *, char *, unsigned int);
+static void listing_page (list_info_type *);
+static unsigned int calc_hex (list_info_type *);
+static void print_lines (list_info_type *, unsigned int, char *, unsigned int);
static void list_symbol_table (void);
-static void print_source (file_info_type *current_file, list_info_type *list,
- char *buffer, unsigned int width);
+static void print_source (file_info_type *, list_info_type *, char *, unsigned int);
static int debugging_pseudo (list_info_type *, const char *);
-static void listing_listing (char *name);
+static void listing_listing (char *);
static void
listing_message (const char *name, const char *message)
@@ -257,8 +258,7 @@ file_info (const char *file_name)
}
/* Make new entry. */
-
- p = (file_info_type *) xmalloc (sizeof (file_info_type));
+ p = xmalloc (sizeof (file_info_type));
p->next = file_info_head;
file_info_head = p;
p->filename = xstrdup (file_name);
@@ -272,10 +272,8 @@ file_info (const char *file_name)
static void
new_frag (void)
{
-
frag_wane (frag_now);
frag_new (0);
-
}
void
@@ -373,7 +371,7 @@ listing_newline (char *ps)
}
else
{
- new = (list_info_type *) xmalloc (sizeof (list_info_type));
+ new = xmalloc (sizeof (list_info_type));
new->line_contents = ps;
}
@@ -591,9 +589,7 @@ calc_hex (list_info_type *list)
&& data_buffer_size < MAX_BYTES - 3)
{
if (address == ~(unsigned int) 0)
- {
- address = frag_ptr->fr_address / OCTETS_PER_BYTE;
- }
+ address = frag_ptr->fr_address / OCTETS_PER_BYTE;
sprintf (data_buffer + data_buffer_size,
"%02X",
@@ -612,9 +608,8 @@ calc_hex (list_info_type *list)
&& data_buffer_size < MAX_BYTES - 3)
{
if (address == ~(unsigned int) 0)
- {
- address = frag_ptr->fr_address / OCTETS_PER_BYTE;
- }
+ address = frag_ptr->fr_address / OCTETS_PER_BYTE;
+
sprintf (data_buffer + data_buffer_size,
"%02X",
(frag_ptr->fr_literal[var_rep_idx]) & 0xff);
@@ -861,6 +856,7 @@ print_source (file_info_type *current_file, list_info_type *list,
&& !current_file->at_end)
{
char *p = buffer_line (current_file, buffer, width);
+
fprintf (list_file, "%4u:%-13s **** %s\n", current_file->linenum,
current_file->filename, p);
on_page++;
@@ -933,7 +929,6 @@ debugging_pseudo (list_info_type *list, const char *line)
return 1;
if (strncmp (line, "tag", 3) == 0)
return 1;
-
if (strncmp (line, "stabs", 5) == 0)
return 1;
if (strncmp (line, "stabn", 5) == 0)
@@ -963,7 +958,6 @@ listing_listing (char *name ATTRIBUTE_UNUSED)
if (list->next)
list->frag = list->next->frag;
list = list->next;
-
}
list = head->next;
@@ -1025,24 +1019,19 @@ listing_listing (char *name ATTRIBUTE_UNUSED)
message = 0;
if (list->hll_file)
- {
- current_hll_file = list->hll_file;
- }
+ current_hll_file = list->hll_file;
if (current_hll_file && list->hll_line && (listing & LISTING_HLL))
- {
- print_source (current_hll_file, list, buffer, width);
- }
+ print_source (current_hll_file, list, buffer, width);
if (list->line_contents)
{
if (!((listing & LISTING_NODEBUG)
&& debugging_pseudo (list, list->line_contents)))
- {
- print_lines (list,
- list->file->linenum == 0 ? list->line : list->file->linenum,
- list->line_contents, calc_hex (list));
- }
+ print_lines (list,
+ list->file->linenum == 0 ? list->line : list->file->linenum,
+ list->line_contents, calc_hex (list));
+
free (list->line_contents);
list->line_contents = NULL;
}
@@ -1067,9 +1056,7 @@ listing_listing (char *name ATTRIBUTE_UNUSED)
}
if (list->edict == EDICT_EJECT)
- {
- eject = 1;
- }
+ eject = 1;
}
if (list->edict == EDICT_NOLIST_NEXT && show_listing == 1)
@@ -1103,6 +1090,9 @@ listing_print (char *name)
using_stdout = 0;
else
{
+#ifdef BFD_ASSEMBLER
+ bfd_set_error (bfd_error_system_call);
+#endif
as_perror (_("can't open list file: %s"), name);
list_file = stdout;
using_stdout = 1;
@@ -1110,30 +1100,27 @@ listing_print (char *name)
}
if (listing & LISTING_NOFORM)
- {
- paper_height = 0;
- }
+ paper_height = 0;
if (listing & LISTING_LISTING)
- {
- listing_listing (name);
- }
+ listing_listing (name);
if (listing & LISTING_SYMBOLS)
- {
- list_symbol_table ();
- }
+ list_symbol_table ();
if (! using_stdout)
{
if (fclose (list_file) == EOF)
- as_perror (_("error closing list file: %s"), name);
+ {
+#ifdef BFD_ASSEMBLER
+ bfd_set_error (bfd_error_system_call);
+#endif
+ as_perror (_("error closing list file: %s"), name);
+ }
}
if (last_open_file)
- {
- fclose (last_open_file);
- }
+ fclose (last_open_file);
}
void
@@ -1337,25 +1324,21 @@ listing_title (int depth)
void
listing_file (const char *name)
{
-
}
void
listing_newline (char *name)
{
-
}
void
listing_source_line (unsigned int n)
{
-
}
void
listing_source_file (const char *n)
{
-
}
#endif