diff options
author | Fred Fish <fnf@specifix.com> | 1992-08-06 19:59:46 +0000 |
---|---|---|
committer | Fred Fish <fnf@specifix.com> | 1992-08-06 19:59:46 +0000 |
commit | 3416d90bd63274fc352e6e5b559cdb25d34a8dbd (patch) | |
tree | 157b2ad4fc060429e1575a4bde51dd78419c588b /gdb/buildsym.c | |
parent | 7fd3560a6a0a0babc4137c0cd877dbe2e34169a9 (diff) | |
download | gdb-3416d90bd63274fc352e6e5b559cdb25d34a8dbd.zip gdb-3416d90bd63274fc352e6e5b559cdb25d34a8dbd.tar.gz gdb-3416d90bd63274fc352e6e5b559cdb25d34a8dbd.tar.bz2 |
* buildsym.c (start_subfile): Compact dirname initialization.
* buildsym.c (patch_subfile_names): New function.
* buildsym.c (end_symtab): Make copy of dirname on symbol obstack.
* buildsym.c (end_symtab): Free all malloc'd subfile fields.
* buildsym.h (patch_subfile_names): Add prototype.
* dbxread.c (process_one_symbol): Call patch_subfile_names.
Diffstat (limited to 'gdb/buildsym.c')
-rw-r--r-- | gdb/buildsym.c | 46 |
1 files changed, 36 insertions, 10 deletions
diff --git a/gdb/buildsym.c b/gdb/buildsym.c index 208d207..e0f69cd 100644 --- a/gdb/buildsym.c +++ b/gdb/buildsym.c @@ -388,19 +388,37 @@ start_subfile (name, dirname) /* Save its name and compilation directory name */ subfile->name = strdup (name); - if (dirname == NULL) - { - subfile->dirname = NULL; - } - else - { - subfile->dirname = strdup (dirname); - } + subfile->dirname = (dirname == NULL) ? NULL : strdup (dirname); /* Initialize line-number recording for this subfile. */ subfile->line_vector = NULL; } +/* For stabs readers, the first N_SO symbol is assumed to be the source + file name, and the subfile struct is initialized using that assumption. + If another N_SO symbol is later seen, immediately following the first + one, then the first one is assumed to be the directory name and the + second one is really the source file name. + + So we have to patch up the subfile struct by moving the old name value to + dirname and remembering the new name. Some sanity checking is performed + to ensure that the state of the subfile struct is reasonable and that the + old name we are assuming to be a directory name actually is (by checking + for a trailing '/'). */ + +void +patch_subfile_names (subfile, name) + struct subfile *subfile; + char *name; +{ + if (subfile != NULL && subfile->dirname == NULL && subfile->name != NULL + && subfile->name[strlen(subfile->name)-1] == '/') + { + subfile->dirname = subfile->name; + subfile->name = strdup (name); + } +} + /* Handle the N_BINCL and N_EINCL symbol types that act like N_SOL for switching source files @@ -692,9 +710,17 @@ end_symtab (end_addr, sort_pending, sort_linevec, objfile) symtab->nonreloc = TRUE; #endif } - if (subfile->line_vector) + if (subfile->name != NULL) + { + free ((PTR) subfile->name); + } + if (subfile->dirname != NULL) + { + free ((PTR) subfile->dirname); + } + if (subfile->line_vector != NULL) { - free ((PTR)subfile->line_vector); + free ((PTR) subfile->line_vector); } nextsub = subfile->next; |