Began actually producing the assembly content of each function.
[aesalon.git] / src / interface / gdb / SymbolParser.cpp
blobaa54880a388816029a1edc22df5f2b2be0e4a4d0
1 #include <sstream>
3 #include "SymbolParser.h"
4 #include "Controller.h"
6 namespace Aesalon {
7 namespace Interface {
8 namespace GDB {
10 SymbolParser::SymbolParser(Misc::SmartPointer<Controller> gdb_controller) : gdb_controller(gdb_controller) {
11 assembly_parser = new AssemblyParser();
12 previous_stream_handler = gdb_controller->get_processor()->get_stream_handler();
13 gdb_controller->get_processor()->set_stream_handler(this);
14 in_scope = true;
15 first = true;
18 SymbolParser::~SymbolParser() {
19 gdb_controller->get_processor()->set_stream_handler(previous_stream_handler);
22 void SymbolParser::parse_symbol(Misc::SmartPointer<Symbol> symbol) {
23 if(symbol->is_parsed()) return;
24 current_symbol = symbol;
25 gdb_controller->send_command(Misc::StreamAsString() << "-interpreter-exec console \"x/i " << symbol->get_address() << "\"");
26 gdb_controller->listen();
27 while(in_scope) {
28 gdb_controller->send_command(Misc::StreamAsString() << "-interpreter-exec console \"x/i\"");
29 gdb_controller->listen();
30 usleep(50000);
33 symbol->set_parsed(true);
36 void SymbolParser::handle_stream(Misc::SmartPointer<StreamOutput> stream) {
37 std::cout << "Received stream \"" << stream->get_stream_data() << "\"" << std::endl;
38 if(first) {
39 first = false;
40 std::stringstream ss;
41 ss << stream;
42 std::string address;
43 ss >> address;
44 std::string symbol_name;
45 ss >> symbol_name;
46 scope = symbol_name.substr(1, symbol_name.length()-3);
47 std::cout << "Scope is: \"" << scope << "\"\n";
51 } // namespace GDB
52 } // namespace Interface
53 } // namespace Aesalon