#define L_INCR 1
#endif
-#include "a.out.gnu.h"
-#include "stab.gnu.h" /* We always use GNU stabs, not native, now */
+#include <obstack.h>
+#include <sys/param.h>
+#include <sys/file.h>
+#include <sys/stat.h>
#include <ctype.h>
+#include "symtab.h"
+#include "breakpoint.h"
+#include "command.h"
+#include "target.h"
+#include "gdbcore.h" /* for bfd stuff */
+#include "libaout.h" /* FIXME Secret internal BFD stuff for a.out */
+#include "symfile.h"
+
+#include "aout64.h"
+#include "stab.gnu.h" /* We always use GNU stabs, not native, now */
#ifndef NO_GNU_STABS
/*
#endif /* NO_GNU_STABS */
-#include <obstack.h>
-#include <sys/param.h>
-#include <sys/file.h>
-#include <sys/stat.h>
-#include "symtab.h"
-#include "breakpoint.h"
-#include "command.h"
-#include "target.h"
-#include "gdbcore.h" /* for bfd stuff */
-#include "libaout.h" /* FIXME Secret internal BFD stuff for a.out */
-#include "symfile.h"
-
struct dbx_symfile_info {
asection *text_sect; /* Text section accessor */
int symcount; /* How many symbols are there in the file */
static char *symfile_string_table;
static int symfile_string_table_size;
- /* Setup a define to deal cleanly with the underscore problem */
+/* The size of each symbol in the symbol file (in external form).
+ This is set by dbx_symfile_read when building psymtabs, and by
+ dbx_psymtab_to_symtab when building symtabs. */
+
+static unsigned symbol_size;
+
+/* Setup a define to deal cleanly with the underscore problem */
#ifdef NAMES_HAVE_UNDERSCORE
#define HASH_OFFSET 1
symfile_bfd = sym_bfd; /* Kludge for SWAP_SYMBOL */
+ /* FIXME POKING INSIDE BFD DATA STRUCTURES */
+ symbol_size = obj_symbol_entry_size (sym_bfd);
+
pending_blocks = 0;
make_cleanup (really_free_pendings, 0);
}
\f
/* Buffer for reading the symbol table entries. */
-static struct nlist symbuf[4096];
+static struct internal_nlist symbuf[4096];
static int symbuf_idx;
static int symbuf_end;
perror_with_name ("<symbol file>");
else if (nbytes == 0)
error ("Premature end of file reading symbol table");
- symbuf_end = nbytes / sizeof (struct nlist);
+ symbuf_end = nbytes / symbol_size;
symbuf_idx = 0;
return 1;
}
#define SWAP_SYMBOL(symp) \
{ \
- (symp)->n_un.n_strx = bfd_h_get_32(symfile_bfd, \
- (unsigned char *)&(symp)->n_un.n_strx); \
+ (symp)->n_strx = bfd_h_get_32(symfile_bfd, \
+ (unsigned char *)&(symp)->n_strx); \
(symp)->n_desc = bfd_h_get_16 (symfile_bfd, \
(unsigned char *)&(symp)->n_desc); \
(symp)->n_value = bfd_h_get_32 (symfile_bfd, \
fill_symbuf ();
symnum++;
SWAP_SYMBOL(&symbuf[symbuf_idx]);
- return symbuf[symbuf_idx++].n_un.n_strx + stringtab_global;
+ return symbuf[symbuf_idx++].n_strx + stringtab_global;
}
\f
/* Initializes storage for all of the partial symbols that will be
CORE_ADDR text_addr;
int text_size;
{
- register struct nlist *bufp;
+ register struct internal_nlist *bufp;
register char *namestring;
register struct partial_symbol *psym;
int nsl;
give a fake name, and print a single error message per symbol file read,
rather than abort the symbol reading or flood the user with messages. */
#define SET_NAMESTRING()\
- if (bufp->n_un.n_strx < 0 || bufp->n_un.n_strx >= stringtab_size) { \
+ if (bufp->n_strx < 0 || bufp->n_strx >= stringtab_size) { \
complain (&string_table_offset_complaint, symnum); \
namestring = "foo"; \
} else \
- namestring = bufp->n_un.n_strx + stringtab
+ namestring = bufp->n_strx + stringtab
/* Add a symbol with an integer value to a psymtab. */
/* This is a macro unless we're debugging. See above this function. */
&& bufp->n_value > pst->textlow)
{
end_psymtab (pst, psymtab_include_list, includes_used,
- symnum * sizeof (struct nlist), bufp->n_value,
+ symnum * symbol_size, bufp->n_value,
dependency_list, dependencies_used,
global_psymbols.next, static_psymbols.next);
pst = (struct partial_symtab *) 0;
if (pst && past_first_source_file)
{
end_psymtab (pst, psymtab_include_list, includes_used,
- first_symnum * sizeof (struct nlist), valu,
+ first_symnum * symbol_size, valu,
dependency_list, dependencies_used,
global_psymbols.next, static_psymbols.next);
pst = (struct partial_symtab *) 0;
pst = start_psymtab (symfile_name, addr,
namestring, valu,
- first_symnum * sizeof (struct nlist),
+ first_symnum * symbol_size,
global_psymbols.next, static_psymbols.next);
continue;
}
if (pst)
{
end_psymtab (pst, psymtab_include_list, includes_used,
- symnum * sizeof (struct nlist), end_of_text_addr,
+ symnum * symbol_size, end_of_text_addr,
dependency_list, dependencies_used,
global_psymbols.next, static_psymbols.next);
includes_used = 0;
return;
}
- /* Read in all partial symbtabs on which this one is dependent */
+ /* Read in all partial symtabs on which this one is dependent */
for (i = 0; i < pst->number_of_dependencies; i++)
if (!pst->dependencies[i]->readin)
{
}
symfile_bfd = sym_bfd; /* Kludge for SWAP_SYMBOL */
+ /* FIXME POKING INSIDE BFD DATA STRUCTURES */
+ symbol_size = obj_symbol_entry_size (sym_bfd);
/* FIXME, this uses internal BFD variables. See above in
dbx_symbol_file_open where the macro is defined! */
int offset;
{
register char *namestring;
- struct nlist *bufp;
+ struct internal_nlist *bufp;
unsigned char type;
+ unsigned max_symnum;
subfile_stack = 0;
stringtab_global = stringtab;
Detecting this in read_dbx_symtab
would slow down initial readin, so we look for it here instead. */
- if (sym_offset >= (int)sizeof (struct nlist))
+ if (sym_offset >= (int)symbol_size)
{
- lseek (desc, sym_offset - sizeof (struct nlist), L_INCR);
+ lseek (desc, sym_offset - symbol_size, L_INCR);
fill_symbuf ();
bufp = &symbuf[symbuf_idx++];
SWAP_SYMBOL (bufp);
- if (bufp->n_un.n_strx < 0 || bufp->n_un.n_strx >= stringtab_size)
- error ("Invalid symbol data: bad string table offset: %d",
- bufp->n_un.n_strx);
- namestring = bufp->n_un.n_strx + stringtab;
+ SET_NAMESTRING ();
processing_gcc_compilation =
(bufp->n_type == N_TEXT
&& !strcmp (namestring, GCC_COMPILED_FLAG_SYMBOL));
+ /* FIXME!!! Check for gcc2_compiled... */
}
else
{
if (bufp->n_type != (unsigned char)N_SO)
error("First symbol in segment of executable not a source symbol");
+ max_symnum = sym_size / symbol_size;
+
for (symnum = 0;
- symnum < sym_size / sizeof(struct nlist);
+ symnum < max_symnum;
symnum++)
{
QUIT; /* Allow this to be interruptable */
bufp->n_value += offset;
type = bufp->n_type;
- if (bufp->n_un.n_strx < 0 || bufp->n_un.n_strx >= stringtab_size)
- error ("Invalid symbol data: bad string table offset: %d",
- bufp->n_un.n_strx);
- namestring = bufp->n_un.n_strx + stringtab;
+ SET_NAMESTRING ();
if (type & N_STAB)
{
bufp = &symbuf[symbuf_idx];
if (bufp->n_type == (unsigned char)N_SO)
{
- char *namestring2;
+ char *namestring1 = namestring;
SWAP_SYMBOL (bufp);
bufp->n_value += offset; /* Relocate */
symbuf_idx++;
symnum++;
+ SET_NAMESTRING ();
- if (bufp->n_un.n_strx < 0
- || bufp->n_un.n_strx >= stringtab_size)
- error ("Invalid symbol data: bad string table offset: %d",
- bufp->n_un.n_strx);
- namestring2 = bufp->n_un.n_strx + stringtab;
-
- process_symbol_pair (N_SO, bufp_n_desc, valu, namestring,
+ process_symbol_pair (N_SO, bufp_n_desc, valu, namestring1,
N_SO, bufp->n_desc, bufp->n_value,
- namestring2);
+ namestring);
}
else
process_one_symbol(type, bufp_n_desc, valu, namestring);
break;
}
+#if 0
+ /* This screws up perfectly good C programs with enums. FIXME. */
/* Is this Modula-2's BOOLEAN type? Flag it as such if so. */
if(TYPE_NFIELDS(type) == 2 &&
((!strcmp(TYPE_FIELD_NAME(type,0),"TRUE") &&
(!strcmp(TYPE_FIELD_NAME(type,1),"TRUE") &&
!strcmp(TYPE_FIELD_NAME(type,0),"FALSE"))))
TYPE_CODE(type) = TYPE_CODE_BOOL;
+#endif
return type;
}
/* After the symbol file has been read, print a newline to get us
beyond the copyright line... But errors should still set off
the error message with a (single) blank line. */
- printf_filtered ("\n");
+ if (!quiet)
+ printf_filtered ("\n");
error_pre_print = "\n";
if (corearg != NULL)
register struct cmd_list_element *c;
register struct command_line *cmdlines;
register enum language flang;
- static enum language current = language_unknown;
+ static struct language_defn *saved_language = 0;
static int warned = 0;
free_all_values ();
(*c->function) (arg, from_tty & caution);
}
- /* Tell the user if the language has changed */
- if (working_lang != current)
+ /* Tell the user if the language has changed (except first time). */
+ if (current_language != saved_language)
{
if (language_mode == language_mode_auto) {
- if (current != language_unknown)
+ if (saved_language)
language_info ();
}
- current = working_lang;
+ saved_language = current_language;
warned = 0;
}
/* Warn the user if the working language does not match the
language of the current frame. Only warn the user if we are
actually running the program, i.e. there is a stack. */
+ /* FIXME: This should be cacheing the frame and only running when
+ the frame changes. */
if (target_has_stack)
{
- flang = get_frame_language();
- if(!warned && flang != language_unknown && flang != working_lang)
+ flang = get_frame_language ();
+ if (!warned
+ && flang != language_unknown
+ && flang != current_language->la_language)
{
printf_filtered ("%s\n", lang_frame_mismatch_warn);
warned = 1;
validate_comname (comname);
+ /* Look it up, and verify that we got an exact match. */
c = lookup_cmd (&tem, cmdlist, "", -1, 1);
+ if (c && 0 != strcmp (comname, c->name))
+ c = 0;
+
if (c)
{
if (c->class == class_user || c->class == class_alias)
{
printf ("\
GDB is free software and you are welcome to distribute copies of it\n\
- under certain conditions; type \"info copying\" to see the conditions.\n\
-There is absolutely no warranty for GDB; type \"info warranty\" for details.\n\
+ under certain conditions; type \"show copying\" to see the conditions.\n\
+There is absolutely no warranty for GDB; type \"show warranty\" for details.\n\
");
}
c = parse_escape (&p);
if (c >= 0)
- fputc (c, stdout);
+ printf_filtered ("%c", c);
}
else
- fputc (c, stdout);
+ printf_filtered ("%c", c);
}
+
+ /* Force this output to appear now. */
+ wrap_here ("");
fflush (stdout);
}