Exemplo n.º 1
0
static void receive_output_cb(GString *string, GIOCondition condition,
	G_GNUC_UNUSED gpointer gdata)
{
	if (condition & (G_IO_IN | G_IO_PRI))
	{
		char *term = string->str + string->len - 1;
		const char *error = NULL;

		switch (*term)
		{
			case '\n' : if (string->len >= 2 && term[-1] == '\r') term--;  /* falldown */
			case '\r' : *term = '\0'; break;
			case '\0' : error = "binary zero encountered"; break;
			default : error = "line too long or incomplete";
		}

		if (leading_receive)
			debug_parse(string->str, error);

		leading_receive = !error;
	}

	if (!commands->len)
		views_update(debug_state());

	update_state(debug_state());
}
Exemplo n.º 2
0
void program_context_changed(void)
{
	const gchar *name = build_get_execute(GEANY_BC_COMMAND);

	if (name && debug_state() == DS_INACTIVE)
		on_recent_menu_item_activate(NULL, name);
}
Exemplo n.º 3
0
void view_command_line(const gchar *text, const gchar *title, const gchar *seek,
	gboolean seek_after)
{
	GtkTextIter start, end;

	gtk_window_set_title(GTK_WINDOW(command_dialog), title ? title : _("GDB Command"));
	gtk_widget_grab_focus(command_view);

	if (text)
	{
		const gchar *pos = seek ? strstr(text, seek) : NULL;
		GtkTextIter iter;

		gtk_text_buffer_set_text(command_text, text, -1);
		gtk_text_buffer_get_iter_at_offset(command_text, &iter,
			g_utf8_strlen(text, pos ? pos + strlen(seek) * seek_after - text : -1));
		gtk_text_buffer_place_cursor(command_text, &iter);
	}

	on_command_text_changed(command_text, NULL);
	command_line_update_state(debug_state());
	gtk_text_buffer_get_start_iter(command_text, &start);
	gtk_text_buffer_get_end_iter(command_text, &end);
	gtk_text_buffer_select_range(command_text, &start, &end);
	gtk_combo_box_set_active_iter(command_history, NULL);
	gtk_dialog_run(GTK_DIALOG(command_dialog));
}
Exemplo n.º 4
0
static void test()
{
    state_t *nfa;
    unsigned char *rpn = NULL;
    unsigned char *test_string = "aaaaaaaa";
    unsigned char *trex = "a";
    int retcode = retorpn(trex, strlen(trex) + 1, &rpn);
    retcode = retorpn(trex, strlen(trex) + 1, &rpn);
    if (retcode >= 0)
        nfa = evalrpn(rpn);
    else
        printf("Invalid search string\n");
    if (nfa == NULL)
        printf("Bad rpn\n");
    debug_state(nfa);
    printf("trex = %s\n", trex);
    printf("rpn = %s\n", rpn);
    printf("Test string = %s\n", test_string);

    printf("Partial Matching:\n");
    match(nfa, test_string, PARTIAL);
    printf("Full Line Matching:\n");
    match(nfa, test_string, ALL);

    exit(0);
}
Exemplo n.º 5
0
static void on_document_filetype_set(G_GNUC_UNUSED GObject *obj, GeanyDocument *doc,
	G_GNUC_UNUSED GeanyFiletype *filetype_old, G_GNUC_UNUSED gpointer gdata)
{
	DebugState state = debug_state();
	utils_lock_unlock(doc, state != DS_INACTIVE && utils_source_document(doc));
	toolbar_update_state(state);
}
Exemplo n.º 6
0
static gboolean tooltip_launch(gpointer gdata)
{
	GeanyDocument *doc = document_get_current();

	if (doc && utils_source_document(doc) && doc->editor == gdata &&
		(debug_state() & DS_SENDABLE))
	{
		ScintillaObject *sci = doc->editor->sci;
		gchar *expr = sci_get_selection_mode(sci) == SC_SEL_STREAM &&
			peek_pos >= sci_get_selection_start(sci) &&
			peek_pos < sci_get_selection_end(sci) ?
			editor_get_default_selection(doc->editor, FALSE, NULL) :
			editor_get_word_at_pos(doc->editor, peek_pos, NULL);

		if ((expr = utils_verify_selection(expr)) != NULL)
		{
			g_free(input);
			input = debug_send_evaluate('3', scid_gen, expr);
			g_free(expr);
		}
		else
			tooltip_set(NULL);
	}
	else
		tooltip_set(NULL);

	query_id = 0;
	return FALSE;
}
Exemplo n.º 7
0
static void menu_evaluate_modify(const gchar *expr, const char *value, const gchar *title,
	gint hb_mode, gint mr_mode, const char *prefix)
{
	gchar *display = parse_get_display_from_7bit(value, hb_mode, mr_mode);
	gchar *text = g_strdup_printf("%s = %s", expr, display ? display : "");
	GtkTextIter iter;

	g_free(display);
	gtk_window_set_title(GTK_WINDOW(modify_dialog), title);
	gtk_widget_grab_focus(modify_value);
	gtk_text_buffer_set_text(modify_text, text, -1);
	g_free(text);
	gtk_text_buffer_get_iter_at_offset(modify_text, &iter, g_utf8_strlen(expr, -1) + 3);
	gtk_text_buffer_place_cursor(modify_text, &iter);
	modify_dialog_update_state(debug_state());

	if (gtk_dialog_run(GTK_DIALOG(modify_dialog)) == GTK_RESPONSE_ACCEPT)
	{
		text = utils_text_buffer_get_text(modify_text, -1);
		utils_strchrepl(text, '\n', ' ');

		if (validate_column(text, TRUE))
		{
			char *locale = utils_get_locale_from_display(text, hb_mode);
			debug_send_format(F, "%s-gdb-set var %s", prefix ? prefix : "", locale);
			g_free(locale);
		}
		g_free(text);
	}
}
Exemplo n.º 8
0
static void on_break_enabled_toggled(G_GNUC_UNUSED GtkCellRendererToggle *renderer,
	gchar *path_str, G_GNUC_UNUSED gpointer gdata)
{
	GtkTreeIter iter;
	DebugState state = debug_state();
	const char *id;
	gint scid;
	gboolean enabled;

	scp_tree_store_get_iter_from_string(store, &iter, path_str);
	scp_tree_store_get(store, &iter, BREAK_ID, &id, BREAK_SCID, &scid, BREAK_ENABLED,
		&enabled, -1);
	enabled ^= TRUE;

	if (state == DS_INACTIVE || !id)
	{
		break_enable(&iter, enabled);
	}
	else if (state & DS_SENDABLE)
	{
		debug_send_format(N, "02%d%d-break-%sable %s", enabled, scid, enabled ? "en" :
			"dis", id);
	}
	else
		plugin_beep();
}
Exemplo n.º 9
0
static void on_break_column_edited(G_GNUC_UNUSED GtkCellRendererText *renderer,
	gchar *path_str, gchar *new_text, gpointer gdata)
{
	gint index = GPOINTER_TO_INT(gdata) - 1;
	const gchar *set_text = validate_column(new_text, index > 0);
	GtkTreeIter iter;
	const char *id;
	char type;

	scp_tree_store_get_iter_from_string(store, &iter, path_str);
	scp_tree_store_get(store, &iter, BREAK_ID, &id, BREAK_TYPE, &type, -1);

	if (id && (debug_state() & DS_SENDABLE))
	{
		char *locale = utils_get_locale_from_display(new_text, HB_DEFAULT);

		debug_send_format(F, "022%s-break-%s %s %s", id, break_command(index, type), id,
			locale ? locale : index ? "" : "0");
		g_free(locale);
	}
	else if (!id)
		scp_tree_store_set(store, &iter, index + BREAK_IGNORE, set_text, -1);
	else
		plugin_beep();
}
Exemplo n.º 10
0
static void on_memory_bytes_edited(G_GNUC_UNUSED GtkCellRendererText *renderer, gchar *path_str,
	gchar *new_text, G_GNUC_UNUSED gpointer gdata)
{
	if (*new_text && (debug_state() & DS_VARIABLE))
	{
		GtkTreeIter iter;
		const char *addr, *bytes;
		guint i;

		scp_tree_store_get_iter_from_string(store, &iter, path_str);
		scp_tree_store_get(store, &iter, MEMORY_ADDR, &addr, MEMORY_BYTES, &bytes, -1);

		for (i = 0; bytes[i]; i++)
			if (!(isxdigit(bytes[i]) ? isxdigit(new_text[i]) : new_text[i] == ' '))
				break;

		if (bytes[i] || new_text[i])
			dc_error("memory: invalid format");
		else
		{
			utils_strchrepl(new_text, ' ', '\0');
			debug_send_format(T, "07-data-write-memory-bytes 0x%s%s", addr, new_text);
		}
	}
	else
		plugin_blink();
}
Exemplo n.º 11
0
static void on_build_start(G_GNUC_UNUSED GObject *obj, G_GNUC_UNUSED gpointer gdata)
{
	if (debug_state() != DS_INACTIVE && dialogs_show_question(_("Build action activated. "
		"Terminate debugging?")))
	{
		on_debug_terminate(NULL);
	}
}
Exemplo n.º 12
0
static void on_document_open(G_GNUC_UNUSED GObject *obj, GeanyDocument *doc,
	G_GNUC_UNUSED gpointer gdata)
{
	prefs_apply(doc);
	breaks_mark(doc);

	if (debug_state() != DS_INACTIVE)
		threads_mark(doc);
}
Exemplo n.º 13
0
void menu_item_execute(const MenuInfo *menu_info, const MenuItem *menu_item, gboolean beep)
{
	guint state = debug_state() | menu_info->extra_state();

	if (!menu_item->state || menu_item_matches_state(menu_item, state))
		menu_item->callback(menu_item);
	else if (beep)
		plugin_beep();
}
Exemplo n.º 14
0
void on_program_setup(G_GNUC_UNUSED const MenuItem *menu_item)
{
	gtk_text_buffer_set_text(environment, program_environment, -1);
	stash_foreach((GFunc) stash_group_display, NULL);
	gtk_button_set_label(long_mr_format, LONG_MR_FORMAT[option_long_mr_format]);
	dialog_long_mr_format = option_long_mr_format;
	gtk_widget_set_sensitive(import_button, last_state_inactive && build_check_execute());
	on_program_name_entry_changed(NULL, NULL);
	gtk_toggle_button_set_active(delete_all_items, FALSE);
	if (debug_state() == DS_INACTIVE)
		gtk_widget_grab_focus(GTK_WIDGET(program_exec_entry));
	gtk_dialog_run(GTK_DIALOG(program_dialog));
}
Exemplo n.º 15
0
static gboolean on_console_key_press(G_GNUC_UNUSED GtkWidget *widget,
	GdkEventKey *event, G_GNUC_UNUSED gpointer gdata)
{
	gboolean insert = event->keyval == GDK_Insert || event->keyval == GDK_KP_Insert;

	if ((insert || (event->keyval >= 0x21 && event->keyval <= 0x7F &&
		event->state <= GDK_SHIFT_MASK)) && (debug_state() & DS_ACTIVE))
	{
		char command[2] = { event->keyval, '\0' };
		view_command_line(insert ? NULL : command, NULL, NULL, TRUE);
		return TRUE;
	}

	return FALSE;
}
Exemplo n.º 16
0
static gboolean on_editor_notify(G_GNUC_UNUSED GObject *obj, GeanyEditor *editor,
	SCNotification *nt, G_GNUC_UNUSED gpointer gdata)
{
	GeanyDocument *doc = editor->document;

	if (nt->nmhdr.code == SCN_MODIFIED && nt->linesAdded && utils_source_document(doc))
	{
		gboolean active = debug_state() != DS_INACTIVE;
		ScintillaObject *sci = editor->sci;
		gint start = sci_get_line_from_position(sci, nt->position);

		if (active)
			threads_delta(sci, doc->real_path, start, nt->linesAdded);

		breaks_delta(sci, doc->real_path, start, nt->linesAdded, active);
	}

	return FALSE;
}
Exemplo n.º 17
0
void on_debug_terminate(const MenuItem *menu_item)
{
	switch (debug_state())
	{
		case DS_BUSY :
		{
			GError *gerror = NULL;

			gdb_state = KILLING;

			if (!spawn_kill_process(gdb_pid, &gerror))
			{
				show_error(_("%s."), gerror->message);
				g_error_free(gerror);
			}

			break;
		}
		case DS_READY :
		case DS_DEBUG :
		{
			if (menu_item && !debug_auto_exit)
			{
				debug_send_command(N, "kill");
				break;
			}
			/* falldown */
		}
		default :
		{
			debug_send_command(N, "-gdb-exit");
			gdb_state = KILLING;
			break;
		}
	}
}
Exemplo n.º 18
0
void debug_done(char *pcFileFunc, int iLine)
{
  if ( cInit == 0 )
    return;
  if ( cInit > 0 )
    cInit--;

  if ( cInit == 0 )
  {
    PBUFPSZ		pNextBufPSZ;
    PDBGCOUNTER		pNext, pScan = pCounters;

    while( lsBufPSZ.pList != NULL )
    {
      pNextBufPSZ = lsBufPSZ.pList->pNext;
      free( lsBufPSZ.pList );
      lsBufPSZ.pList = pNextBufPSZ;
    }

    debug_state();
    while( pScan != NULL )
    {
      pNext = pScan->pNext;
      free( pScan->pcName );
      free( pScan );
      pScan = pNext;
    }

    fclose( fdDebug );
    fdDebug = NULL;
    DosCloseMutexSem( hMtx );
  }
  else
    debug_write( "debugDone(): %s line %d, %d calls left\n",
                 pcFileFunc, iLine, cInit );
}
Exemplo n.º 19
0
static void on_menu_show(G_GNUC_UNUSED GtkWidget *widget, MenuInfo *menu_info)
{
	active_menu = menu_info;
	update_active_menu(debug_state());
}
Exemplo n.º 20
0
void on_view_changed(G_GNUC_UNUSED GtkNotebook *notebook, G_GNUC_UNUSED gpointer page,
	gint page_num, G_GNUC_UNUSED gpointer gdata)
{
	view_current = page_num;
	view_update(view_current, debug_state());
}
Exemplo n.º 21
0
void view_inspect_update(void)
{
	view_update(VIEW_INSPECT, debug_state());
}
Exemplo n.º 22
0
static void on_geany_sidebar_switch_page(G_GNUC_UNUSED GtkNotebook *notebook,
	G_GNUC_UNUSED gpointer page, gint page_num, G_GNUC_UNUSED gpointer gdata)
{
	views_sidebar_update(page_num, debug_state());
}
Exemplo n.º 23
0
static void on_document_filetype_set(G_GNUC_UNUSED GObject *obj, GeanyDocument *doc,
	G_GNUC_UNUSED GeanyFiletype *filetype_old, G_GNUC_UNUSED gpointer gdata)
{
	utils_lock_unlock(doc, debug_state() != DS_INACTIVE && utils_source_document(doc));
}
Exemplo n.º 24
0
static void on_document_activate(G_GNUC_UNUSED GObject *obj, G_GNUC_UNUSED GeanyDocument *doc,
	G_GNUC_UNUSED gpointer user_data)
{
	toolbar_update_state(debug_state());
}