Merge ktlim@zamp:./local/clean/o3-merge/m5
[gem5.git] / src / sim / pseudo_inst.cc
index bd26e9dc52baa4a9e1e5c9c54c2b8a3e9569b281..aae2f60216d8c4d66cd811bb24c1b56e59864863 100644 (file)
@@ -148,6 +148,54 @@ namespace AlphaPseudo
         exitSimLoop(when, "m5_exit instruction encountered");
     }
 
+    void
+    loadsymbol(ExecContext *xc)
+    {
+        const string &filename = xc->getCpuPtr()->system->params()->symbolfile;
+        if (filename.empty()) {
+            return;
+        }
+
+        std::string buffer;
+        ifstream file(filename.c_str());
+
+        if (!file)
+            fatal("file error: Can't open symbol table file %s\n", filename);
+
+        while (!file.eof()) {
+            getline(file, buffer);
+
+            if (buffer.empty())
+                continue;
+
+            int idx = buffer.find(' ');
+            if (idx == string::npos)
+                continue;
+
+            string address = "0x" + buffer.substr(0, idx);
+            eat_white(address);
+            if (address.empty())
+                continue;
+
+            // Skip over letter and space
+            string symbol = buffer.substr(idx + 3);
+            eat_white(symbol);
+            if (symbol.empty())
+                continue;
+
+            Addr addr;
+            if (!to_number(address, addr))
+                continue;
+
+            if (!xc->getSystemPtr()->kernelSymtab->insert(addr, symbol))
+                continue;
+
+
+            DPRINTF(Loader, "Loaded symbol: %s @ %#llx\n", symbol, addr);
+        }
+        file.close();
+    }
+
     void
     resetstats(ThreadContext *tc, Tick delay, Tick period)
     {