@@ -216,7 +216,7 @@ bool Debugger::checkDebugMessages(Module *m, RunningState *program_state) {
216
216
}
217
217
218
218
// Private methods
219
- void Debugger::printValue (StackValue *v, int idx, bool end = false ) {
219
+ void Debugger::printValue (StackValue *v, int idx, bool end = false ) const {
220
220
char buff[256 ];
221
221
222
222
switch (v->value_type ) {
@@ -266,7 +266,7 @@ void Debugger::handleInterruptRUN(Module *m, RunningState *program_state) {
266
266
*program_state = WARDUINOrun;
267
267
}
268
268
269
- void Debugger::handleInterruptBP (uint8_t *interruptData) {
269
+ void Debugger::handleInterruptBP (const uint8_t *interruptData) {
270
270
// TODO: segfault may happen here!
271
271
uint8_t len = interruptData[1 ];
272
272
uintptr_t bp = 0x0 ;
@@ -305,7 +305,7 @@ void Debugger::dump(Module *m, bool full) const {
305
305
}
306
306
307
307
dprintf (this ->socket , " }\n\n " );
308
- fflush (stdout);
308
+ // fflush(stdout);
309
309
}
310
310
311
311
void Debugger::dumpBreakpoints (Module *m) const {
@@ -350,7 +350,7 @@ void Debugger::dumpCallstack(Module *m) const {
350
350
}
351
351
352
352
void Debugger::dumpLocals (Module *m) const {
353
- fflush (stdout);
353
+ // fflush(stdout);
354
354
int firstFunFramePtr = m->csp ;
355
355
while (m->callstack [firstFunFramePtr].block ->block_type != 0 ) {
356
356
firstFunFramePtr--;
@@ -360,7 +360,7 @@ void Debugger::dumpLocals(Module *m) const {
360
360
}
361
361
Frame *f = &m->callstack [firstFunFramePtr];
362
362
dprintf (this ->socket , R"( {"count":%u,"locals":[)" , 0 );
363
- fflush (stdout); // FIXME: this is needed for ESP to propery print
363
+ // fflush(stdout); // FIXME: this is needed for ESP to propery print
364
364
char _value_str[256 ];
365
365
for (size_t i = 0 ; i < f->block ->local_count ; i++) {
366
366
auto v = &m->stack [m->fp + i];
@@ -387,12 +387,12 @@ void Debugger::dumpLocals(Module *m) const {
387
387
v->value_type , v->value .uint64 );
388
388
}
389
389
390
- dprintf (this ->socket , " {%s, \" index\" :%i }%s" , _value_str,
390
+ dprintf (this ->socket , " {%s, \" index\" :%lu }%s" , _value_str,
391
391
i + f->block ->type ->param_count ,
392
392
(i + 1 < f->block ->local_count ) ? " ," : " " );
393
393
}
394
394
dprintf (this ->socket , " ]}" );
395
- fflush (stdout);
395
+ // fflush(stdout);
396
396
}
397
397
398
398
/* *
@@ -580,7 +580,7 @@ enum ReceiveState {
580
580
581
581
void Debugger::freeState (Module *m, uint8_t *interruptData) {
582
582
debug (" freeing the program state\n " );
583
- printf (" freeing the program state\n " );
583
+ debug (" freeing the program state\n " );
584
584
uint8_t *first_msg = nullptr ;
585
585
uint8_t *endfm = nullptr ;
586
586
first_msg = interruptData + 1 ; // skip interruptRecvState
@@ -596,7 +596,7 @@ void Debugger::freeState(Module *m, uint8_t *interruptData) {
596
596
switch (*first_msg++) {
597
597
case globalsState: {
598
598
debug (" receiving globals info\n " );
599
- printf (" receiving globals info\n " );
599
+ debug (" receiving globals info\n " );
600
600
uint32_t amount = read_B32 (&first_msg);
601
601
debug (" total globals %d\n " , amount);
602
602
// TODO if global_count != amount Otherwise set all to zero
@@ -620,7 +620,7 @@ void Debugger::freeState(Module *m, uint8_t *interruptData) {
620
620
}
621
621
case tblState: {
622
622
debug (" receiving table info\n " );
623
- printf (" receiving table info\n " );
623
+ debug (" receiving table info\n " );
624
624
m->table .initial = read_B32 (&first_msg);
625
625
m->table .maximum = read_B32 (&first_msg);
626
626
uint32_t size = read_B32 (&first_msg);
@@ -637,15 +637,13 @@ void Debugger::freeState(Module *m, uint8_t *interruptData) {
637
637
}
638
638
case memState: {
639
639
debug (" receiving memory info\n " );
640
- printf (" receiving memory info\n " );
640
+ debug (" receiving memory info\n " );
641
641
// FIXME: init & max not needed
642
642
m->memory .maximum = read_B32 (&first_msg);
643
643
m->memory .initial = read_B32 (&first_msg);
644
644
uint32_t pages = read_B32 (&first_msg);
645
645
debug (" max %d init %d current page %d\n " , m->memory .maximum ,
646
646
m->memory .initial , pages);
647
- printf (" max %d init %d current page %d\n " , m->memory .maximum ,
648
- m->memory .initial , pages);
649
647
// if(pages !=m->memory.pages){
650
648
// if(m->memory.pages !=0)
651
649
if (m->memory .bytes != nullptr ) {
@@ -669,7 +667,6 @@ void Debugger::freeState(Module *m, uint8_t *interruptData) {
669
667
}
670
668
}
671
669
debug (" done with first msg\n " );
672
- /* printf("done with first msg\n"); */
673
670
}
674
671
675
672
bool Debugger::saveState (Module *m, uint8_t *interruptData) {
@@ -681,13 +678,13 @@ bool Debugger::saveState(Module *m, uint8_t *interruptData) {
681
678
while (program_state < endstate) {
682
679
switch (*program_state++) {
683
680
case pcState: { // PC
684
- printf ( " reciving pc\n " );
681
+ debug ( " receiving pc\n " );
685
682
m->pc_ptr = (uint8_t *)readPointer (&program_state);
686
683
break ;
687
684
}
688
685
case breakpointsState: { // breakpoints
689
686
uint8_t quantity_bps = *program_state++;
690
- printf (" receiving breakpoints %" PRIu8 " \n " , quantity_bps);
687
+ debug (" receiving breakpoints %" PRIu8 " \n " , quantity_bps);
691
688
for (size_t i = 0 ; i < quantity_bps; i++) {
692
689
auto bp = (uint8_t *)readPointer (&program_state);
693
690
this ->addBreakpoint (bp);
@@ -696,7 +693,7 @@ bool Debugger::saveState(Module *m, uint8_t *interruptData) {
696
693
}
697
694
case callstackState: {
698
695
debug (" receiving callstack\n " );
699
- printf (" receiving callstack\n " );
696
+ debug (" receiving callstack\n " );
700
697
uint16_t quantity = read_B16 (&program_state);
701
698
debug (" quantity frames %" PRIu16 " \n " , quantity);
702
699
for (size_t i = 0 ; i < quantity; i++) {
@@ -719,10 +716,10 @@ bool Debugger::saveState(Module *m, uint8_t *interruptData) {
719
716
}
720
717
m->fp = f->sp + 1 ;
721
718
} else {
722
- printf (" non function block\n " );
719
+ debug (" non function block\n " );
723
720
uint8_t *block_key =
724
721
(uint8_t *)readPointer (&program_state);
725
- /* printf ("block_key=%p\n", static_cast<void
722
+ /* debug ("block_key=%p\n", static_cast<void
726
723
* *>(block_key)); */
727
724
f->block = m->block_lookup [block_key];
728
725
if (f->block == nullptr ) {
@@ -735,7 +732,7 @@ bool Debugger::saveState(Module *m, uint8_t *interruptData) {
735
732
case globalsState: { // TODO merge globalsState stackvalsState into
736
733
// one case
737
734
debug (" receiving global state\n " );
738
- printf (" receiving globals\n " );
735
+ debug (" receiving globals\n " );
739
736
uint32_t quantity_globals = read_B32 (&program_state);
740
737
uint8_t valtypes[] = {I32, I64, F32, F64};
741
738
@@ -757,7 +754,7 @@ bool Debugger::saveState(Module *m, uint8_t *interruptData) {
757
754
break ;
758
755
}
759
756
case tblState: {
760
- printf (" receiving table\n " );
757
+ debug (" receiving table\n " );
761
758
uint8_t tbl_type =
762
759
(uint8_t )*program_state++; // for now only funcref
763
760
uint32_t quantity = read_B32 (&program_state);
@@ -769,7 +766,7 @@ bool Debugger::saveState(Module *m, uint8_t *interruptData) {
769
766
}
770
767
case memState: {
771
768
debug (" receiving memory\n " );
772
- printf (" receiving memory\n " );
769
+ debug (" receiving memory\n " );
773
770
uint32_t begin = read_B32 (&program_state);
774
771
uint32_t end = read_B32 (&program_state);
775
772
debug (" memory offsets begin=%" PRIu32 " , end=%" PRIu32 " \n " ,
@@ -795,7 +792,7 @@ bool Debugger::saveState(Module *m, uint8_t *interruptData) {
795
792
}
796
793
case brtblState: {
797
794
debug (" receiving br_table\n " );
798
- printf (" receiving br_table\n " );
795
+ debug (" receiving br_table\n " );
799
796
uint16_t beginidx = read_B16 (&program_state);
800
797
uint16_t endidx = read_B16 (&program_state);
801
798
debug (" br_table offsets begin=%" PRIu16 " , end=%" PRIu16 " \n " ,
@@ -816,7 +813,7 @@ bool Debugger::saveState(Module *m, uint8_t *interruptData) {
816
813
case stackvalsState: {
817
814
// FIXME the float does add numbers at the end. The extra
818
815
// numbers are present in the send information when dump occurs
819
- printf (" receiving stack\n " );
816
+ debug (" receiving stack\n " );
820
817
uint16_t quantity_sv = read_B16 (&program_state);
821
818
uint8_t valtypes[] = {I32, I64, F32, F64};
822
819
for (size_t i = 0 ; i < quantity_sv; i++) {
0 commit comments