Beispiel #1
0
/*
 * select frame
 */
static void set_active_frame(int frame_number)
{
	gchar *command = g_strdup_printf("-stack-select-frame %i", frame_number);
	if (RC_DONE == exec_sync_command(command, TRUE, NULL))
	{
		active_frame = frame_number;
		update_autos();
		update_watches();
	}
	g_free(command);
}
Beispiel #2
0
void update_all(int gno)
{
    update_set_lists(gno);
    update_world(gno);
    update_view(gno);
    update_status(gno, cur_statusitem, -1);
    update_ticks(gno);
    update_autos(gno);
    updatelegends(gno);
    updatesymbols(gno, -1);
    update_label_proc();
    update_locator_items(gno);
    update_draw();
    update_frame_items(gno);
    update_graph_items();
    update_hotlinks();
}
Beispiel #3
0
static gboolean on_read_from_gdb(GIOChannel * src, GIOCondition cond, gpointer data)
{
	gchar *line;
	gsize length;
	
	if (G_IO_STATUS_NORMAL != g_io_channel_read_line(src, &line, NULL, &length, NULL))
		return TRUE;		

	gboolean prompt = !strcmp(line, GDB_PROMPT);
	
	*(line + length) = '\0';

	if (!prompt)
	{
		if ('~' == line[0])
		{
			colorize_message(line);
		}
		else
		{
			gchar *compressed = g_strcompress(line);
			colorize_message(compressed);
			g_free(compressed);
		}
	}
		
	if (!target_pid && g_str_has_prefix(line, "=thread-group-created"))
	{
		*(strrchr(line, '\"')) = '\0';
		target_pid = atoi(line + strlen("=thread-group-created,id=\""));
	}
	else if (g_str_has_prefix(line, "=thread-created"))
	{
		*(strrchr(line, ',') - 1) = '\0';
		int thread_id = atoi(line + strlen("=thread-created,id=\""));
		dbg_cbs->add_thread(thread_id);
	}
	else if (g_str_has_prefix(line, "=thread-exited"))
	{
		*(strrchr(line, ',') - 1) = '\0';
		int thread_id = atoi(line + strlen("=thread-exited,id=\""));
		dbg_cbs->remove_thread(thread_id);
	}
	else if (g_str_has_prefix(line, "=library-loaded") || g_str_has_prefix(line, "=library-unloaded"))
	{
		file_refresh_needed = TRUE;
	}
	else if (*line == '*')
	{
		/* asyncronous record found */
		char *record = NULL;
		if ( (record = strchr(line, ',')) )
		{
			*record = '\0';
			record++;
		}
		else
			record = line + strlen(line);
		
		if (!strcmp(line, "*running"))
			dbg_cbs->set_run();
		else if (!strcmp(line, "*stopped"))
		{
			/* removing read callback (will pulling all output left manually) */
			g_source_remove(gdb_id_out);

			/* looking for a reason to stop */
			char *next = NULL;
			char *reason = strstr(record, "reason=\"");
			if (reason)
			{
				reason += strlen("reason=\"");
				next = strstr(reason, "\"") + 1;
				*(next - 1) = '\0';
				if (!strcmp(reason, "breakpoint-hit"))
					stop_reason = SR_BREAKPOINT_HIT;
				else if (!strcmp(reason, "end-stepping-range"))
					stop_reason = SR_END_STEPPING_RANGE;
				else if (!strcmp(reason, "signal-received"))
					stop_reason = SR_SIGNAL_RECIEVED;
				else if (!strcmp(reason, "exited-normally"))
					stop_reason = SR_EXITED_NORMALLY;
				else if (!strcmp(reason, "exited-signalled"))
					stop_reason = SR_EXITED_SIGNALLED;
			}
			else
			{
				/* somehow, sometimes there can be no stop reason */
				stop_reason = SR_END_STEPPING_RANGE;
			}
			
			if (SR_BREAKPOINT_HIT == stop_reason || SR_END_STEPPING_RANGE == stop_reason || SR_SIGNAL_RECIEVED == stop_reason)
			{
				gchar *thread_id = strstr(reason + strlen(reason) + 1,"thread-id=\"") + strlen("thread-id=\"");
				*(strchr(thread_id, '\"')) = '\0'; 
				
				if (SR_BREAKPOINT_HIT == stop_reason || SR_END_STEPPING_RANGE == stop_reason)
				{
					/* update autos */
					update_autos();
			
					/* update watches */
					update_watches();
			
					/* update files */
					if (file_refresh_needed)
					{
						update_files();
						file_refresh_needed = FALSE;
					}

					dbg_cbs->set_stopped(atoi(thread_id));
				}
				else
				{
					if (!requested_interrupt)
						dbg_cbs->report_error(_("Program received a signal"));
					else
						requested_interrupt = FALSE;
						
					dbg_cbs->set_stopped(atoi(thread_id));
				}
			}
			else if (stop_reason == SR_EXITED_NORMALLY || stop_reason == SR_EXITED_SIGNALLED)
			{
				stop();
			}
		}
	}
	else if (g_str_has_prefix (line, "^error"))
	{
		/* removing read callback (will pulling all output left manually) */
		g_source_remove(gdb_id_out);

		/* set debugger stopped if is running */
		if (DBS_STOPPED != debug_get_state())
		{
			gchar *thread_id = strstr(line + strlen(line) + 1,"thread-id=\"");
			*(strchr(thread_id, '\"')) = '\0'; 

			dbg_cbs->set_stopped(atoi(thread_id));
		}

		/* get message */
		char *msg = strstr(line, "msg=\"") + strlen("msg=\"");
		*strrchr(msg, '\"') = '\0';
		msg = g_strcompress(msg);
		
		/* reading until prompt */
		GList *lines = read_until_prompt();
		GList *iter = lines;
		while(iter)
		{
			gchar *l = (gchar*)iter->data;
			if (strcmp(l, GDB_PROMPT))
				colorize_message(l);
			g_free(l);
			
			iter = iter->next;
		}
		g_list_free (lines);

		/* send error message */
		dbg_cbs->report_error(msg);

		g_free(msg);
	}

	g_free(line);

	return TRUE;
}