This is the mail archive of the gdb-cvs@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]

[binutils-gdb] Simplify dwarf2_find_containing_comp_unit


https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=45b8ae0c3348a6e6aa64ad5d114adabdc399c5ef

commit 45b8ae0c3348a6e6aa64ad5d114adabdc399c5ef
Author: Tom Tromey <tom@tromey.com>
Date:   Mon Dec 24 09:55:10 2018 -0700

    Simplify dwarf2_find_containing_comp_unit
    
    In an earlier patch discussion we noticed that
    dwarf2_find_containing_comp_unit takes the address of sect_off, but
    doesn't actually need to.  This is a leftover from before
    C++-ification.  This patch simplifies the function.
    
    Tested using gdb.dwarf2 on x86-64 Fedora 28.
    
    gdb/ChangeLog
    2018-12-18  Tom Tromey  <tom@tromey.com>
    
    	* dwarf2read.c (dwarf2_find_containing_comp_unit): Don't take
    	address of sect_off.

Diff:
---
 gdb/ChangeLog    | 5 +++++
 gdb/dwarf2read.c | 7 ++-----
 2 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index fd5c612..21731be 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,8 @@
+2018-12-18  Tom Tromey  <tom@tromey.com>
+
+	* dwarf2read.c (dwarf2_find_containing_comp_unit): Don't take
+	address of sect_off.
+
 2018-12-23  Joel Brobecker  <brobecker@adacore.com>
 
 	GDB 8.2.1 released.
diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
index bb8e923..8f200d3 100644
--- a/gdb/dwarf2read.c
+++ b/gdb/dwarf2read.c
@@ -25120,7 +25120,6 @@ dwarf2_find_containing_comp_unit (sect_offset sect_off,
 {
   struct dwarf2_per_cu_data *this_cu;
   int low, high;
-  const sect_offset *cu_off;
 
   low = 0;
   high = dwarf2_per_objfile->all_comp_units.size () - 1;
@@ -25130,18 +25129,16 @@ dwarf2_find_containing_comp_unit (sect_offset sect_off,
       int mid = low + (high - low) / 2;
 
       mid_cu = dwarf2_per_objfile->all_comp_units[mid];
-      cu_off = &mid_cu->sect_off;
       if (mid_cu->is_dwz > offset_in_dwz
 	  || (mid_cu->is_dwz == offset_in_dwz
-	      && *cu_off + mid_cu->length >= sect_off))
+	      && mid_cu->sect_off + mid_cu->length >= sect_off))
 	high = mid;
       else
 	low = mid + 1;
     }
   gdb_assert (low == high);
   this_cu = dwarf2_per_objfile->all_comp_units[low];
-  cu_off = &this_cu->sect_off;
-  if (this_cu->is_dwz != offset_in_dwz || *cu_off > sect_off)
+  if (this_cu->is_dwz != offset_in_dwz || this_cu->sect_off > sect_off)
     {
       if (low == 0 || this_cu->is_dwz != offset_in_dwz)
 	error (_("Dwarf Error: could not find partial DIE containing "


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