@@ -300,6 +300,9 @@ void MainWindow::create_core(
300300 connect (machine.data (), &machine::Machine::status_change, this , &MainWindow::machine_status);
301301 connect (machine.data (), &machine::Machine::program_exit, this , &MainWindow::machine_exit);
302302 connect (machine.data (), &machine::Machine::program_trap, this , &MainWindow::machine_trap);
303+ connect (
304+ machine.data ()->core (), &machine::Core::highlight_editor, this ,
305+ &MainWindow::hightlightByAddress);
303306 // Connect signal from break to machine pause
304307 connect (
305308 machine->core (), &machine::Core::stop_on_exception_reached, machine.data (),
@@ -334,6 +337,12 @@ void MainWindow::new_machine() {
334337 ndialog->show ();
335338}
336339
340+ void MainWindow::hightlightByAddress (machine::Address addr) {
341+ auto lineNum = lineToAddress.value (addr);
342+ printf (" hightlightByAddress addr: %x, block: %d\n " , addr, lineNum);
343+ editor_tabs->get_current_editor ()->highlightBlock (lineNum);
344+ }
345+
337346void MainWindow::machine_reload (bool force_memory_reset, bool force_elf_load) {
338347 if (machine == nullptr ) { return new_machine (); }
339348 bool load_executable = force_elf_load || machine->executable_loaded ();
@@ -414,7 +423,7 @@ void MainWindow::reset_state_##NAME() {
414423
415424SHOW_HANDLER (registers, Qt::TopDockWidgetArea, true )
416425SHOW_HANDLER(program, Qt::LeftDockWidgetArea, true )
417- SHOW_HANDLER(memory, Qt::RightDockWidgetArea, true )
426+ SHOW_HANDLER(memory, Qt::RightDockWidgetArea, true )
418427SHOW_HANDLER(cache_program, Qt::RightDockWidgetArea, false )
419428SHOW_HANDLER(cache_data, Qt::RightDockWidgetArea, false )
420429SHOW_HANDLER(cache_level2, Qt::RightDockWidgetArea, false )
@@ -632,7 +641,7 @@ void MainWindow::message_selected(
632641}
633642
634643bool SimpleAsmWithEditorCheck::process_file (const QString &filename, QString *error_ptr) {
635- EditorTab* tab = mainwindow->editor_tabs ->find_tab_by_filename (filename);
644+ EditorTab * tab = mainwindow->editor_tabs ->find_tab_by_filename (filename);
636645 if (tab == nullptr ) { return Super::process_file (filename, error_ptr); }
637646 SrcEditor *editor = tab->get_editor ();
638647 QTextDocument *doc = editor->document ();
@@ -759,6 +768,8 @@ void MainWindow::compile_source() {
759768 }
760769 if (!sasm.finish ()) { error_occured = true ; }
761770
771+ lineToAddress = sasm.addressToLine ;
772+
762773 if (error_occured) { show_messages (); }
763774}
764775
0 commit comments