* xcoffread.c (process_linenos): Make sure filename we pass to
start_subfile will cause deduce_language_from_filename to return the correct thing. Reindent function to GNU standards.
This commit is contained in:
parent
3c727f7293
commit
5cba5d2608
197
gdb/xcoffread.c
197
gdb/xcoffread.c
|
@ -529,17 +529,16 @@ process_linenos (start, end)
|
||||||
char *pp;
|
char *pp;
|
||||||
int offset, ii;
|
int offset, ii;
|
||||||
|
|
||||||
struct subfile main_subfile; /* subfile structure for the main
|
/* subfile structure for the main compilation unit. */
|
||||||
compilation unit. */
|
struct subfile main_subfile;
|
||||||
|
|
||||||
/* in the main source file, any time we see a function entry, we reset
|
/* In the main source file, any time we see a function entry, we
|
||||||
this variable to function's absolute starting line number. All the
|
reset this variable to function's absolute starting line number.
|
||||||
following line numbers in the function are relative to this, and
|
All the following line numbers in the function are relative to
|
||||||
we record absolute line numbers in record_line(). */
|
this, and we record absolute line numbers in record_line(). */
|
||||||
|
|
||||||
int main_source_baseline = 0;
|
int main_source_baseline = 0;
|
||||||
|
|
||||||
|
|
||||||
unsigned *firstLine;
|
unsigned *firstLine;
|
||||||
CORE_ADDR addr;
|
CORE_ADDR addr;
|
||||||
|
|
||||||
|
@ -555,126 +554,146 @@ process_linenos (start, end)
|
||||||
enter_line_range (&main_subfile, offset, 0, start, end,
|
enter_line_range (&main_subfile, offset, 0, start, end,
|
||||||
&main_source_baseline);
|
&main_source_baseline);
|
||||||
|
|
||||||
/* else, there was source with line numbers in include files */
|
else
|
||||||
else {
|
{
|
||||||
|
/* There was source with line numbers in include files. */
|
||||||
|
main_source_baseline = 0;
|
||||||
|
for (ii=0; ii < inclIndx; ++ii)
|
||||||
|
{
|
||||||
|
struct subfile *tmpSubfile;
|
||||||
|
|
||||||
main_source_baseline = 0;
|
/* If there is main file source before include file, enter it. */
|
||||||
for (ii=0; ii < inclIndx; ++ii) {
|
if (offset < inclTable[ii].begin)
|
||||||
|
{
|
||||||
|
enter_line_range
|
||||||
|
(&main_subfile, offset, inclTable[ii].begin - LINESZ,
|
||||||
|
start, 0, &main_source_baseline);
|
||||||
|
}
|
||||||
|
|
||||||
struct subfile *tmpSubfile;
|
/* Have a new subfile for the include file. */
|
||||||
|
|
||||||
/* if there is main file source before include file, enter it. */
|
tmpSubfile = inclTable[ii].subfile =
|
||||||
if (offset < inclTable[ii].begin) {
|
(struct subfile *) xmalloc (sizeof (struct subfile));
|
||||||
enter_line_range
|
|
||||||
(&main_subfile, offset, inclTable[ii].begin - LINESZ, start, 0,
|
|
||||||
&main_source_baseline);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Have a new subfile for the include file */
|
memset (tmpSubfile, '\0', sizeof (struct subfile));
|
||||||
|
firstLine = &(inclTable[ii].funStartLine);
|
||||||
|
|
||||||
tmpSubfile = inclTable[ii].subfile = (struct subfile*)
|
/* Enter include file's lines now. */
|
||||||
xmalloc (sizeof (struct subfile));
|
enter_line_range (tmpSubfile, inclTable[ii].begin,
|
||||||
|
inclTable[ii].end, start, 0, firstLine);
|
||||||
|
|
||||||
memset (tmpSubfile, '\0', sizeof (struct subfile));
|
offset = inclTable[ii].end + LINESZ;
|
||||||
firstLine = &(inclTable[ii].funStartLine);
|
}
|
||||||
|
|
||||||
/* enter include file's lines now. */
|
/* All the include files' line have been processed at this point. Now,
|
||||||
enter_line_range (tmpSubfile, inclTable[ii].begin,
|
enter remaining lines of the main file, if any left. */
|
||||||
inclTable[ii].end, start, 0, firstLine);
|
if (offset < (linetab_offset + linetab_size + 1 - LINESZ))
|
||||||
|
{
|
||||||
offset = inclTable[ii].end + LINESZ;
|
enter_line_range (&main_subfile, offset, 0, start, end,
|
||||||
|
&main_source_baseline);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* all the include files' line have been processed at this point. Now,
|
/* Process main file's line numbers. */
|
||||||
enter remaining lines of the main file, if any left. */
|
if (main_subfile.line_vector)
|
||||||
if (offset < (linetab_offset + linetab_size + 1 - LINESZ)) {
|
{
|
||||||
enter_line_range (&main_subfile, offset, 0, start, end,
|
struct linetable *lineTb, *lv;
|
||||||
&main_source_baseline);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Process main file's line numbers. */
|
lv = main_subfile.line_vector;
|
||||||
if (main_subfile.line_vector) {
|
|
||||||
struct linetable *lineTb, *lv;
|
|
||||||
|
|
||||||
lv = main_subfile.line_vector;
|
/* Line numbers are not necessarily ordered. xlc compilation will
|
||||||
|
put static function to the end. */
|
||||||
|
|
||||||
/* Line numbers are not necessarily ordered. xlc compilation will
|
lineTb = arrange_linetable (lv);
|
||||||
put static function to the end. */
|
if (lv == lineTb)
|
||||||
|
{
|
||||||
|
current_subfile->line_vector = (struct linetable *)
|
||||||
|
xrealloc (lv, (sizeof (struct linetable)
|
||||||
|
+ lv->nitems * sizeof (struct linetable_entry)));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
free (lv);
|
||||||
|
current_subfile->line_vector = lineTb;
|
||||||
|
}
|
||||||
|
|
||||||
lineTb = arrange_linetable (lv);
|
current_subfile->line_vector_length =
|
||||||
if (lv == lineTb) {
|
current_subfile->line_vector->nitems;
|
||||||
current_subfile->line_vector = (struct linetable *)
|
|
||||||
xrealloc (lv, (sizeof (struct linetable)
|
|
||||||
+ lv->nitems * sizeof (struct linetable_entry)));
|
|
||||||
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
free (lv);
|
|
||||||
current_subfile->line_vector = lineTb;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
current_subfile->line_vector_length =
|
/* Now, process included files' line numbers. */
|
||||||
current_subfile->line_vector->nitems;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Now, process included files' line numbers. */
|
for (ii=0; ii < inclIndx; ++ii)
|
||||||
|
{
|
||||||
|
if ((inclTable[ii].subfile)->line_vector) /* Useless if!!! FIXMEmgo */
|
||||||
|
{
|
||||||
|
struct linetable *lineTb, *lv;
|
||||||
|
|
||||||
for (ii=0; ii < inclIndx; ++ii) {
|
lv = (inclTable[ii].subfile)->line_vector;
|
||||||
|
|
||||||
if ( (inclTable[ii].subfile)->line_vector) { /* Useless if!!! FIXMEmgo */
|
/* Line numbers are not necessarily ordered. xlc compilation will
|
||||||
struct linetable *lineTb, *lv;
|
put static function to the end. */
|
||||||
|
|
||||||
lv = (inclTable[ii].subfile)->line_vector;
|
lineTb = arrange_linetable (lv);
|
||||||
|
|
||||||
/* Line numbers are not necessarily ordered. xlc compilation will
|
push_subfile ();
|
||||||
put static function to the end. */
|
|
||||||
|
|
||||||
lineTb = arrange_linetable (lv);
|
/* For the same include file, we might want to have more than one
|
||||||
|
subfile. This happens if we have something like:
|
||||||
|
|
||||||
push_subfile ();
|
|
||||||
|
|
||||||
/* For the same include file, we might want to have more than one subfile.
|
|
||||||
This happens if we have something like:
|
|
||||||
|
|
||||||
......
|
......
|
||||||
#include "foo.h"
|
#include "foo.h"
|
||||||
......
|
......
|
||||||
#include "foo.h"
|
#include "foo.h"
|
||||||
......
|
......
|
||||||
|
|
||||||
while foo.h including code in it. (stupid but possible)
|
while foo.h including code in it. (stupid but possible)
|
||||||
Since start_subfile() looks at the name and uses an existing one if finds,
|
Since start_subfile() looks at the name and uses an
|
||||||
we need to provide a fake name and fool it. */
|
existing one if finds, we need to provide a fake name and
|
||||||
|
fool it. */
|
||||||
|
|
||||||
/* start_subfile (inclTable[ii].name, (char*)0); */
|
#if 0
|
||||||
start_subfile (" ?", (char*)0);
|
start_subfile (inclTable[ii].name, (char*)0);
|
||||||
free (current_subfile->name);
|
#else
|
||||||
current_subfile->name = strdup (inclTable[ii].name);
|
{
|
||||||
|
/* Pick a fake name that will produce the same results as this
|
||||||
|
one when passed to deduce_language_from_filename. Kludge on
|
||||||
|
top of kludge. */
|
||||||
|
char *fakename = strrchr (inclTable[ii].name, '.');
|
||||||
|
if (fakename == NULL)
|
||||||
|
fakename = " ?";
|
||||||
|
start_subfile (fakename, (char*)0);
|
||||||
|
free (current_subfile->name);
|
||||||
|
}
|
||||||
|
current_subfile->name = strdup (inclTable[ii].name);
|
||||||
|
#endif
|
||||||
|
|
||||||
if (lv == lineTb) {
|
if (lv == lineTb)
|
||||||
current_subfile->line_vector = (struct linetable *)
|
{
|
||||||
xrealloc (lv, (sizeof (struct linetable)
|
current_subfile->line_vector =
|
||||||
|
(struct linetable *) xrealloc
|
||||||
|
(lv, (sizeof (struct linetable)
|
||||||
+ lv->nitems * sizeof (struct linetable_entry)));
|
+ lv->nitems * sizeof (struct linetable_entry)));
|
||||||
|
|
||||||
}
|
}
|
||||||
else {
|
else
|
||||||
free (lv);
|
{
|
||||||
current_subfile->line_vector = lineTb;
|
free (lv);
|
||||||
}
|
current_subfile->line_vector = lineTb;
|
||||||
|
}
|
||||||
|
|
||||||
current_subfile->line_vector_length =
|
current_subfile->line_vector_length =
|
||||||
current_subfile->line_vector->nitems;
|
current_subfile->line_vector->nitems;
|
||||||
start_subfile (pop_subfile (), (char*)0);
|
start_subfile (pop_subfile (), (char*)0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return_after_cleanup:
|
return_after_cleanup:
|
||||||
|
|
||||||
/* We don't want to keep alloc/free'ing the global include file table. */
|
/* We don't want to keep alloc/free'ing the global include file table. */
|
||||||
inclIndx = 0;
|
inclIndx = 0;
|
||||||
|
|
||||||
/* start with a fresh subfile structure for the next file. */
|
/* Start with a fresh subfile structure for the next file. */
|
||||||
memset (&main_subfile, '\0', sizeof (struct subfile));
|
memset (&main_subfile, '\0', sizeof (struct subfile));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue