codeview: Call register_file only when producing line numbers

Previously, debug info would refer to the first file seen, even
when it did not actually generate line numbers (e.g. segto=-1).

Fix it so we only lock in the file name the first time we actually
produce a line number record. Not as good as proper support for
debug info referencing multiple source files but much more useful
than the current behavior.

Signed-off-by: Fabian Giesen <fabiang@radgametools.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
This commit is contained in:
Fabian Giesen 2016-04-28 13:48:16 -07:00 committed by Cyrill Gorcunov
parent 5b838ef981
commit 6503051dcc

View file

@ -169,9 +169,6 @@ static void cv8_linenum(const char *filename, int32_t linenumber,
struct coff_Section *s;
struct linepair *li;
if (cv8_state.source_file.name == NULL)
register_file(filename);
s = find_section(segto);
if (s == NULL)
return;
@ -179,6 +176,9 @@ static void cv8_linenum(const char *filename, int32_t linenumber,
if ((s->flags & IMAGE_SCN_MEM_EXECUTE) == 0)
return;
if (cv8_state.source_file.name == NULL)
register_file(filename);
li = saa_wstruct(cv8_state.lines);
li->file_offset = cv8_state.text_offset;
li->linenumber = linenumber;