コード例 #1
0
ファイル: gui.c プロジェクト: adtools/db101
void main_load(char *name, char *path, char *args)
{
	if (!load_inferior (name, path, args))
	{
		console_printf (OUTPUT_SYSTEM, "New process loaded");
		init_breakpoints();
		console_printf(OUTPUT_SYSTEM, "Interpreting stabs...");
		stabs_init();
		init_symbols();
		if(!stabs_load_module(exec_elfhandle, name))
			console_printf(OUTPUT_WARNING, "Failed to load stabs section for %s", name);
		console_printf(OUTPUT_SYSTEM, "Done!");
		if(!modules_lookup_entry(name))
			modules_add_entry(name, path, TRUE);

		enable(TRUE, GAD_START_BUTTON, GAD_KILL_BUTTON, GAD_SETBREAK_BUTTON, GAD_FILENAME_STRING, GAD_HEX_BUTTON, TAG_END);
		enable(FALSE, GAD_SELECT_BUTTON, GAD_RELOAD_BUTTON, TAG_END);
		button_set_start();

		IIntuition->SetGadgetAttrs((struct Gadget *)MainObj[GAD_FILENAME_STRING], mainwin, NULL,
														STRINGA_TextVal, name,
														TAG_DONE);
		sourcelist_update();
		if(db101_prefs.prefs_show_main_at_entry)
			sourcelist_show_main();
		show_source();
	}
}
コード例 #2
0
ファイル: obs-source.c プロジェクト: Christicles/obs-studio
static void show_tree(obs_source_t parent, obs_source_t child, void *param)
{
	if (os_atomic_inc_long(&child->show_refs) == 1)
		show_source(child);

	UNUSED_PARAMETER(parent);
	UNUSED_PARAMETER(param);
}
コード例 #3
0
ファイル: obs-source.c プロジェクト: Christicles/obs-studio
void obs_source_activate(obs_source_t source, enum view_type type)
{
	if (!source) return;

	if (os_atomic_inc_long(&source->show_refs) == 1) {
		show_source(source);
		obs_source_enum_tree(source, show_tree, NULL);
	}

	if (type == MAIN_VIEW) {
		if (os_atomic_inc_long(&source->activate_refs) == 1) {
			activate_source(source);
			obs_source_enum_tree(source, activate_tree, NULL);
			obs_source_set_present_volume(source, 1.0f);
		}
	}
}
コード例 #4
0
ファイル: load.c プロジェクト: henryem/blinkdb-scheduling
static void add_stmt(
   Prog*       prog,
   const char* filename,
   const int   lineno,
   const char* text)
{
   StmtType type = STMT_ERR;

   assert(prog     != NULL);
   assert(filename != NULL);
   assert(text     != NULL);

   if (!strncmp(text, "set", 3) && isspace(text[3]))
      type = STMT_SET;
   else if (!strncmp(text, "param", 5) && isspace(text[5]))
      type = STMT_PARAM;
   else if (!strncmp(text, "var", 3) && isspace(text[3]))
      type = STMT_VAR;
   else if (!strncmp(text, "minimize", 8) && isspace(text[8]))
      type = STMT_MIN;
   else if (!strncmp(text, "maximize", 8) && isspace(text[8]))
      type = STMT_MAX;
   else if (!strncmp(text, "subto", 5) && isspace(text[5]))
      type = STMT_CONS;
   else if (!strncmp(text, "defnumb", 7) && isspace(text[7]))
      type = STMT_DEF;
   else if (!strncmp(text, "defstrg", 7) && isspace(text[7]))
      type = STMT_DEF;
   else if (!strncmp(text, "defbool", 7) && isspace(text[7]))
      type = STMT_DEF;
   else if (!strncmp(text, "defset", 6) && isspace(text[6]))
      type = STMT_DEF;
   else if (!strncmp(text, "do", 2) && isspace(text[2]))
      type = STMT_DO;
   else if (!strncmp(text, "sos", 3) && isspace(text[3]))
      type = STMT_SOS;
   else
   {
      fprintf(stderr, "*** Error 163: Line %d: Syntax Error\n", lineno);
      show_source(stderr, text, 1);

      zpl_exit(EXIT_FAILURE);
   }
   prog_add_stmt(prog, stmt_new(type, filename, lineno, text));
}
コード例 #5
0
ファイル: gui.c プロジェクト: 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;
}