]> git.siccegge.de Git - frida/frida.git/blobdiff - src/Binary.cxx
Resize the basicBlock widget
[frida/frida.git] / src / Binary.cxx
index 1fcd908543ea767bd20affe2cc337d85ade4a72b..a659d5c450a58905effaf526d94f676360ac4935 100644 (file)
@@ -1,5 +1,7 @@
 #include "Binary.hxx"
 
+#include "disassembler/Disassembler.hxx"
+
 #include <iostream>
 #include <string>
 #include <algorithm>
@@ -54,8 +56,8 @@ namespace {
     std::map<std::string, SectionRef> readSections(const ObjectFile& o) {
         error_code ec;
         std::map<std::string, SectionRef> result;
-        section_iterator i(o.begin_sections()), e(o.end_sections());
-        for (; i != e; i.increment(ec)) {
+        section_iterator i(o.section_begin()), e(o.section_end());
+        for (; i != e; ++i) {
             StringRef name;
             if (error(i->getName(name))) break;
 
@@ -67,8 +69,8 @@ namespace {
     std::map<std::string, SymbolRef> readSymbols(const ObjectFile& o) {
         error_code ec;
         std::map<std::string, SymbolRef> result;
-        symbol_iterator si(o.begin_symbols()), se(o.end_symbols());
-        for (; si != se; si.increment(ec)) {
+        symbol_iterator si(o.symbol_begin()), se(o.symbol_end());
+        for (; si != se; ++si) {
             StringRef name;
             if (error(si->getName(name))) break;
 
@@ -83,15 +85,16 @@ namespace qtlldb {
     Binary::Binary(const std::string& filename)
         : triple("unkown-unknown-unknown")
     {
+        ::Disassembler d(filename);
         std::string error;
 
-        createBinary(filename, binary);
-        if (Archive *a = dyn_cast<Archive>(binary.get())) {
+        binary = createBinary(filename).get();
+        if (Archive *a = dyn_cast<Archive>(binary)) {
             std::cerr << "Got an archive!" << std::endl;
             return;
         }
 
-        o = dyn_cast<ObjectFile>(binary.get());
+        o = dyn_cast<ObjectFile>(binary);
 
         triple.setArch(Triple::ArchType(o->getArch()));
         std::string tripleName(triple.getTriple());
@@ -178,8 +181,12 @@ namespace qtlldb {
         std::vector<std::string> result;
         for_each(symbols.begin(), symbols.end(), [&](const std::pair<std::string, SymbolRef>& i) {
                      bool contains;
-                     if (!error(r.containsSymbol(i.second, contains)) && contains)
-                         result.push_back(i.first);
+                                        SymbolRef::Type t;
+                     if (!error(r.containsSymbol(i.second, contains)) && contains) {
+                                                i.second.getType(t);
+                                                if (SymbolRef::ST_Function == t)
+                                                        result.push_back(i.first);
+                                        }
                  });
         return result;
     }
@@ -192,7 +199,7 @@ namespace qtlldb {
 
         if (symbols.end() != symbols.find(function)) {
             SymbolRef ref;
-            section_iterator sec(o->begin_sections());
+            section_iterator sec(o->section_begin());
 
             ref = symbols.at(function);
             if (error(ref.getSection(sec))) return;
@@ -265,9 +272,9 @@ namespace qtlldb {
 
     void Binary::disassemble_functions() {
         error_code ec;
-        for (section_iterator i = o->begin_sections(),
-                 e = o->end_sections();
-             i != e; i.increment(ec)) {
+        for (section_iterator i = o->section_begin(),
+                 e = o->section_end();
+             i != e; ++i) {
             if (error(ec)) break;
             bool text;
             if (error(i->isText(text))) break;
@@ -278,9 +285,9 @@ namespace qtlldb {
 
             // Make a list of all the symbols in this section.
             std::vector<std::pair<uint64_t, StringRef> > Symbols;
-            for (symbol_iterator si = o->begin_symbols(),
-                     se = o->end_symbols();
-                 si != se; si.increment(ec)) {
+            for (symbol_iterator si = o->symbol_begin(),
+                     se = o->symbol_end();
+                 si != se; ++si) {
                 bool contains;
                 if (!error(i->containsSymbol(*si, contains)) && contains) {
                     uint64_t Address;
@@ -361,7 +368,7 @@ namespace qtlldb {
                 outs() << '\n' << Symbols[si].second << ":\n";
 
 #ifndef NDEBUG
-                raw_ostream &DebugOut = DebugFlag ? dbgs() : nulls();
+                raw_ostream &DebugOut = nulls(); //DebugFlag ? dbgs() : nulls();
 #else
                 raw_ostream &DebugOut = nulls();
 #endif