From 17ab01652fc7aa37d560283f5b6109748bced26c Mon Sep 17 00:00:00 2001
From: Jon Turney <jon.turney@dronecode.org.uk>
Date: Fri, 17 Nov 2017 17:14:32 +0000
Subject: [PATCH 26/29] Disable DwpReader for MinGW

elf_reader.cc uses mmap(), which isn't available

Perhaps we could change to using MmapWrapper(), which I've already fixed for
Windows, but this code isn't doing anything for us anyhow

Signed-off-by: Jon Turney <jon.turney@dronecode.org.uk>
---
 Makefile.am                      |  1 -
 src/common/dwarf/dwarf2reader.cc | 12 +++++++++++-
 src/common/dwarf/dwarf2reader.h  |  2 ++
 3 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/Makefile.am b/Makefile.am
index 9261e784..96a75c36 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -804,7 +804,6 @@ src_tools_windows_dump_syms_dwarf_dump_syms_SOURCES = \
 	src/common/dwarf/bytereader.cc \
 	src/common/dwarf/dwarf2diehandler.cc \
 	src/common/dwarf/dwarf2reader.cc \
-	src/common/dwarf/elf_reader.cc \
 	src/common/pecoff/dump_symbols.cc \
 	src/common/pecoff/pecoffutils.cc \
 	src/common/pecoff/pecoff_file_id.cc \
diff --git a/src/common/dwarf/dwarf2reader.cc b/src/common/dwarf/dwarf2reader.cc
index f2dc4afe..0a2c93c3 100644
--- a/src/common/dwarf/dwarf2reader.cc
+++ b/src/common/dwarf/dwarf2reader.cc
@@ -64,7 +64,11 @@ CompilationUnit::CompilationUnit(const string& path,
       is_split_dwarf_(false), dwo_id_(0), dwo_name_(),
       skeleton_dwo_id_(0), ranges_base_(0), addr_base_(0),
       have_checked_for_dwp_(false), dwp_path_(),
-      dwp_byte_reader_(), dwp_reader_() {}
+      dwp_byte_reader_()
+#ifdef DWPREADER_WANTED
+    , dwp_reader_()
+#endif
+{}
 
 // Initialize a compilation unit from a .dwo or .dwp file.
 // In this case, we need the .debug_addr section from the
@@ -346,6 +350,7 @@ uint64 CompilationUnit::Start() {
   // Now that we have our abbreviations, start processing DIE's.
   ProcessDIEs();
 
+#ifdef DWPREADER_WANTED
   // If this is a skeleton compilation unit generated with split DWARF,
   // and the client needs the full debug info, we need to find the full
   // compilation unit in a .dwo or .dwp file.
@@ -353,6 +358,7 @@ uint64 CompilationUnit::Start() {
       && dwo_name_ != NULL
       && handler_->NeedSplitDebugInfo())
     ProcessSplitDwarf();
+#endif
 
   return ourlength;
 }
@@ -610,6 +616,7 @@ inline int GetElfWidth(const ElfReader& elf) {
   return 0;
 }
 
+#ifdef DWPREADER_WANTED
 void CompilationUnit::ProcessSplitDwarf() {
   struct stat statbuf;
   if (!have_checked_for_dwp_) {
@@ -694,7 +701,9 @@ void CompilationUnit::ReadDebugSectionsFromDwo(ElfReader* elf_reader,
              section_size)));
   }
 }
+#endif
 
+#ifdef DWPREADER_WANTED
 DwpReader::DwpReader(const ByteReader& byte_reader, ElfReader* elf_reader)
     : elf_reader_(elf_reader), byte_reader_(byte_reader),
       cu_index_(NULL), cu_index_size_(0), string_buffer_(NULL),
@@ -900,6 +909,7 @@ uint32 DwpReader::LookupCUv2(uint64 dwo_id) {
   }
   return index;
 }
+#endif
 
 LineInfo::LineInfo(const uint8_t *buffer, uint64 buffer_length,
                    ByteReader* reader, LineInfoHandler* handler):
diff --git a/src/common/dwarf/dwarf2reader.h b/src/common/dwarf/dwarf2reader.h
index 5d2d7f60..8e0d41d4 100644
--- a/src/common/dwarf/dwarf2reader.h
+++ b/src/common/dwarf/dwarf2reader.h
@@ -556,8 +556,10 @@ class CompilationUnit {
   // ByteReader for the DWP file.
   std::unique_ptr<ByteReader> dwp_byte_reader_;
 
+#ifdef DWPREADER_WANTED
   // DWP reader.
    std::unique_ptr<DwpReader> dwp_reader_;
+#endif
 };
 
 // A Reader for a .dwp file.  Supports the fetching of DWARF debug
-- 
2.15.0

