#include "complaints.h"
#include "target.h"
+extern void _initialize_coffread PARAMS ((void));
+
struct coff_symfile_info {
file_ptr min_lineno_offset; /* Where in file lowest line#s are */
file_ptr max_lineno_offset; /* 1+last byte of line#s in file */
static bfd *nlist_bfd_global;
static int nlist_nsyms_global;
-/* Vector of line number information. */
-
-static struct linetable *line_vector;
-
-/* Index of next entry to go in line_vector_index. */
-
-static int line_vector_index;
-
-/* Last line number recorded in the line vector. */
-
-static int prev_line_number;
-
-/* Number of elements allocated for line_vector currently. */
-
-static int line_vector_length;
/* Pointers to scratch storage, used for reading raw symbols and auxents. */
static void coff_start_symtab PARAMS ((char *));
-static void coff_record_line PARAMS ((int, CORE_ADDR));
-
static struct type *coff_alloc_type PARAMS ((int));
static struct type **coff_lookup_type PARAMS ((int));
return type;
}
\f
-/* Record a line number entry for line LINE at address PC.
- FIXME: Use record_line instead. */
-
-static void
-coff_record_line (line, pc)
- int line;
- CORE_ADDR pc;
-{
- struct linetable_entry *e;
- /* Make sure line vector is big enough. */
-
- if (line_vector_index + 2 >= line_vector_length)
- {
- line_vector_length *= 2;
- line_vector = (struct linetable *)
- xrealloc ((char *) line_vector, sizeof (struct linetable)
- + (line_vector_length
- * sizeof (struct linetable_entry)));
- }
-
- e = line_vector->item + line_vector_index++;
- e->line = line; e->pc = pc;
-}
-\f
/* Start a new symtab for a new source file.
This is called when a COFF ".file" symbol is seen;
it indicates the start of data for one original source file. */
last_source_start_addr in coff_end_symtab. */
0);
record_debugformat ("COFF");
-
- /* Initialize the source file line number information for this file. */
-
- if (line_vector) /* Unlikely, but maybe possible? */
- free ((PTR)line_vector);
- line_vector_index = 0;
- line_vector_length = 1000;
- prev_line_number = -2; /* Force first line number to be explicit */
- line_vector = (struct linetable *)
- xmalloc (sizeof (struct linetable)
- + line_vector_length * sizeof (struct linetable_entry));
}
/* Save the vital information from when starting to read a file,
last_source_start_addr = current_source_start_addr;
- /* For no good reason, this file stores the number of entries in a
- separate variable instead of in line_vector->nitems. Fix it. */
- if (line_vector)
- line_vector->nitems = line_vector_index;
-
- /* For COFF, we only have one subfile, so we can just look at
- subfiles and not worry about there being other elements in the
- chain. We fill in various fields now because we didn't know them
- before (or because doing it now is simply an artifact of how this
- file used to be written). */
- subfiles->line_vector = line_vector;
-
symtab = end_symtab (current_source_end_addr, objfile, 0);
if (symtab != NULL)
free_named_symtabs (symtab->filename);
/* Reinitialize for beginning of new file. */
- line_vector = 0;
- line_vector_length = -1;
last_source_file = NULL;
}
\f
/* Set a few file-statics that give us specific information about
the particular COFF file format we're reading. */
- local_linesz = cdata->local_linesz;
local_n_btmask = cdata->local_n_btmask;
local_n_btshft = cdata->local_n_btshft;
local_n_tmask = cdata->local_n_tmask;
if (info->stabsects)
{
+ if (! info->stabstrsect)
+ {
+ error_begin ();
+ fprintf_filtered
+ (gdb_stderr,
+ ("The debugging information in `%s' is corrupted.\n"
+ "The file has a `.stabs' section, but no `.stabstr' section.\n"),
+ name);
+ return_to_top_level (RETURN_ERROR);
+ }
+
/* FIXME: dubious. Why can't we use something normal like
bfd_get_section_contents? */
bfd_seek (abfd, abfd->where, 0);
char *filestring = "";
int depth = 0;
int fcn_first_line = 0;
+ CORE_ADDR fcn_first_line_addr;
int fcn_last_line = 0;
int fcn_start_addr = 0;
long fcn_line_ptr = 0;
info is available. */
case C_LABEL:
/* However, labels within a function can make weird backtraces,
- so filter them out (from phdm@macquel.be). */
+ so filter them out (from phdm@macqel.be). */
if (within_function)
break;
case C_STAT:
if (cs->c_naux != 1)
complain (&bf_no_aux_complaint, cs->c_symnum);
fcn_first_line = main_aux.x_sym.x_misc.x_lnsz.x_lnno;
+ fcn_first_line_addr = cs->c_value;
/* Might want to check that locals are 0 and
context_stack_depth is zero, and complain if not. */
{
fcn_last_line = main_aux.x_sym.x_misc.x_lnsz.x_lnno;
}
- enter_linenos (fcn_line_ptr, fcn_first_line, fcn_last_line,
- section_offsets);
+ /* fcn_first_line is the line number of the opening '{'.
+ Do not record it - because it would affect gdb's idea
+ of the line number of the first statement of the function -
+ except for one-line functions, for which it is also the line
+ number of all the statements and of the closing '}', and
+ for which we do not have any other statement-line-number. */
+ if (fcn_last_line == 1)
+ record_line (current_subfile, fcn_first_line,
+ fcn_first_line_addr);
+ else
+ enter_linenos (fcn_line_ptr, fcn_first_line, fcn_last_line,
+ section_offsets);
finish_block (new->name, &local_symbols, new->old_blocks,
new->start_addr,
rawptr += local_linesz;
/* The next function, or the sentinel, will have L_LNNO32 zero; we exit. */
if (L_LNNO32 (&lptr) && L_LNNO32 (&lptr) <= last_line)
- coff_record_line (first_line + L_LNNO32 (&lptr),
+ record_line (current_subfile, first_line + L_LNNO32 (&lptr),
lptr.l_addr.l_paddr
+ ANOFFSET (section_offsets, SECT_OFF_TEXT));
else