5 #include "SymbolParser.h"
6 #include "Controller.h"
12 SymbolParser::SymbolParser(Misc::SmartPointer
<Controller
> controller
) : StreamHandler(controller
) {
13 assembly_parser
= new AssemblyParser();
18 SymbolParser::~SymbolParser() {
21 void SymbolParser::parse_symbol(Misc::SmartPointer
<Platform::Symbol
> symbol
) {
22 if(symbol
->is_parsed()) return;
23 current_symbol
= symbol
;
25 in_scope
= true; /* it's assumed that the first instruction is within the scope. */
26 get_controller()->send_command(Misc::StreamAsString() << "-interpreter-exec console \"x/i " << symbol
->get_address() << "\"");
29 while(!was_stream
) get_controller()->listen();
30 if(in_scope
) get_controller()->send_command(Misc::StreamAsString() << "-interpreter-exec console \"x/i\"");
34 symbol
->set_parsed(true);
37 bool SymbolParser::handle(Misc::SmartPointer
<StreamOutput
> stream
) {
38 std::cout
<< "SymbolParser::handle_stream: stream content is: " << stream
->get_stream_data() << std::endl
;
40 if(!in_scope
) return true;
44 ss
<< stream
->get_stream_data();
46 std::string symbol_name
;
48 scope
= symbol_name
.substr(1, symbol_name
.length()-3);
49 /*std::cout << "Scope is: \"" << scope << "\"\n";*/
53 ss
<< stream
->get_stream_data();
55 std::string symbol_name
;
57 std::string temporary_scope
;
58 temporary_scope
= symbol_name
.substr(1, symbol_name
.length()-3);
59 temporary_scope
= temporary_scope
.substr(0, temporary_scope
.find("+"));
60 if(scope
!= temporary_scope
) {
61 /*std::cout << "Scope \"" << temporary_scope << "\" does not match original of \"" << scope << "\"" << std::endl;*/
67 /* Add one to get rid of the tab that comes before the instruction . . . */
68 std::string asm_instruction
= stream
->get_stream_data().substr(stream
->get_stream_data().find(":")+2);
69 asm_instruction
.erase(asm_instruction
.length()-1, 1);
71 if(assembly_parser
->changes_memory(asm_instruction
)) add_breakpoint();
75 void SymbolParser::add_breakpoint() {
76 get_controller()->send_command(Misc::StreamAsString() << "-break-insert *" << address
<< "\"");
80 } // namespace Interface
81 } // namespace Aesalon