aboutsummaryrefslogtreecommitdiff
path: root/gdb/buildsym.h
diff options
context:
space:
mode:
authorSimon Marchi <simon.marchi@polymtl.ca>2022-04-07 08:55:16 -0400
committerSimon Marchi <simon.marchi@efficios.com>2022-04-12 14:17:43 -0400
commit558802e4d1c5dcbd0df7d2c6ef62a6deac247a2f (patch)
tree886bd294660f6280a4085267703135c754fe2770 /gdb/buildsym.h
parentb08c778be92ec638f4f8e6d8d7153c1456b460c8 (diff)
downloadgdb-558802e4d1c5dcbd0df7d2c6ef62a6deac247a2f.zip
gdb-558802e4d1c5dcbd0df7d2c6ef62a6deac247a2f.tar.gz
gdb-558802e4d1c5dcbd0df7d2c6ef62a6deac247a2f.tar.bz2
gdb: change subfile::line_vector to an std::vector
Change this field to an std::vector to facilitate memory management. Since the linetable_entry array is copied into the symtab resulting from the subfile, it is possible to change it without changing how symtab stores the linetable entries (which would be a much larger change). There is a small change in buildsym_compunit::record_line to avoid accessing a now invalid linetable_entry. Before this patch, we keep a pointer to the last linetable entry, pop it from the vector, and then read last->line. It works with the manually-maintained array, but since we now use std::vector::pop_back, I am afraid that it could be flagged as an invalid access by the various static / dynamic analysis tools to access the linetable_entry object after popping it from the vector. Instead, record just the line number in an optional and use it. There are substantial changes in xcoffread.c that simplify the code, but I can't test them. I was hesitant to do this change because of that, but I decided to send it anyway. I don't think that an almost dead platform should hold back improving the code in the common parts of GDB. The changes in xcoffread.c are: - Make arrange_linetable "arrange" the linetable passed as a parameter, instead of returning possibly a new one, possibly the same one. - In the "Process main file's line numbers.", I'm not too sure what happens. We get the lintable from "main_subfile", "arrange" it, but then assign the result to the current subfile, obtained with get_current_subfile. I assume that the current subfile is also the main one, so now I just call arrange_linetable on the main subfile's line table. - Remove that weird "Useless if!!!" FIXME comment. It's been there forever, but the "if" is still there, so I guess the "if" can stay there. Change-Id: I11799006fd85189e8cf5bd3a168f8f38c2c27a80
Diffstat (limited to 'gdb/buildsym.h')
-rw-r--r--gdb/buildsym.h6
1 files changed, 2 insertions, 4 deletions
diff --git a/gdb/buildsym.h b/gdb/buildsym.h
index 6284aaf..ee75e6f 100644
--- a/gdb/buildsym.h
+++ b/gdb/buildsym.h
@@ -20,6 +20,7 @@
#define BUILDSYM_H 1
#include "gdbsupport/gdb_obstack.h"
+#include "symtab.h"
struct objfile;
struct symbol;
@@ -53,10 +54,7 @@ struct subfile
struct subfile *next = nullptr;
std::string name;
-
- /* Space for this is malloc'd. */
- struct linetable *line_vector = nullptr;
- int line_vector_length = 0;
+ std::vector<linetable_entry> line_vector_entries;
enum language language = language_unknown;
struct symtab *symtab = nullptr;
};