After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 645081 - Provide a way to specify the gdb path
Provide a way to specify the gdb path
Status: RESOLVED OBSOLETE
Product: anjuta
Classification: Applications
Component: plugins: gdb
unspecified
Other Linux
: Normal normal
: ---
Assigned To: Sébastien Granjoux
Anjuta maintainers
Depends on:
Blocks:
 
 
Reported: 2011-03-17 22:55 UTC by Jon Ringle
Modified: 2020-11-06 20:22 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Set other GDB executable (16.77 KB, patch)
2011-04-10 23:43 UTC, Lucas van Dijk
reviewed Details | Review
Updated version of GDB path patch (15.61 KB, patch)
2011-06-17 09:29 UTC, Lucas van Dijk
reviewed Details | Review

Description Jon Ringle 2011-03-17 22:55:46 UTC
Please provide a way to specify the path to the gdb executable to use so that a cross gdb (like arm-linux-gdb) can be used for remote debugging of embedded targets.
Comment 1 Lucas van Dijk 2011-04-10 23:43:46 UTC
Created attachment 185673 [details] [review]
Set other GDB executable

This patch allows the user to set a custom GDB executable path. It's stored in the project session, so it's configurable per project, and will be remembered the next time you open the project. You can change it in the main preferences window.
Comment 2 Sébastien Granjoux 2011-04-16 08:40:44 UTC
Review of attachment 185673 [details] [review]:

Thanks that's working fine.

I have just some comments on a few details.

1.
+	/* Free previous path */
+	g_free(*(dlg->path));
+	*(dlg->path) = NULL;
+
+	/* Set the new path */
+	gchar *new_path = g_new0(gchar, gtk_entry_get_text_length(dlg->executable_entry)+1);
+	g_stpcpy(new_path, gtk_entry_get_text(dlg->executable_entry));
+	*(dlg->path) = new_path;	
+

* I think it's not needed to set *(dlg->path) to NULL after free, because you overwrite this value just a few lines later.
* Why do you use g_stpcpy instead of strcpy? g_stpcpy returns a pointer on the end of the string but you don't use it.
* I think it's easier to just do
	g_free(*(dlg->path));
        *(dlg->path) = g_strdup (gtk_entry_get_text(dlg->executable_entry));

2.
+	GString *path = g_string_new(NULL);
+	gchar *session_path = anjuta_session_get_string(session, GDB_SECTION, GDB_EXECUTABLE_KEY);
+
+	if(session_path == NULL || *session_path == '\0')
+	{
+		g_string_append(path, DEFAULT_GDB_EXECUTABLE);
+	}
+	else
+	{
+		g_string_append(path, session_path);
+		g_free(session_path);
+	}
+
+	return g_string_free(path, FALSE);

* Why do you use a GString object and g_string_append while you just need to initialize a string?
I think you can write
	gchar *path = anjuta_session_get_string(session, GDB_SECTION, GDB_EXECUTABLE_KEY);

	if ((path == NULL) || (path == '\0'))
	{
                g_free (path);  /* in case path == "" */
		path = g_strdup (DEFAULT_GDB_EXECUTABLE);
	}

        return path;
Comment 3 Lucas van Dijk 2011-04-25 13:33:59 UTC
Thanks for the comments Sebastien!

I somehow missed the g_strdup function :) I was looking at the documentation, to search for a str copy function, and by only looking at the function names at
http://developer.gnome.org/glib/unstable/glib-String-Utility-Functions.html

My first guess was that g_stpcpy was the best candidate (I thought g_strdup was something for uppercase :')), the g_strdup function makes it a lot easier indeed.

I also used to a GString object to make sure it was allocated at runtime, so I could be freed. I couldn't just return DEFAULT_GDB_EXECUTABLE, but also here the g_strdup makes live easier.

I'll try to submit a new patch in the next week.
Comment 4 Lucas van Dijk 2011-06-17 09:29:56 UTC
Created attachment 190098 [details] [review]
Updated version of GDB path patch

This is an updated version of the previous patch, including improvements mentioned by Sebastien.
Comment 5 Sébastien Granjoux 2011-06-17 19:40:18 UTC
Review of attachment 190098 [details] [review]:

It is fine but I have two cosmetic additional requests:
- Could you add a Browse button on the right of the preference dialog allowing to select an executable or use a combo box button like the cvs or CLang plugin? unless you need to add some arguments, I don't know if this can be useful.
- Could you take care of the "Gdb Executable" title has more space with the tree view above and keep the entry (or the combo box) at the top even when the dialog is resize? currently the entry is put in the middle of the available space.
Comment 6 André Klapper 2020-11-06 20:22:29 UTC
bugzilla.gnome.org is being replaced by gitlab.gnome.org. We are closing all old bug reports in Bugzilla which have not seen updates for many years.

If you can still reproduce this issue in a currently supported version of GNOME (currently that would be 3.38), then please feel free to report it at https://gitlab.gnome.org/GNOME/anjuta/-/issues/

Thank you for reporting this issue and we are sorry it could not be fixed.