Skip to content

Commit 79e7ae1

Browse files
committed
Clean up some comments in minsyms.c
Philippe pointed out that some comments in minsyms.c still referred to obstack allocation. This patch fixes these up. In most cases here, my view is that the comments were more misleading than helpful. So, I've generally removed text. gdb/ChangeLog 2019-03-25 Tom Tromey <[email protected]> * minsyms.c (BUNCH_SIZE): Update comment. (~minimal_symbol_reader): Remove old comment. (compact_minimal_symbols): Update comment. (minimal_symbol_reader::install): Remove old comment. Update other comments.
1 parent d45963c commit 79e7ae1

File tree

2 files changed

+15
-42
lines changed

2 files changed

+15
-42
lines changed

gdb/ChangeLog

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
2019-03-25 Tom Tromey <[email protected]>
2+
3+
* minsyms.c (BUNCH_SIZE): Update comment.
4+
(~minimal_symbol_reader): Remove old comment.
5+
(compact_minimal_symbols): Update comment.
6+
(minimal_symbol_reader::install): Remove old comment. Update
7+
other comments.
8+
19
2019-03-25 Alan Hayward <[email protected]>
210

311
* s390-linux-nat.c: Add include.

gdb/minsyms.c

Lines changed: 7 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,7 @@ msymbol_is_function (struct objfile *objfile, minimal_symbol *minsym,
9292
}
9393

9494
/* Accumulate the minimal symbols for each objfile in bunches of BUNCH_SIZE.
95-
At the end, copy them all into one newly allocated location on an objfile's
96-
per-BFD storage obstack. */
95+
At the end, copy them all into one newly allocated array. */
9796

9897
#define BUNCH_SIZE 127
9998

@@ -1031,11 +1030,7 @@ minimal_symbol_reader::minimal_symbol_reader (struct objfile *obj)
10311030

10321031
/* Discard the currently collected minimal symbols, if any. If we wish
10331032
to save them for later use, we must have already copied them somewhere
1034-
else before calling this function.
1035-
1036-
FIXME: We could allocate the minimal symbol bunches on their own
1037-
obstack and then simply blow the obstack away when we are done with
1038-
it. Is it worth the extra trouble though? */
1033+
else before calling this function. */
10391034

10401035
minimal_symbol_reader::~minimal_symbol_reader ()
10411036
{
@@ -1231,15 +1226,6 @@ compare_minimal_symbols (const void *fn1p, const void *fn2p)
12311226
to linearly scan the table, which is done in a number of places. So we
12321227
just do one linear scan here and toss out the duplicates.
12331228
1234-
Note that we are not concerned here about recovering the space that
1235-
is potentially freed up, because the strings themselves are allocated
1236-
on the storage_obstack, and will get automatically freed when the symbol
1237-
table is freed. The caller can free up the unused minimal symbols at
1238-
the end of the compacted region if their allocation strategy allows it.
1239-
1240-
Also note we only go up to the next to last entry within the loop
1241-
and then copy the last entry explicitly after the loop terminates.
1242-
12431229
Since the different sources of information for each symbol may
12441230
have different levels of "completeness", we may have duplicates
12451231
that have one entry with type "mst_unknown" and the other with a
@@ -1315,24 +1301,7 @@ build_minimal_symbol_hash_tables (struct objfile *objfile)
13151301
minimal symbol table. In most cases there is no minimal symbol table yet
13161302
for this objfile, and the existing bunches are used to create one. Once
13171303
in a while (for shared libraries for example), we add symbols (e.g. common
1318-
symbols) to an existing objfile.
1319-
1320-
Because of the way minimal symbols are collected, we generally have no way
1321-
of knowing what source language applies to any particular minimal symbol.
1322-
Specifically, we have no way of knowing if the minimal symbol comes from a
1323-
C++ compilation unit or not. So for the sake of supporting cached
1324-
demangled C++ names, we have no choice but to try and demangle each new one
1325-
that comes in. If the demangling succeeds, then we assume it is a C++
1326-
symbol and set the symbol's language and demangled name fields
1327-
appropriately. Note that in order to avoid unnecessary demanglings, and
1328-
allocating obstack space that subsequently can't be freed for the demangled
1329-
names, we mark all newly added symbols with language_auto. After
1330-
compaction of the minimal symbols, we go back and scan the entire minimal
1331-
symbol table looking for these new symbols. For each new symbol we attempt
1332-
to demangle it, and if successful, record it as a language_cplus symbol
1333-
and cache the demangled form on the symbol obstack. Symbols which don't
1334-
demangle are marked as language_unknown symbols, which inhibits future
1335-
attempts to demangle them if we later add more minimal symbols. */
1304+
symbols) to an existing objfile. */
13361305

13371306
void
13381307
minimal_symbol_reader::install ()
@@ -1354,10 +1323,10 @@ minimal_symbol_reader::install ()
13541323
m_msym_count, objfile_name (m_objfile));
13551324
}
13561325

1357-
/* Allocate enough space in the obstack, into which we will gather the
1358-
bunches of new and existing minimal symbols, sort them, and then
1359-
compact out the duplicate entries. Once we have a final table,
1360-
we will give back the excess space. */
1326+
/* Allocate enough space, into which we will gather the bunches
1327+
of new and existing minimal symbols, sort them, and then
1328+
compact out the duplicate entries. Once we have a final
1329+
table, we will give back the excess space. */
13611330

13621331
alloc_count = m_msym_count + m_objfile->per_bfd->minimal_symbol_count;
13631332
gdb::unique_xmalloc_ptr<minimal_symbol>
@@ -1407,10 +1376,6 @@ minimal_symbol_reader::install ()
14071376
m_objfile->per_bfd->minimal_symbol_count = mcount;
14081377
m_objfile->per_bfd->msymbols = std::move (msym_holder);
14091378

1410-
/* Now build the hash tables; we can't do this incrementally
1411-
at an earlier point since we weren't finished with the obstack
1412-
yet. (And if the msymbol obstack gets moved, all the internal
1413-
pointers to other msymbols need to be adjusted.) */
14141379
build_minimal_symbol_hash_tables (m_objfile);
14151380
}
14161381
}

0 commit comments

Comments
 (0)