@@ -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,6 @@ 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 " );
584
583
uint8_t *first_msg = nullptr ;
585
584
uint8_t *endfm = nullptr ;
586
585
first_msg = interruptData + 1 ; // skip interruptRecvState
@@ -596,7 +595,6 @@ void Debugger::freeState(Module *m, uint8_t *interruptData) {
596
595
switch (*first_msg++) {
597
596
case globalsState: {
598
597
debug (" receiving globals info\n " );
599
- printf (" receiving globals info\n " );
600
598
uint32_t amount = read_B32 (&first_msg);
601
599
debug (" total globals %d\n " , amount);
602
600
// TODO if global_count != amount Otherwise set all to zero
@@ -620,7 +618,6 @@ void Debugger::freeState(Module *m, uint8_t *interruptData) {
620
618
}
621
619
case tblState: {
622
620
debug (" receiving table info\n " );
623
- printf (" receiving table info\n " );
624
621
m->table .initial = read_B32 (&first_msg);
625
622
m->table .maximum = read_B32 (&first_msg);
626
623
uint32_t size = read_B32 (&first_msg);
@@ -637,15 +634,12 @@ void Debugger::freeState(Module *m, uint8_t *interruptData) {
637
634
}
638
635
case memState: {
639
636
debug (" receiving memory info\n " );
640
- printf (" receiving memory info\n " );
641
637
// FIXME: init & max not needed
642
638
m->memory .maximum = read_B32 (&first_msg);
643
639
m->memory .initial = read_B32 (&first_msg);
644
640
uint32_t pages = read_B32 (&first_msg);
645
641
debug (" max %d init %d current page %d\n " , m->memory .maximum ,
646
642
m->memory .initial , pages);
647
- printf (" max %d init %d current page %d\n " , m->memory .maximum ,
648
- m->memory .initial , pages);
649
643
// if(pages !=m->memory.pages){
650
644
// if(m->memory.pages !=0)
651
645
if (m->memory .bytes != nullptr ) {
@@ -669,7 +663,6 @@ void Debugger::freeState(Module *m, uint8_t *interruptData) {
669
663
}
670
664
}
671
665
debug (" done with first msg\n " );
672
- /* printf("done with first msg\n"); */
673
666
}
674
667
675
668
bool Debugger::saveState (Module *m, uint8_t *interruptData) {
@@ -678,7 +671,7 @@ bool Debugger::saveState(Module *m, uint8_t *interruptData) {
678
671
program_state = interruptData + 1 ; // skip interruptRecvState
679
672
endstate = program_state + read_B32 (&program_state);
680
673
681
- printf (" saving program_state\n " );
674
+ debug (" saving program_state\n " );
682
675
while (program_state < endstate) {
683
676
switch (*program_state++) {
684
677
case pcState: { // PC
@@ -688,7 +681,7 @@ bool Debugger::saveState(Module *m, uint8_t *interruptData) {
688
681
}
689
682
case breakpointsState: { // breakpoints
690
683
uint8_t quantity_bps = *program_state++;
691
- printf (" receiving breakpoints %" PRIu8 " \n " , quantity_bps);
684
+ debug (" receiving breakpoints %" PRIu8 " \n " , quantity_bps);
692
685
for (size_t i = 0 ; i < quantity_bps; i++) {
693
686
auto bp = (uint8_t *)readPointer (&program_state);
694
687
this ->addBreakpoint (bp);
@@ -697,7 +690,6 @@ bool Debugger::saveState(Module *m, uint8_t *interruptData) {
697
690
}
698
691
case callstackState: {
699
692
debug (" receiving callstack\n " );
700
- printf (" receiving callstack\n " );
701
693
uint16_t quantity = read_B16 (&program_state);
702
694
debug (" quantity frames %" PRIu16 " \n " , quantity);
703
695
/* printf("quantity frames %" PRIu16 "\n", quantity); */
@@ -712,7 +704,7 @@ bool Debugger::saveState(Module *m, uint8_t *interruptData) {
712
704
if (block_type == 0 ) { // a function
713
705
debug (" function block\n " );
714
706
uint32_t fidx = read_B32 (&program_state);
715
- /* printf ("function block idx=%" PRIu32 "\n", fidx); */
707
+ /* debug ("function block idx=%" PRIu32 "\n", fidx); */
716
708
f->block = m->functions + fidx;
717
709
718
710
if (f->block ->fidx != fidx) {
@@ -722,10 +714,10 @@ bool Debugger::saveState(Module *m, uint8_t *interruptData) {
722
714
}
723
715
m->fp = f->sp + 1 ;
724
716
} else {
725
- printf (" non function block\n " );
717
+ debug (" non function block\n " );
726
718
uint8_t *block_key =
727
719
(uint8_t *)readPointer (&program_state);
728
- /* printf ("block_key=%p\n", static_cast<void
720
+ /* debug ("block_key=%p\n", static_cast<void
729
721
* *>(block_key)); */
730
722
f->block = m->block_lookup [block_key];
731
723
if (f->block == nullptr ) {
@@ -738,7 +730,6 @@ bool Debugger::saveState(Module *m, uint8_t *interruptData) {
738
730
case globalsState: { // TODO merge globalsState stackvalsState into
739
731
// one case
740
732
debug (" receiving global state\n " );
741
- printf (" receiving globals\n " );
742
733
uint32_t quantity_globals = read_B32 (&program_state);
743
734
uint8_t valtypes[] = {I32, I64, F32, F64};
744
735
@@ -760,7 +751,6 @@ bool Debugger::saveState(Module *m, uint8_t *interruptData) {
760
751
break ;
761
752
}
762
753
case tblState: {
763
- printf (" receiving table\n " );
764
754
uint8_t tbl_type =
765
755
(uint8_t )*program_state++; // for now only funcref
766
756
uint32_t quantity = read_B32 (&program_state);
@@ -772,7 +762,6 @@ bool Debugger::saveState(Module *m, uint8_t *interruptData) {
772
762
}
773
763
case memState: {
774
764
debug (" receiving memory\n " );
775
- printf (" receiving memory\n " );
776
765
uint32_t begin = read_B32 (&program_state);
777
766
uint32_t end = read_B32 (&program_state);
778
767
debug (" memory offsets begin=%" PRIu32 " , end=%" PRIu32 " \n " ,
@@ -798,7 +787,6 @@ bool Debugger::saveState(Module *m, uint8_t *interruptData) {
798
787
}
799
788
case brtblState: {
800
789
debug (" receiving br_table\n " );
801
- printf (" receiving br_table\n " );
802
790
uint16_t beginidx = read_B16 (&program_state);
803
791
uint16_t endidx = read_B16 (&program_state);
804
792
debug (" br_table offsets begin=%" PRIu16 " , end=%" PRIu16 " \n " ,
@@ -819,7 +807,7 @@ bool Debugger::saveState(Module *m, uint8_t *interruptData) {
819
807
case stackvalsState: {
820
808
// FIXME the float does add numbers at the end. The extra
821
809
// numbers are present in the send information when dump occurs
822
- printf (" receiving stack\n " );
810
+ debug (" receiving stack\n " );
823
811
uint16_t quantity_sv = read_B16 (&program_state);
824
812
uint8_t valtypes[] = {I32, I64, F32, F64};
825
813
for (size_t i = 0 ; i < quantity_sv; i++) {
0 commit comments