Branch: Tag:

2018-12-03

2018-12-03 04:38:40 by William Welliver <william@welliver.org>

debugger: track stepping mode by thread, remove some debugging output

838:         // begining of debugging state. we obviously will need better data structures for this. - int stepping_mode = 0; - THREAD_T stepping_thread = NULL; - #define IS_THREAD_STEPPING(A) (stepping_thread == A) + #define IS_THREAD_STEPPING(A) (A->stepping_mode)   struct svalue debugger_server = SVALUE_INIT_FREE;      static inline void low_debug_instr_prologue (PIKE_INSTR_T instr)
849:    struct pike_string *filep;    INT_TYPE linep;    int debug_retval = 0; +  struct thread_state * th_state; +    #ifdef PIKE_DEBUG    /* This block exists solely to print some debug when we execute opcodes in a thread that's stepping,    or a program that contains breakpoints. */ -  if((stepping_mode != 0 && IS_THREAD_STEPPING(th_self())) || (bp = Pike_fp->context->prog->breakpoints) != NULL) +  th_state = thread_state_for_id(th_self()); +  +  /* +  if((IS_THREAD_STEPPING(th_state)) || (bp = Pike_fp->context->prog->breakpoints) != NULL)    {    char *file = NULL, *f;    struct pike_string *filep2;    -  printf("stepping_mode: %d, stepping_thread: %p\n", stepping_mode, stepping_thread); + // printf("stepping_mode: %d\n", IS_THREAD_STEPPING(th_state));    filep2 = get_line(Pike_fp->pc,Pike_fp->context->prog,&linep);    if (filep2 && !filep2->size_shift) {    file = filep2->str;
875: Inside #if defined(PIKE_DEBUG)
      printf("pro: %p, %p %p, %p\n", bp_prog, Pike_fp->context->prog, bp_offset, Pike_fp->pc - Pike_fp->context->prog->program);    } + */       /* This block performs the actual breakpoint/step behavior */ -  if((stepping_mode != 0 && IS_THREAD_STEPPING(th_self())) || bp != NULL ) { +  if((IS_THREAD_STEPPING(th_state)) || (bp = Pike_fp->context->prog->breakpoints) != NULL ) {    int pause_here = 0; -  if(stepping_mode != 0) { +  if(IS_THREAD_STEPPING(th_state)) {    pause_here = 1;    } else {    while(bp != NULL) {
891: Inside #if defined(PIKE_DEBUG)
   };    }    if(pause_here) { -  printf("got a match!\n"); -  stepping_thread = th_self(); +  // printf("got a match!\n");       if(TYPEOF(debugger_server) == PIKE_T_FREE) { -  +     push_text("Debug.Debugger.get_debugger_handler");    SAFE_APPLY_MASTER("resolv", 1 );   
924: Inside #if defined(PIKE_DEBUG)
      // we don't want to step though any of the do_breakpoint() instructions that actually wake up the debugger.    // this seems safe for the basic scenario, but perhaps we should do this on another thread altogether? -  stepping_mode = 0; -  +  th_state->stepping_mode = 0;    safe_apply_svalue(&debugger_server, 5, 1);       if(TYPEOF(*(Pike_sp - 1)) != T_INT)
939: Inside #if defined(PIKE_DEBUG)
      if(debug_retval == 1) // single_step    { -  stepping_mode = 1; // single_step +  th_state->stepping_mode = 1;    } else { -  stepping_mode = 0; -  stepping_thread = 0; +  th_state->stepping_mode = 0;    }    }