This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Fix inconsistency of code and comments in init_psymbol_list


On 12/26/12 1:37 AM, Yao Qi wrote:
Hi,
I happen to read the following part in psymtab.c:init_psymbol_list,

   /* Current best guess is that approximately a twentieth
      of the total symbols (in a debugging file) are global or static
      oriented symbols.  */

   objfile->global_psymbols.size = total_symbols / 10;
   objfile->static_psymbols.size = total_symbols / 10;

and think the code is inconsistent to the comment (twentieth vs. '/ 10').
It should be "tenth" instead of "twentieth" in comment.  Of course,
we can update constant 10 to 20, but it is safe to change comment rather
than the code.

I think the comment is consistent with the code, but maybe a little too terse; the goal here is to minimize growing the table, and so we start with the 1/20th estimate, multiply by 2 as generic slop factor, and use that as starting fraction. So the comment could just be enhanced to say something like


[...] oriented symbols, then multiply that by slop factor of two. */


(It took me a while to realize that the discrepancy was probably intentional, so definitely want to clarify the comment.)


Stan
stan@codesourcery.com


These lines of code has been in GDB for many years, even prior to importing to CVS repository, so I don't find any clue from the history. OK?

gdb:

2012-12-26 Yao Qi <yao@codesourcery.com>

	* psymtab.c (init_psymbol_list): Fix a typo in comment.
---
  gdb/psymtab.c |    2 +-
  1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/gdb/psymtab.c b/gdb/psymtab.c
index 409f96b..0c62679 100644
--- a/gdb/psymtab.c
+++ b/gdb/psymtab.c
@@ -1710,7 +1710,7 @@ init_psymbol_list (struct objfile *objfile, int total_symbols)
xfree (objfile->static_psymbols.list);
}
- /* Current best guess is that approximately a twentieth
+ /* Current best guess is that approximately a tenth
of the total symbols (in a debugging file) are global or static
oriented symbols. */


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]