public inbox for gdb-cvs@sourceware.org help / color / mirror / Atom feed
From: Tom Tromey <tromey@sourceware.org> To: gdb-cvs@sourceware.org Subject: [binutils-gdb] Constify solib_name_from_address Date: Tue, 7 Jun 2022 13:54:53 +0000 (GMT) [thread overview] Message-ID: <20220607135453.3DDA43850413@sourceware.org> (raw) https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=6d08aed3c98dd073d79365bc12a675fe0930aee7 commit 6d08aed3c98dd073d79365bc12a675fe0930aee7 Author: Tom Tromey <tromey@adacore.com> Date: Mon Jun 6 09:56:30 2022 -0600 Constify solib_name_from_address I noticed that solib_name_from_address returned a non-const string, but it's more appropriate to return const. This patch implements this. Tested by rebuilding. Diff: --- gdb/python/py-progspace.c | 3 +-- gdb/solib.c | 2 +- gdb/solib.h | 2 +- gdb/stack.c | 5 +++-- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/gdb/python/py-progspace.c b/gdb/python/py-progspace.c index 5657ef7756c..a9abfb4c777 100644 --- a/gdb/python/py-progspace.c +++ b/gdb/python/py-progspace.c @@ -351,7 +351,6 @@ pspy_get_objfiles (PyObject *self_, PyObject *args) static PyObject * pspy_solib_name (PyObject *o, PyObject *args) { - char *soname; gdb_py_ulongest pc; pspace_object *self = (pspace_object *) o; @@ -360,7 +359,7 @@ pspy_solib_name (PyObject *o, PyObject *args) if (!PyArg_ParseTuple (args, GDB_PY_LLU_ARG, &pc)) return NULL; - soname = solib_name_from_address (self->pspace, pc); + const char *soname = solib_name_from_address (self->pspace, pc); if (soname == nullptr) Py_RETURN_NONE; return host_string_to_python_string (soname).release (); diff --git a/gdb/solib.c b/gdb/solib.c index 0fbf5bc988d..7d4734b0012 100644 --- a/gdb/solib.c +++ b/gdb/solib.c @@ -1225,7 +1225,7 @@ solib_contains_address_p (const struct so_list *const solib, breakpoints which are in shared libraries that are not currently mapped in. */ -char * +const char * solib_name_from_address (struct program_space *pspace, CORE_ADDR address) { struct so_list *so = NULL; diff --git a/gdb/solib.h b/gdb/solib.h index f9b4d3566d7..251028472c0 100644 --- a/gdb/solib.h +++ b/gdb/solib.h @@ -48,7 +48,7 @@ extern void solib_create_inferior_hook (int from_tty); /* If ADDR lies in a shared library, return its name. */ -extern char *solib_name_from_address (struct program_space *, CORE_ADDR); +extern const char *solib_name_from_address (struct program_space *, CORE_ADDR); /* Return true if ADDR lies within SOLIB. */ diff --git a/gdb/stack.c b/gdb/stack.c index 71d85985d18..80801ccdb01 100644 --- a/gdb/stack.c +++ b/gdb/stack.c @@ -1427,8 +1427,9 @@ print_frame (const frame_print_options &fp_opts, if (print_what != SHORT_LOCATION && pc_p && (funname == NULL || sal.symtab == NULL)) { - char *lib = solib_name_from_address (get_frame_program_space (frame), - get_frame_pc (frame)); + const char *lib + = solib_name_from_address (get_frame_program_space (frame), + get_frame_pc (frame)); if (lib) {
reply other threads:[~2022-06-07 13:54 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20220607135453.3DDA43850413@sourceware.org \ --to=tromey@sourceware.org \ --cc=gdb-cvs@sourceware.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).