[go: nahoru, domu]

Fix for bug where 64-bit executables were processed as 32-bit executables.

Added some more logging.

TBR=sra

Review URL: http://codereview.chromium.org/988002

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@41598 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/courgette/adjustment_method_2.cc b/courgette/adjustment_method_2.cc
index 9cb9dbd3..244b3a0 100644
--- a/courgette/adjustment_method_2.cc
+++ b/courgette/adjustment_method_2.cc
@@ -18,6 +18,7 @@
 #include "base/format_macros.h"
 #include "base/logging.h"
 #include "base/string_util.h"
+#include "base/time.h"
 
 #include "courgette/assembly_program.h"
 #include "courgette/courgette.h"
@@ -1293,8 +1294,11 @@
   }
 
   void Solve(const Trace& model, size_t model_end) {
+    base::Time start_time = base::Time::Now();
     AssignmentProblem a(model, model_end);
     a.Solve();
+    LOG(INFO) << " Adjuster::Solve "
+              << (base::Time::Now() - start_time).InSecondsF();
   }
 
   void ReferenceLabel(Trace* trace, Label* label, bool is_model) {
diff --git a/courgette/ensemble.cc b/courgette/ensemble.cc
index 15bfb3e..a9b7f38 100644
--- a/courgette/ensemble.cc
+++ b/courgette/ensemble.cc
@@ -63,12 +63,15 @@
         Region region(start + position, info->length());
 
         if (info->has_text_section()) {
-          Element* element = new ElementWinPE(Element::WIN32_X86_WITH_CODE,
-                                              this, region, info);
-          owned_elements_.push_back(element);
-          elements_.push_back(element);
-          position += region.length();
-          continue;
+          if (info->is_32bit()) {
+            Element* element = new ElementWinPE(Element::WIN32_X86_WITH_CODE,
+                                                this, region, info);
+            owned_elements_.push_back(element);
+            elements_.push_back(element);
+            position += region.length();
+            continue;
+          }
+          // TODO(sra): Extend to 64-bit executables.
         }
 
         // If we had a clever transformation for resource-only executables we
diff --git a/courgette/ensemble_create.cc b/courgette/ensemble_create.cc
index 6e64474..00de6887 100644
--- a/courgette/ensemble_create.cc
+++ b/courgette/ensemble_create.cc
@@ -186,6 +186,9 @@
 Status GenerateEnsemblePatch(SourceStream* base,
                              SourceStream* update,
                              SinkStream* final_patch) {
+  LOG(INFO) << "start GenerateEnsemblePatch";
+  base::Time start_time = base::Time::Now();
+
   Region old_region(base->Buffer(), base->Remaining());
   Region new_region(update->Buffer(), update->Remaining());
   Ensemble old_ensemble(old_region, "old");
@@ -376,6 +379,9 @@
   if (!patch_streams.CopyTo(final_patch))
     return C_STREAM_ERROR;
 
+  LOG(INFO) << "done GenerateEnsemblePatch "
+            << (base::Time::Now() - start_time).InSecondsF() << "s";
+
   return C_OK;
 }
 
diff --git a/courgette/win32_x86_generator.h b/courgette/win32_x86_generator.h
index 3aabe9f..c0302ca 100644
--- a/courgette/win32_x86_generator.h
+++ b/courgette/win32_x86_generator.h
@@ -7,6 +7,7 @@
 #ifndef COURGETTE_WIN32_X86_GENERATOR_H_
 #define COURGETTE_WIN32_X86_GENERATOR_H_
 
+#include "base/logging.h"
 #include "base/scoped_ptr.h"
 
 #include "courgette/ensemble.h"
@@ -60,8 +61,10 @@
         ParseWin32X86PE(old_element_->region().start(),
                         old_element_->region().length(),
                         &old_program);
-    if (old_parse_status != C_OK)
+    if (old_parse_status != C_OK) {
+      LOG(ERROR) << "Cannot parse as Win32X86PE " << old_element_->Name();
       return old_parse_status;
+    }
 
     AssemblyProgram* new_program = NULL;
     Status new_parse_status =
@@ -70,6 +73,7 @@
                         &new_program);
     if (new_parse_status != C_OK) {
       DeleteAssemblyProgram(old_program);
+      LOG(ERROR) << "Cannot parse as Win32X86PE " << new_element_->Name();
       return new_parse_status;
     }