GNOME Bugzilla – Bug 645081
Provide a way to specify the gdb path
Last modified: 2020-11-06 20:22:29 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.
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.
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;
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.
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.
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.
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.