@@ -182,9 +182,18 @@ void Machine::print_calls_returns()
182
182
if (after_call | after_return) {
183
183
auto &out = get_trace_stream ();
184
184
185
- out << " ---------------------------------------------------\n " ;
185
+ out << " ---------------------------------------------------" ;
186
186
187
- // TODO: print name of the routine at PC.
187
+ // Print name of routine at new address.
188
+ std::string name;
189
+ bool at_start{};
190
+ if (find_resident_name (cpu.get_pc (), name, at_start)) {
191
+ if (!at_start) {
192
+ out << " back to" ;
193
+ }
194
+ out << " " << name;
195
+ }
196
+ out << " \n " ;
188
197
}
189
198
}
190
199
@@ -356,6 +365,11 @@ void Machine::drum_io(char op, unsigned drum_unit, unsigned zone, unsigned secto
356
365
}
357
366
} else {
358
367
drums[drum_unit]->memory_to_drum (zone, sector, addr, nwords);
368
+
369
+ if (debug_instructions && drum_unit == 020 && zone == 0 && nwords == 1024 ) {
370
+ // Load the table of resident programs, for tracing.
371
+ load_resident_directory (addr);
372
+ }
359
373
}
360
374
}
361
375
@@ -795,6 +809,47 @@ void Machine::print_iso_string(std::ostream &out, unsigned addr)
795
809
out << ' \n ' ;
796
810
}
797
811
812
+ //
813
+ // Load the table of resident programs, for tracing.
814
+ //
815
+ void Machine::load_resident_directory (unsigned base)
816
+ {
817
+ resident_name.clear ();
818
+ resident_addr.clear ();
819
+ for (unsigned offset = 0 ; offset < PAGE_NWORDS/4 ; offset += 2 ) {
820
+ Word name = memory.load (base + offset);
821
+ if (name == 0 ) {
822
+ break ;
823
+ }
824
+ unsigned address = memory.load (base + offset + 1 ) & 077777 ;
825
+
826
+ resident_name[address] = word_text_string (name);
827
+ resident_addr.insert (address);
828
+ }
829
+ std::cout << " Load " << resident_name.size () << " names from TRP\n " ;
830
+ }
831
+
832
+ //
833
+ // Find name of resident routine, by address.
834
+ // Set at_start to true when address matches the start of the routine.
835
+ //
836
+ bool Machine::find_resident_name (unsigned addr, std::string &name, bool &at_start)
837
+ {
838
+ // Find the next resident program after given address.
839
+ auto it = resident_addr.upper_bound (addr);
840
+ if (it == resident_addr.begin ()) {
841
+ // No residents at all.
842
+ return false ;
843
+ }
844
+
845
+ // Get start address of the resident.
846
+ unsigned start = *std::prev (it); // Largest element <= addr
847
+
848
+ name = resident_name[start];
849
+ at_start = (addr == start);
850
+ return true ;
851
+ }
852
+
798
853
//
799
854
// Load boot code for Monitoring System Dubna.
800
855
//
0 commit comments