Branch: Tag:

2018-11-29

2018-11-29 09:55:44 by Henrik Grubbström (Grubba) <grubba@grubba.org>

Debugger: Cleaned up debugger_server handling somewhat.

Fixes:
* Unnecessary dynamic allocation of a single svalue.
* Double ref-counted svalue.
* Clean up on exit.

840:   // begining of debugging state. we obviously will need better data structures for this.   THREAD_T stepping_thread = NULL;   int stepping_mode = 0; - struct svalue * debugger_server = NULL; + struct svalue debugger_server = SVALUE_INIT_FREE;      static inline void low_debug_instr_prologue (PIKE_INSTR_T instr)   {
890: Inside #if defined(PIKE_DEBUG)
   printf("got a match!\n");    stepping_thread = th_self();    -  if(debugger_server == NULL) { +  if(TYPEOF(debugger_server) == PIKE_T_FREE) {       push_text("Debug.Debugger.get_debugger_handler");    SAFE_APPLY_MASTER("resolv", 1 );
902: Inside #if defined(PIKE_DEBUG)
   Pike_error("Could not get debugger for breakpoint.\n");    }    -  // TODO check we actually got the memory. -  debugger_server = malloc(sizeof(struct svalue)); +  assign_svalue(&debugger_server, Pike_sp-1);    -  assign_svalue_no_free((debugger_server), Pike_sp-1); -  add_ref_svalue((debugger_server)); -  +     pop_stack();    pop_stack();    }
926: Inside #if defined(PIKE_DEBUG)
   // this seems safe for the basic scenario, but perhaps we should do this on another thread altogether?    stepping_mode = 0;    -  safe_apply_svalue(debugger_server, 5, 1); +  safe_apply_svalue(&debugger_server, 5, 1);       if(TYPEOF(*(Pike_sp - 1)) != T_INT)    {
3820:   void really_clean_up_interpret(void)   {   #ifdef DO_PIKE_CLEANUP +  free_svalue(&debugger_server);   #if 0    struct pike_frame_block *p;    int e;