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][gdb] Fix build breaker with gcc 4.8


On 19-06-19 14:43, Pedro Alves wrote:
> On 6/19/19 12:04 PM, Tom de Vries wrote:
>> Hi,
>>
>> When compiling with gcc 4.8, we run into:
>> ...
>> /usr/include/c++/4.8/bits/unordered_map.h:100:18: required from \
>>   ‘class std::unordered_map<sect_offset, std::vector<sect_offset> >’
>> src/gdb/dwarf2read.h:260:5:   required from here
>> /usr/include/c++/4.8/bits/hashtable_policy.h:1070:12: error: invalid use of \
>>   incomplete type ‘struct std::hash<sect_offset>’
>> ...
>>
>> Fix this by adding std::hash<sect_offset>.
>>
>> Build and reg-tested on x86_64-linux with gcc 4.8.
>>
>> OK for trunk?
>>
> 
> hash_enum was added for this:
> 
>  https://sourceware.org/ml/gdb-patches/2017-12/msg00210.html
> 
> Can you use it here?
> 
> It's currently used in dwarf2read.c, here:
> 
>   std::unordered_map<sect_offset,
> 		     dwarf2_per_cu_data *,
> 		     gdb::hash_enum<sect_offset>>
> 

Yes, that works for me.

OK for trunk?

Thanks,
- Tom


[gdb] Fix build breaker with gcc 4.8

When compiling with gcc 4.8, we run into:
...
/usr/include/c++/4.8/bits/unordered_map.h:100:18: required from \
  â??class std::unordered_map<sect_offset, std::vector<sect_offset> >â??
src/gdb/dwarf2read.h:260:5:   required from here
/usr/include/c++/4.8/bits/hashtable_policy.h:1070:12: error: invalid use of \
  incomplete type â??struct std::hash<sect_offset>â??
...

Fix this by setting the Hash template parameter of the unordered_map to
gdb::hash_enum<sect_offset>, rather than using the default
std::hash<sect_offset>.

Build and reg-tested on x86_64-linux with gcc 4.8.

gdb/ChangeLog:

2019-06-19  Tom de Vries  <tdevries@suse.de>

	* dwarf2read.h (abstract_to_concrete): Change type to
	std::unordered_map<sect_offset, std::vector<sect_offset>,
	gdb::hash_enum<sect_offset>>.

---
 gdb/dwarf2read.h | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/gdb/dwarf2read.h b/gdb/dwarf2read.h
index 776860e454..7113cfd384 100644
--- a/gdb/dwarf2read.h
+++ b/gdb/dwarf2read.h
@@ -24,6 +24,7 @@
 #include "dwarf-index-cache.h"
 #include "filename-seen-cache.h"
 #include "gdb_obstack.h"
+#include "common/hash_enum.h"
 
 /* Hold 'maintenance (set|show) dwarf' commands.  */
 extern struct cmd_list_element *set_dwarf_cmdlist;
@@ -256,7 +257,8 @@ public:
 
   /* Mapping from abstract origin DIE to concrete DIEs that reference it as
      DW_AT_abstract_origin.  */
-  std::unordered_map<sect_offset, std::vector<sect_offset>>
+  std::unordered_map<sect_offset, std::vector<sect_offset>, \
+		     gdb::hash_enum<sect_offset>> \
     abstract_to_concrete;
 };
 

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