Ejemplo n.º 1
0
/**
 * If the state #q of the automaton A has a default transition, this function
 * adds all the explicit transitions that are equivalent to the default one.
 */
void explicit_default_transition(language_t* language,SingleGraph A,int q) {
if (A->states[q]->default_state==-1) {
   /* Nothing to do if there is no default transition */
   return;
}
/* We compute the set of symbols tagging transitions that outgo from q */
symbol_t* s=symbols_from_transs(A->states[q]->outgoing_transitions);
/* and we take the complementary set */
symbol_t* all_but_s=minus_symbols(language,s);
add_all_outgoing_transitions(A->states[q],all_but_s,A->states[q]->default_state);
free_symbols(s);
free_symbols(all_but_s);
}
Ejemplo n.º 2
0
Archivo: gui.c Proyecto: adtools/db101
void cleanup()
{
	remove_hook();
	if (!isattached)
		killtask();

	free_symbols();
	close_all_elfhandles();
	stabs_free_stabs();

	hex_close_window();
	breakpoints_close_window();
	modules_close_window();
	main_close_window();
	arexx_close_port();
	
	IExec->FreeSysObject(ASOT_PORT, AppPort);
	
	pipe_cleanup();
	
	variables_cleanup();
	console_cleanup();
	stacktrace_cleanup();
	source_cleanup();
	disassembler_cleanup();
	sourcelist_cleanup();
	
	freemem_free_hook(main_freemem_hook);

	char sysstring[1024] = "";	
	sprintf(sysstring, "setenv DB101_LASTDIR SAVE \"%s\"", lastdir);
	IDOS->SystemTags(sysstring, TAG_END);
}
/**
 * Replaces the given automaton by its complement one.
 */
void elag_complementation(language_t* language,SingleGraph A) {
int sink_state_index=A->number_of_states;
SingleGraphState sink_state=add_state(A);
/* The sink state is not final (because finalities will be reversed
 * below), and its default transition loops back on itself */
sink_state->default_state=sink_state_index;
for (int q=0;q<A->number_of_states;q++) {
   /* We reverse the finality of each state */
   if (is_final_state(A->states[q])) {
      unset_final_state(A->states[q]);
   } else {
      set_final_state(A->states[q]);
   }
   if (A->states[q]->default_state==-1) {
      /* If there is no default transition, we create one that is
       * tagged by anything but the non default ones */
      symbol_t* s=LEXIC_minus_transitions(language,A->states[q]->outgoing_transitions);
      if (s!=NULL) {
         add_all_outgoing_transitions(A->states[q],s,sink_state_index);
         /* We have added a single transition tagged by a symbol list. Now
          * we replace it by a list of transitions, each one of them
          * tagged with a single symbol */
         flatten_transition(A->states[q]->outgoing_transitions);
         /* Important to use free_symbols and not free_symbol, because
          * s represents a symbol list */
         free_symbols(s);
      }
   }
}
}
/**
 * This function returns a symbol list that matches
 * everything but the symbols matched by the given
 * transition list, or NULL if the transition list
 * matches everything.
 */
symbol_t* LEXIC_minus_transitions(language_t* language,Transition* trans) {
#ifdef NO_C99_VARIABLE_LENGTH_ARRAY
symbol_t** POS=(symbol_t**)malloc(sizeof(symbol_t*)*(language->POSs->size));
#else
symbol_t* POS[language->POSs->size];
#endif
int i;
/* First we build an array containing a full symbol for each POS.
 * For instance, we could have POS[0]=<A>, POS[1]=<V>, etc. */
for (i=0;i<language->POSs->size;i++) {
   POS[i]=new_symbol_POS((POS_t*)language->POSs->value[i],-1);
}
symbol_t* tmp;
while (trans!=NULL) {
   tmp=(symbol_t*)trans->label;
   if (tmp->type==S_LEXIC) {
      /* If a transition matches everything, then we can stop
       * and return NULL */
      for (i=0;i<language->POSs->size;i++) {
         free_symbols(POS[i]);
      }
#ifdef NO_C99_VARIABLE_LENGTH_ARRAY
	  free(POS);
#endif
      return NULL;
   }
   /* If we have a transition tagged by <A:s>, we have to replace
    * the POS array cell #z that corresponds to <A> by POS[z]-<A:s>,
    * that may give something like POS[z]=<A:p> */
   symbol_t* minus=symbols_minus_symbol(language,POS[tmp->POS->index],tmp);
   free_symbols(POS[tmp->POS->index]);
   POS[tmp->POS->index]=minus;
   trans=trans->next;
}
/* Finally, we concatenate all the symbols we have computed into
 * one symbol list */
symbol_t res;
res.next=NULL;
symbol_t* end=&res;
for (i=0;i<language->POSs->size;i++) {
   concat_symbols(end,POS[i],NULL);
}
#ifdef NO_C99_VARIABLE_LENGTH_ARRAY
free(POS);
#endif
return res.next;
}
Ejemplo n.º 5
0
bool_t free_awkvm(awkvm_t *vm) {
  if( vm ) {
    free_objstack(&vm->codeblocks);
    free_awkconstmgr(&vm->constants);
    free_objstack(&vm->symtable);
    free_symbols(&vm->sym);
  }
  return FALSE;
}
Ejemplo n.º 6
0
 void bvisit(const Subs &x) {
     set_basic set_ = free_symbols(*x.get_arg());
     for (const auto &p: x.get_variables()) {
         set_.erase(p);
     }
     s.insert(set_.begin(), set_.end());
     for (const auto &p: x.get_point()) {
         p->accept(*this);
     }
 }
Ejemplo n.º 7
0
Archivo: gui.c Proyecto: adtools/db101
void event_loop()
{
            ULONG wait, signal;
			BOOL shouldplay = FALSE;
			char *symbol = NULL;
			branch branchallowed = NOBRANCH;

            /* Obtain the window wait signal mask. */
            //IIntuition->GetAttr( WINDOW_SigMask, MainWinObj, &signal );
            
            /* Input Event Loop */
            while( !done )
            {
				signal = obtain_all_signals();

                wait = IExec->Wait(signal|SIGBREAKF_CTRL_C|SIGF_CHILD);
                								
                if (wait & SIGBREAKF_CTRL_C) done = TRUE;
                
				if(wait & debug_sigfield)
				{
					//console_printf(OUTPUT_SYSTEM, "SIG from debug hook\n");
					//console_printf(OUTPUT_SYSTEM, "traptype = 0x%08x\n", *((uint32 *)debug_hook.h_Data));

					button_set_continue();

					BOOL crashed = FALSE;
					uint32 traptype = *((uint32 *)debug_hook.h_Data);
					if(traptype != 0x700 && traptype != 0xd00)
					{
						catch_sline = FALSE;
						should_continue = FALSE;
						console_printf(OUTPUT_WARNING, "Your program has crashed! ip = 0x%x", context_copy.ip);
					}

					BOOL tracing = FALSE;

					//signal from debugger means TRAP
					task_playing = FALSE;
					suspend_all_breakpoints();
					
					if(stepping_out)
					{
						stepping_out = FALSE;
						stepout_remove();
					}
					if (asm_trace)
					{
						asmstep_remove();
						if(!should_continue && !stepping_over)
						{
							switch(is_branch_allowed())
							{
								case DISALLOWEDBRANCH:
									if(catch_sline)
									{
										stepping_out = TRUE;
										stepout_install();
										shouldplay = TRUE;
									}
									else
									{
										//console_printf(OUTPUT_WARNING, "Branch into new area not allowed!");
										enable(TRUE, GAD_STEPOUT_BUTTON, TAG_END);
										enable(FALSE, GAD_STEPINTO_BUTTON, GAD_STEPOVER_BUTTON, GAD_DISASSEMBLER_STEP_BUTTON, TAG_END);
									}
									catch_sline = FALSE;
									stepping_over = FALSE;
									break;
								case DISALLOWEDBRANCHCOND:
									if(catch_sline)
									{
										stepping_out = TRUE;
										stepout_install();
										shouldplay = TRUE;
									}
									else
									{
										//console_printf(OUTPUT_WARNING, "Branch into new area not allowed!");
										enable(TRUE, GAD_STEPOVER_BUTTON, GAD_STEPOUT_BUTTON, TAG_END);
										enable(FALSE, GAD_STEPINTO_BUTTON, GAD_DISASSEMBLER_STEP_BUTTON, TAG_END);
									}
									catch_sline = FALSE;
									stepping_over = FALSE;
									break;
								default:
									break;
							}
						}			
						tracing = TRUE;
						if(!should_continue && !catch_sline)
						{
							disassembler_makelist();
							variables_update();
							source_update();
						}
					}
					if (should_continue)
					{
						install_all_breakpoints();
						shouldplay = TRUE;
						should_continue = FALSE;
					}
					else
					{
						current_function = stabs_get_function_from_address (context_copy.ip);
						if (current_function)
							hasfunctioncontext = TRUE;
						else if(!stepping_over && try_import_segment(context_copy.ip) > 0)
						{
							current_function = stabs_get_function_from_address(context_copy.ip);
							if(current_function)
								hasfunctioncontext = TRUE;
							else
								hasfunctioncontext = FALSE;
						}
						else
							hasfunctioncontext = FALSE;
							
						if (hasfunctioncontext)
						{
							//dprintf("current_function == %s\n", current_function->name);
							//if(stepover_func)
							//	dprintf("stepover_func == %s\n", stepover_func->name);
							
							int nline = get_nline_from_address (context_copy.ip);
							
							if(nline >= 0)
							{
								if(stepping_over)
								{
									if(current_function == stepover_func
										&& current_function->line[nline].infile != current_function->line[current_function->currentline].infile)
									{
										catch_sline = FALSE;
										stepping_over = FALSE;
										current_function->currentline = nline;
									}
								}
								else
								{
									catch_sline = FALSE;
									current_function->currentline = nline;
								}
							}
							else if (!catch_sline)
							{
								nline = guess_line_in_function();
								if(nline)
									current_function->currentline = nline;
							}
							else if (!tracing)
							{
								console_printf(OUTPUT_WARNING, "Function overload error!");
								//printf("function size: 0x%x function address: 0x%x\n", current_function->size, current_function->address);
							}
						}
						else if(!stepping_over && (symbol = get_symbol_from_value(context_copy.ip)))
						{
							console_printf(OUTPUT_NORMAL, "At symbol %s: 0x%x", symbol, context_copy.ip);
							if(catch_sline)
							{
								catch_sline = FALSE;
								enable(TRUE, GAD_START_BUTTON, GAD_STEPINTO_BUTTON, GAD_STEPOUT_BUTTON, GAD_DISASSEMBLER_STEP_BUTTON, TAG_END);
								enable(FALSE, GAD_PAUSE_BUTTON, GAD_STEPOVER_BUTTON, TAG_END);
							}
							source_update();
							variables_update();
							stacktrace_update();
							disassembler_makelist();
							
							show_disassembler();
						}
						else if(!stepping_over && !tracing)
						{
							console_printf(OUTPUT_WARNING, "Program has stopped at an unknown point in memory (TRAP)");
							disassembler_makelist();
							variables_update();
							stacktrace_update();
							show_disassembler();
						}

						if(catch_sline)
						{
							if(stepping_over && get_branched_function() != current_function)
								asmstep_nobranch();
							else
								asmstep();
						}
						else if(hasfunctioncontext)
						{
							if (current_function != old_function)
								output_functionheader();
							old_function = current_function;

							enable(TRUE, GAD_START_BUTTON, GAD_STEPOVER_BUTTON, GAD_STEPINTO_BUTTON, GAD_STEPOUT_BUTTON, GAD_KILL_BUTTON, TAG_END);
							enable(FALSE, GAD_PAUSE_BUTTON, GAD_SELECT_BUTTON, TAG_END);

							remove_line_breakpoints();

							variables_update();
							stacktrace_update();
							disassembler_makelist();
							source_update();
							
							if(!tracing)
								show_source();
						}
					}
				}
                if(wait & SIGF_CHILD)
				{
					task_exists = FALSE;
					task_playing = FALSE;
					should_continue = FALSE;
					asm_trace = FALSE;
					hasfunctioncontext = FALSE;
					current_function = NULL;
					breakpoints_installed = FALSE;

					enable(TRUE, GAD_RELOAD_BUTTON, GAD_SELECT_BUTTON, TAG_END);
					enable(FALSE, GAD_START_BUTTON, GAD_PAUSE_BUTTON, GAD_STEPOVER_BUTTON, GAD_STEPINTO_BUTTON,
								  GAD_KILL_BUTTON, GAD_SETBREAK_BUTTON, GAD_FILENAME_STRING, GAD_HEX_BUTTON, TAG_END);

					button_set_start();
					IIntuition->RefreshGadgets ((struct Gadget *)MainObj[GAD_FILENAME_STRING], mainwin, NULL);

					close_all_elfhandles();
					free_symbols();
					stabs_free_stabs();
					free_breakpoints();
					//tracking_clear();

					modules_close_window();
					hex_close_window();
					variables_clear();
					source_clear();
					sourcelist_clear();
					stacktrace_clear();
					disassembler_clear();

					console_printf(OUTPUT_SYSTEM, "Program has ended");
				}

				if (wait & main_obtain_window_signal())
				{
					main_event_handler();
				}
				if (wait & hex_obtain_window_signal())
				{
					hex_event_handler();
				}
				if (wait & breakpoints_obtain_window_signal())
				{
					breakpoints_event_handler();
				}
				if (wait & sigwin_obtain_signal())
				{
					sigwin_event_handler();
				}
				if(wait & import_obtain_window_signal())
				{
					import_event_handler();
				}
				if(wait & arexx_obtain_signal())
				{
					arexx_event_handler();
				}
				if(wait & pipe_obtain_signal())
				{
					char buffer[1024];
					int len = pipe_read(buffer);
					console_write_raw_data(OUTPUT_FROM_EXECUTABLE, buffer, len);
				}
				if (shouldplay)
				{
					play();
					task_playing = TRUE;
				}
				shouldplay = FALSE;
			}
			return;
}
Ejemplo n.º 8
0
Archivo: main.c Proyecto: vidarh/ACE
int dothehardpart( void )
{
  int len, c, n=0;
  int faux_pas= 0;
  long codesize= 0;

  /* initialize globals */

  numsyms= numlines= 0;

  /* begin scanning the input stream */

  c= fgetc(fin);

  if(c != 0xf5)
  {
    warn("Hmmm... this doesn't look like an AmigaBASIC binary.\n"
         "My output will probably look a bit funny.  Proceed, for a laugh.");
  }

  if( feof(fin) || ferror(fin) )
  { warn("unexpected end of input -- no code, no symbols");
    return 1;
  }

  /* read the code segment */

  do {

    /* Stefan Reisner thought that AmigaBASIC encodes the length of a line
     * in a 2 byte word prefix.  This is not the whole truth...
     * I've experienced that the first byte holds a flag (e.g. 0x80 indicates
     * a line number) and only the second byte encodes the length.
     */

    c= fgetc(fin); /* flags */

    if( len= fgetc(fin) )
    {
      codesize += len;
      len-= 2;

      if( !feof(fin) && !ferror(fin) )
        n= read_line(fin,len,c);
    }

  } while( len && n == len && !ferror(fin) && !feof(fin) );

  if( len )
  {
    if( n != len || ferror(fin) )
    {
      warn("I'm confused; after having read the code segment, I still seem\n"
           "to want to go on.  In fact I just wanted to read another %d bytes\n"
           "when a serious problem interrupted me.  I'll try to forget about this.",len);
    }

    if( feof(fin) )
    {
      warn("Uh, oh.  I suspect there was a null missing at the end of the code segment,\n"
           "causing me to read past where I should stop.\n"
           "I'll forget about the symbols now.  Proceed, with fingers crossed.");
    }
  }
  else if( feof(fin) || ferror(fin) ) /* and len <= 0 */
    warn("This seems to be a funny program.  The input ended without any symbol definitions.\n");

  /* read the symbols */

  if( !ferror(fin) && !feof(fin) )
  {
    int ok= 1;

#ifdef DEBUG
    if(debuglevel >= 1)
      fprintf(stderr,"skipping a '\\x%02x' character\n",fgetc(fin));
    else
#endif
      (void)fgetc(fin);  /* skip null byte */

    if( (codesize & 1) == 0 )
    {
#ifdef DEBUG
      if(debuglevel >= 1)
        fprintf(stderr,"skipping another '\\x%02x' character\n",fgetc(fin));
      else
#endif
      (void)fgetc(fin);
    }

    if( feof(fin) || ferror(fin) )
    {
      warn("I was just about to read the symbols when I reached the end of file.\n"
           "Maybe we have a BASIC program without symbols?  We'll see...");
    }

    else do {
      len= fgetc(fin);

      if( !feof(fin) )
        ok= read_sym(fin, len, numsyms++);

    } while( ok && !feof(fin) && !ferror(fin) );

    if( !ok )
    {
      warn("After having read %ld %s I couldn't get another %d bytes.\n"
           "Maybe there is not enough free store?  I'll better stop reading symbols!",
           numsyms-1, (numsyms-1 == 1) ? "symbol": "symbols");
    }
  }

#ifdef DEBUG
    if(debuglevel >= 1)
      fprintf(stderr,"expanding %ld lines of code w/ %d symbols\n",numlines,numsyms);
#endif

  expand_code();

  /* we _must_ call these to become re-entrant */

  free_symbols();
  free_code();

  return faux_pas;
}
Ejemplo n.º 9
0
static void free_months(UChar *months[])
{
    free_symbols(months, MONTH_COUNT - 1);
}
Ejemplo n.º 10
0
static void free_days(UChar *days[])
{
    free_symbols(days, DAY_COUNT);
}