public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Tom Tromey <tom@tromey.com>
To: gdb-patches@sourceware.org
Cc: Tom Tromey <tom@tromey.com>
Subject: [RFA 5/6] Add validity bits for psymtab high and low fields
Date: Thu, 03 May 2018 22:36:00 -0000	[thread overview]
Message-ID: <20180503223621.22544-6-tom@tromey.com> (raw)
In-Reply-To: <20180503223621.22544-1-tom@tromey.com>

Right now some psymtab code checks whether a psymtab's textlow or
texthigh fields are valid by comparing against 0.

I imagine this is mildly wrong in the current environment, but once
psymtabs are relocated dynamically, it will no longer be correct,
because it will be much more normal to see a psymtab with a textlow of
zero -- this will just mean it appears at the start of the text
section.

This patch introduces validity bits to handle this situation more
nicely, and changes users of the code to follow.

ChangeLog
2018-05-03  Tom Tromey  <tromey@redhat.com>

	* dbxread.c (end_psymtab): Use texthigh_valid and textlow_valid.
	* mdebugread.c (parse_partial_symbols): Use textlow_valid.
	(psymtab_to_symtab_1): Use texthigh_valid and textlow_valid.
	* psympriv.h (struct partial_symtab) <textlow_, texthigh_>: Update
	comment.
	<textlow_valid, texthigh_valid>: New fields.
	(set_psymtab_textlow, set_psymtab_texthigh): New inline functions.
	(SET_PSYMTAB_TEXTLOW, SET_PSYMTAB_TEXTHIGH): Redefine.
	* xcoffread.c (scan_xcoff_symtab): Use textlow_valid.
---
 gdb/ChangeLog    | 12 ++++++++++++
 gdb/dbxread.c    |  6 ++----
 gdb/mdebugread.c |  8 ++++----
 gdb/psympriv.h   | 33 ++++++++++++++++++++++++++++++---
 gdb/xcoffread.c  |  2 +-
 5 files changed, 49 insertions(+), 12 deletions(-)

diff --git a/gdb/dbxread.c b/gdb/dbxread.c
index 810bdcf57b..da675abb68 100644
--- a/gdb/dbxread.c
+++ b/gdb/dbxread.c
@@ -2100,13 +2100,11 @@ dbx_end_psymtab (struct objfile *objfile, struct partial_symtab *pst,
       /* If we know our own starting text address, then walk through all other
          psymtabs for this objfile, and if any didn't know their ending text
          address, set it to our starting address.  Take care to not set our
-         own ending address to our starting address, nor to set addresses on
-         `dependency' files that have both textlow and texthigh zero.  */
+         own ending address to our starting address.  */
 
       ALL_OBJFILE_PSYMTABS (objfile, p1)
       {
-	if (PSYMTAB_TEXTHIGH (p1) == 0 && PSYMTAB_TEXTLOW (p1) != 0
-	    && p1 != pst)
+	if (!p1->texthigh_valid && p1->textlow_valid && p1 != pst)
 	  SET_PSYMTAB_TEXTHIGH (p1, PSYMTAB_TEXTLOW (pst));
       }
     }
diff --git a/gdb/mdebugread.c b/gdb/mdebugread.c
index 09bdb28088..fb8318a831 100644
--- a/gdb/mdebugread.c
+++ b/gdb/mdebugread.c
@@ -2764,7 +2764,7 @@ parse_partial_symbols (minimal_symbol_reader &reader,
 
 			  /* Kludge for Irix 5.2 zero fh->adr.  */
 			  if (!relocatable
-			      && (PSYMTAB_TEXTLOW (pst) == 0
+			      && (!pst->textlow_valid
 				  || procaddr < PSYMTAB_TEXTLOW (pst)))
 			    SET_PSYMTAB_TEXTLOW (pst, procaddr);
 			  if (high > PSYMTAB_TEXTHIGH (pst))
@@ -3543,7 +3543,7 @@ parse_partial_symbols (minimal_symbol_reader &reader,
 
 		  /* Kludge for Irix 5.2 zero fh->adr.  */
 		  if (!relocatable
-		      && (PSYMTAB_TEXTLOW (pst) == 0
+		      && (!pst->textlow_valid
 			  || procaddr < PSYMTAB_TEXTLOW (pst)))
 		    SET_PSYMTAB_TEXTLOW (pst, procaddr);
 
@@ -3742,7 +3742,7 @@ parse_partial_symbols (minimal_symbol_reader &reader,
          other cases.  */
       save_pst = fdr_to_pst[f_idx].pst;
       if (save_pst != NULL
-	  && PSYMTAB_TEXTLOW (save_pst) != 0
+	  && save_pst->textlow_valid
 	  && !(objfile->flags & OBJF_REORDERED))
 	{
 	  ALL_OBJFILE_PSYMTABS (objfile, pst)
@@ -3957,7 +3957,7 @@ psymtab_to_symtab_1 (struct objfile *objfile,
   /* Do nothing if this is a dummy psymtab.  */
 
   if (pst->n_global_syms == 0 && pst->n_static_syms == 0
-      && PSYMTAB_TEXTLOW (pst) == 0 && PSYMTAB_TEXTHIGH (pst) == 0)
+      && !pst->textlow_valid && !pst->texthigh_valid)
     return;
 
   /* Now read the symbols for this symtab.  */
diff --git a/gdb/psympriv.h b/gdb/psympriv.h
index fa175736ce..8ce3c6b2a9 100644
--- a/gdb/psympriv.h
+++ b/gdb/psympriv.h
@@ -125,7 +125,9 @@ struct partial_symtab
   /* Range of text addresses covered by this file; texthigh is the
      beginning of the next section.  Do not use if PSYMTABS_ADDRMAP_SUPPORTED
      is set.  Do not refer directly to these fields.  Instead, use the
-     accessor macros.  */
+     accessor macros.  The validity of these fields is determined by the
+     textlow_valid and texthigh_valid fields; these are located later
+     in this structure for better packing.  */
 
   CORE_ADDR textlow_;
   CORE_ADDR texthigh_;
@@ -211,6 +213,11 @@ struct partial_symtab
 
   ENUM_BITFIELD (psymtab_search_status) searched_flag : 2;
 
+  /* Validity of the textlow_ and texthigh_ fields.  */
+
+  unsigned int textlow_valid : 1;
+  unsigned int texthigh_valid : 1;
+
   /* Pointer to compunit eventually allocated for this source file, 0 if
      !readin or if we haven't looked for the symtab after it was readin.  */
 
@@ -239,8 +246,28 @@ struct partial_symtab
 #define PSYMTAB_TEXTLOW(PST) ((PST)->textlow_ + 0)
 #define PSYMTAB_TEXTHIGH(PST) ((PST)->texthigh_ + 0)
 
-#define SET_PSYMTAB_TEXTLOW(PST, V) (((PST)->textlow_) = (V))
-#define SET_PSYMTAB_TEXTHIGH(PST, V) (((PST)->texthigh_) = (V))
+/* Set the "textlow" field on the partial symbol table, and mark the
+   field as valid.  */
+
+static inline void
+set_psymtab_textlow (struct partial_symtab *pst, CORE_ADDR low)
+{
+  pst->textlow_ = low;
+  pst->textlow_valid = 1;
+}
+
+/* Set the "texthigh" field on the partial symbol table, and mark the
+   field as valid.  */
+
+static inline void
+set_psymtab_texthigh (struct partial_symtab *pst, CORE_ADDR high)
+{
+  pst->texthigh_ = high;
+  pst->texthigh_valid = 1;
+}
+
+#define SET_PSYMTAB_TEXTLOW(PST, V) set_psymtab_textlow ((PST), (V))
+#define SET_PSYMTAB_TEXTHIGH(PST, V) set_psymtab_texthigh ((PST), (V))
 
 /* Add any kind of symbol to a partial_symbol vector.  */
 
diff --git a/gdb/xcoffread.c b/gdb/xcoffread.c
index 49716a56e5..25df119d51 100644
--- a/gdb/xcoffread.c
+++ b/gdb/xcoffread.c
@@ -2353,7 +2353,7 @@ scan_xcoff_symtab (minimal_symbol_reader &reader,
 
 			if (highval > PSYMTAB_TEXTHIGH (pst))
 			  SET_PSYMTAB_TEXTHIGH (pst, highval);
-			if (PSYMTAB_TEXTLOW (pst) == 0
+			if (!pst->textlow_valid
 			    || symbol.n_value < PSYMTAB_TEXTLOW (pst))
 			  SET_PSYMTAB_TEXTLOW (pst, symbol.n_value);
 		      }
-- 
2.13.6

  parent reply	other threads:[~2018-05-03 22:36 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-05-03 22:36 [RFA 0/6] Make psymbols independent of the progspace Tom Tromey
2018-05-03 22:36 ` [RFA 4/6] Introduce accessors for psymtab high and low fields Tom Tromey
2018-06-01 20:48   ` Keith Seitz
2018-06-04 18:14     ` Tom Tromey
2018-06-05 21:03   ` Simon Marchi
2018-05-03 22:36 ` [RFA 3/6] Make PSYMBOL_VALUE_ADDRESS take objfile argument Tom Tromey
2018-06-01 20:06   ` Keith Seitz
2018-06-01 21:03     ` Tom Tromey
2018-06-05 20:50       ` Simon Marchi
2018-05-03 22:36 ` [RFA 1/6] Remove dead code in end_psymtab Tom Tromey
2018-06-01 18:55   ` Keith Seitz
2018-06-05 19:41     ` Simon Marchi
2018-05-03 22:36 ` [RFA 6/6] Make psymbols and psymtabs independent of the program space Tom Tromey
2018-06-05 20:34   ` Keith Seitz
2018-05-03 22:36 ` [RFA 2/6] Change representation of psymbol to flush out accessors Tom Tromey
2018-06-01 19:19   ` Keith Seitz
2018-06-04 18:11     ` Tom Tromey
2018-06-05 19:49       ` Simon Marchi
2018-06-05 22:56         ` Tom Tromey
2018-06-05 23:31           ` Simon Marchi
2018-05-03 22:36 ` Tom Tromey [this message]
2018-06-01 21:23   ` [RFA 5/6] Add validity bits for psymtab high and low fields Keith Seitz
2018-06-05 17:25     ` Tom Tromey
2018-06-05 17:38       ` Keith Seitz
2018-05-25 17:58 ` [RFA 0/6] Make psymbols independent of the progspace Tom Tromey

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180503223621.22544-6-tom@tromey.com \
    --to=tom@tromey.com \
    --cc=gdb-patches@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).