(record_debugformat): Declare global function.
* buildsym.c (start_subfile): Initialize debugformat member
to NULL.
(record_debugformat): New function to record the format.
(end_symtab): Copy format into symtab debugformat member.
(end_symtab): Free subfile debugformat member.
* symmisc.c (free_symtab): Free debugformat when freeing
symtab.
* symfile.c (allocate_symtab): Initialize the new debugformat
member for new symtabs.
* symtab.h (struct symtab): Add debugformat member.
* source.c (source_info): Print the debug format.
* os9kread.c (os9k_process_one_symbol): Call record_debugformat
with "OS9".
* hpread.c (hpread_expand_symtab): Call record_debugformat
with "HP".
(hpread_process_one_debug_symbol): Ditto.
* dbxread.c (process_one_symbol): Call record_debugformat
with "stabs".
* coffread.c (coff_start_symtab): Call record_debugformat
with "COFF".
* xcoffread.c (read_xcoff_symtab): Call record_debugformat
with "XCOFF".
* dwarfread.c (read_file_scope): Call record_debugformat
with "DWARF 1".
* dwarf2read.c (read_file_scope): Call record_debugformat
with "DWARF 2".
* dstread.c (dst_end_symtab): Set debugformat to be
"Apollo DST".
* mdebugread.c (new_symtab): Set debugformat to be "ECOFF".
+Fri Jun 27 23:03:53 1997 Fred Fish <fnf@ninemoons.com>
+
+ * buildsym.h (struct subfile): Add debugformat member.
+ (record_debugformat): Declare global function.
+ * buildsym.c (start_subfile): Initialize debugformat member
+ to NULL.
+ (record_debugformat): New function to record the format.
+ (end_symtab): Copy format into symtab debugformat member.
+ (end_symtab): Free subfile debugformat member.
+ * symmisc.c (free_symtab): Free debugformat when freeing
+ symtab.
+ * symfile.c (allocate_symtab): Initialize the new debugformat
+ member for new symtabs.
+ * symtab.h (struct symtab): Add debugformat member.
+ * source.c (source_info): Print the debug format.
+
+ * os9kread.c (os9k_process_one_symbol): Call record_debugformat
+ with "OS9".
+ * hpread.c (hpread_expand_symtab): Call record_debugformat
+ with "HP".
+ (hpread_process_one_debug_symbol): Ditto.
+ * dbxread.c (process_one_symbol): Call record_debugformat
+ with "stabs".
+ * coffread.c (coff_start_symtab): Call record_debugformat
+ with "COFF".
+ * xcoffread.c (read_xcoff_symtab): Call record_debugformat
+ with "XCOFF".
+ * dwarfread.c (read_file_scope): Call record_debugformat
+ with "DWARF 1".
+ * dwarf2read.c (read_file_scope): Call record_debugformat
+ with "DWARF 2".
+ * dstread.c (dst_end_symtab): Set debugformat to be
+ "Apollo DST".
+ * mdebugread.c (new_symtab): Set debugformat to be "ECOFF".
+
Fri Jun 27 21:05:45 1997 Michael Snyder (msnyder@cleaver.cygnus.com)
* mips-tdep.c (mips_push_arguments): handle alignment of
subfile->language = subfile->next->language;
}
+ /* Initialize the debug format string to NULL. We may supply it
+ later via a call to record_debugformat. */
+ subfile->debugformat = NULL;
+
/* cfront output is a C program, so in most ways it looks like a C
program. But to demangle we need to set the language to C++. We
can distinguish cfront code by the fact that it has #line
language it is from things we found in the symbols. */
symtab->language = subfile->language;
+ /* Save the debug format string (if any) in the symtab */
+ if (subfile -> debugformat != NULL)
+ {
+ symtab->debugformat = obsavestring (subfile->debugformat,
+ strlen (subfile->debugformat),
+ &objfile -> symbol_obstack);
+ }
+
/* All symtabs for the main file and the subfiles share a
blockvector, so we need to clear primary for everything but
the main file. */
{
free ((PTR) subfile->line_vector);
}
+ if (subfile->debugformat != NULL)
+ {
+ free ((PTR) subfile->debugformat);
+ }
nextsub = subfile->next;
free ((PTR)subfile);
return (total % HASHSIZE);
}
+\f
+void
+record_debugformat (format)
+ char *format;
+{
+ current_subfile -> debugformat = savestring (format, strlen (format));
+}
+
\f
/* Initialize anything that needs initializing when starting to read
a fresh piece of a symbol file, e.g. reading in the stuff corresponding
struct linetable *line_vector;
int line_vector_length;
enum language language;
+ char *debugformat;
};
EXTERN struct subfile *subfiles;
record_pending_block PARAMS ((struct objfile *, struct block *,
struct pending_block *));
+extern void
+record_debugformat PARAMS ((char *));
+
#undef EXTERN
#endif /* defined (BUILDSYM_H) */
{
enum minimal_symbol_type ms_type;
int section;
+ asection *bfd_section;
switch (type)
{
case N_TEXT | N_EXT:
ms_type = mst_text;
section = SECT_OFF_TEXT;
+ bfd_section = DBX_TEXT_SECTION (objfile);
break;
case N_DATA | N_EXT:
ms_type = mst_data;
section = SECT_OFF_DATA;
+ bfd_section = DBX_DATA_SECTION (objfile);
break;
case N_BSS | N_EXT:
ms_type = mst_bss;
section = SECT_OFF_BSS;
+ bfd_section = DBX_BSS_SECTION (objfile);
break;
case N_ABS | N_EXT:
ms_type = mst_abs;
section = -1;
+ bfd_section = NULL;
break;
#ifdef N_SETV
case N_SETV | N_EXT:
ms_type = mst_data;
section = SECT_OFF_DATA;
+ bfd_section = DBX_DATA_SECTION (objfile);
break;
case N_SETV:
/* I don't think this type actually exists; since a N_SETV is the result
file local. */
ms_type = mst_file_data;
section = SECT_OFF_DATA;
+ bfd_section = DBX_DATA_SECTION (objfile);
break;
#endif
case N_TEXT:
case N_FN_SEQ:
ms_type = mst_file_text;
section = SECT_OFF_TEXT;
+ bfd_section = DBX_TEXT_SECTION (objfile);
break;
case N_DATA:
ms_type = mst_file_data;
ms_type = mst_data;
}
section = SECT_OFF_DATA;
+ bfd_section = DBX_DATA_SECTION (objfile);
break;
case N_BSS:
ms_type = mst_file_bss;
section = SECT_OFF_BSS;
+ bfd_section = DBX_BSS_SECTION (objfile);
break;
default:
ms_type = mst_unknown;
section = -1;
+ bfd_section = NULL;
break;
}
lowest_text_address = address;
prim_record_minimal_symbol_and_info
- (name, address, ms_type, NULL, section, objfile);
+ (name, address, ms_type, NULL, section, bfd_section, objfile);
}
\f
/* Scan and build partial symbols for a symbol file.
/* Allocate struct to keep track of the symfile */
objfile->sym_stab_info = (PTR)
xmmalloc (objfile -> md, sizeof (struct dbx_symfile_info));
+ memset ((PTR) objfile->sym_stab_info, 0, sizeof (struct dbx_symfile_info));
+
+ DBX_TEXT_SECTION (objfile) = bfd_get_section_by_name (sym_bfd, ".text");
+ DBX_DATA_SECTION (objfile) = bfd_get_section_by_name (sym_bfd, ".data");
+ DBX_BSS_SECTION (objfile) = bfd_get_section_by_name (sym_bfd, ".bss");
/* FIXME POKING INSIDE BFD DATA STRUCTURES */
#define STRING_TABLE_OFFSET (sym_bfd->origin + obj_str_filepos (sym_bfd))
while (--i >= 0)
{
free (hfiles [i].name);
+ free (hfiles [i].vector);
}
free ((PTR) hfiles);
}
bincl_list = (struct header_file_location *)
xmrealloc (pst->objfile->md, (char *)bincl_list,
bincls_allocated * sizeof (struct header_file_location));
+ if (bincl_list == NULL)
+ fatal ("virtual memory exhausted in add_bincl_to_list ();");
next_bincl = bincl_list + offset;
}
next_bincl->pst = pst;
/* Make a block for the local symbols within. */
finish_block (new->name, &local_symbols, new->old_blocks,
- function_start_offset, function_start_offset + valu,
+ new->start_addr, new->start_addr + valu,
objfile);
break;
}
start_stabs ();
start_symtab (name, NULL, valu);
+ record_debugformat ("stabs");
break;
case N_SOL:
/* There is already a dbx_symfile_info allocated by our caller.
It might even contain some info from the coff symtab to help us. */
- info = (struct dbx_symfile_info *) objfile->sym_stab_info;
+ info = objfile->sym_stab_info;
DBX_TEXT_ADDR (objfile) = textaddr;
DBX_TEXT_SIZE (objfile) = textsize;
/* There is already a dbx_symfile_info allocated by our caller.
It might even contain some info from the ELF symtab to help us. */
- info = (struct dbx_symfile_info *) objfile->sym_stab_info;
+ info = objfile->sym_stab_info;
text_sect = bfd_get_section_by_name (sym_bfd, ".text");
if (!text_sect)
stab_name, stabstr_name);
objfile->sym_stab_info = (PTR) xmalloc (sizeof (struct dbx_symfile_info));
- memset (DBX_SYMFILE_INFO (objfile), 0, sizeof (struct dbx_symfile_info));
+ memset (objfile->sym_stab_info, 0, sizeof (struct dbx_symfile_info));
text_sect = bfd_get_section_by_name (sym_bfd, text_name);
if (!text_sect)
symtab->free_ptr = 0;
symtab->filename = last_source_file;
symtab->dirname = NULL;
+ symtab->debugformat = obsavestring ("Apollo DST", 10,
+ &objfile -> symbol_obstack);
lv = line_vector;
lv->nitems = line_vector_index;
symtab->linetable = (struct linetable *)
memset (ftypes, 0, FT_NUM_MEMBERS * sizeof (struct type *));
start_symtab (name, comp_dir, lowpc);
+ record_debugformat ("DWARF 2");
/* Decode line number information if present. */
attr = dwarf_attr (die, DW_AT_stmt_list);
memset (utypes, 0, numutypes * sizeof (struct type *));
memset (ftypes, 0, FT_NUM_MEMBERS * sizeof (struct type *));
start_symtab (dip -> at_name, dip -> at_comp_dir, dip -> at_low_pc);
+ record_debugformat ("DWARF 1");
decode_line_numbers (lnbase);
process_dies (thisdie + dip -> die_length, enddie, objfile);
dn_bufp = hpread_get_lntt (sym_index, objfile);
if (!((dn_bufp->dblock.kind == (unsigned char) DNTT_TYPE_SRCFILE) ||
(dn_bufp->dblock.kind == (unsigned char) DNTT_TYPE_MODULE)))
- start_symtab ("globals", NULL, 0);
+ {
+ start_symtab ("globals", NULL, 0);
+ record_debugformat ("HP");
+ }
max_symnum = sym_size / sizeof (struct dntt_type_block);
if (!last_source_file)
{
start_symtab (name, NULL, valu);
+ record_debugformat ("HP");
SL_INDEX (objfile) = dn_bufp->dsfile.address;
}
else
BLOCKVECTOR_BLOCK (BLOCKVECTOR (s), GLOBAL_BLOCK);
s->free_code = free_linetable;
-
+ s->debugformat = obsavestring ("ECOFF", 5,
+ &objfile -> symbol_obstack);
return (s);
}
start_stabs ();
os9k_stabs = 1;
start_symtab (n, dirn, valu);
+ record_debugformat ("OS9");
} else {
push_subfile();
start_subfile (n, dirn!=NULL ? dirn : current_subfile->dirname);
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
-Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
#include "defs.h"
#include "symtab.h"
#include "command.h"
#include "gdbcmd.h"
#include "frame.h"
+#include "value.h"
#include <sys/types.h>
#include "gdb_string.h"
-#include <sys/param.h>
#include "gdb_stat.h"
#include <fcntl.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#include "gdbcore.h"
-#include "regex.h"
+#include "gnu-regex.h"
#include "symfile.h"
#include "objfiles.h"
#include "annotate.h"
}
}
+#ifndef WIN32
+ /* On win32 h:\ is different to h: */
if (SLASH_P (p[-1]))
/* Sigh. "foo/" => "foo" */
--p;
+#endif
*p = '\0';
while (p[-1] == '.')
if (name[0] == '~')
name = tilde_expand (name);
- else if (!SLASH_P (name[0]) && name[0] != '$')
+ else if (!ROOTED_P (name) && name[0] != '$')
name = concat (current_directory, SLASH_STRING, name, NULL);
else
name = savestring (name, p - name);
printf_filtered ("Contains %d line%s.\n", s->nlines,
s->nlines == 1 ? "" : "s");
- printf_filtered("Source language is %s.\n", language_str (s->language));
+ printf_filtered ("Source language is %s.\n", language_str (s->language));
+ printf_filtered ("Compiled with %s debugging format.\n", s->debugformat);
}
if (!path)
path = ".";
+#ifdef WIN32
+ mode |= O_BINARY;
+#endif
+
if (try_cwd_first || SLASH_P (string[0]))
{
int i;
if (fd >= 0)
goto done;
for (i = 0; string[i]; i++)
- if (SLASH_P(string[0]))
- goto done;
+ if (SLASH_P (string[i]))
+ goto done;
}
/* ./foo => foo */
len = strlen (p);
if (len == 4 && p[0] == '$' && p[1] == 'c'
- && p[2] == 'w' && p[3] == 'd') {
+ && p[2] == 'w' && p[3] == 'd') {
/* Name is $cwd -- insert current directory name instead. */
int newlen;
/* Remove trailing slashes */
while (len > 0 && SLASH_P (filename[len-1]))
- filename[--len] = 0;
+ filename[--len] = 0;
strcat (filename+len, SLASH_STRING);
strcat (filename, string);
int nlines = 0;
int lines_allocated = 1000;
int *line_charpos;
- long exec_mtime;
+ long mtime;
int size;
line_charpos = (int *) xmmalloc (s -> objfile -> md,
if (fstat (desc, &st) < 0)
perror_with_name (s->filename);
- if (exec_bfd)
+ if (s && s->objfile && s->objfile->obfd)
{
- exec_mtime = bfd_get_mtime(exec_bfd);
- if (exec_mtime && exec_mtime < st.st_mtime)
+ mtime = bfd_get_mtime(s->objfile->obfd);
+ if (mtime && mtime < st.st_mtime)
+ printf_filtered ("Source file is more recent than executable.\n");
+ }
+ else if (exec_bfd)
+ {
+ mtime = bfd_get_mtime(exec_bfd);
+ if (mtime && mtime < st.st_mtime)
printf_filtered ("Source file is more recent than executable.\n");
}
/* Have to read it byte by byte to find out where the chars live */
- line_charpos[0] = tell(desc);
+ line_charpos[0] = lseek (desc, 0, SEEK_CUR);
nlines = 1;
while (myread(desc, &c, 1)>0)
{
(int *) xmrealloc (s -> objfile -> md, (char *) line_charpos,
sizeof (int) * lines_allocated);
}
- line_charpos[nlines++] = tell(desc);
+ line_charpos[nlines++] = lseek (desc, 0, SEEK_CUR);
}
}
}
data = (char *) xmalloc (size);
old_cleanups = make_cleanup (free, data);
- if (myread (desc, data, size) < 0)
+ /* Reassign `size' to result of read for systems where \r\n -> \n. */
+ size = myread (desc, data, size);
+ if (size < 0)
perror_with_name (s->filename);
end = data + size;
p = data;
CORE_ADDR start_pc, end_pc;
int i;
+ INIT_SAL (&sal); /* initialize to zeroes */
+
if (arg == 0)
{
sal.symtab = current_source_symtab;
sal.line = last_line_listed;
- sal.pc = 0;
sals.nelts = 1;
sals.sals = (struct symtab_and_line *)
xmalloc (sizeof (struct symtab_and_line));
enum language language;
+ /* String that identifies the format of the debugging information, such
+ as "stabs", "dwarf 1", "dwarf 2", "coff", etc. This is mostly useful
+ for automated testing of gdb but may also be information that is
+ useful to the user. */
+
+ char *debugformat;
+
/* String of version information. May be zero. */
char *version;
start_stabs ();
start_symtab (filestring, (char *)NULL, file_start_addr);
+ record_debugformat ("XCOFF");
symnum = ((struct symloc *)pst->read_symtab_private)->first_symnum;
max_symnum =
symnum + ((struct symloc *)pst->read_symtab_private)->numsyms;
start_stabs ();
start_symtab ("_globals_", (char *)NULL, (CORE_ADDR)0);
+ record_debugformat ("XCOFF");
cur_src_end_addr = first_object_file_end;
/* done with all files, everything from here on is globals */
}
/* Give all csects for this source file the same
name. */
start_symtab (filestring, NULL, (CORE_ADDR)0);
+ record_debugformat ("XCOFF");
}
/* If this is the very first csect seen,
start_stabs ();
start_symtab (filestring, (char *)NULL, (CORE_ADDR)0);
+ record_debugformat ("XCOFF");
last_csect_name = 0;
/* reset file start and end addresses. A compilation unit with no text