From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id xtZsFvEjnmJkpAoAWB0awg (envelope-from ) for ; Mon, 06 Jun 2022 11:57:37 -0400 Received: by simark.ca (Postfix, from userid 112) id 4D1901E221; Mon, 6 Jun 2022 11:57:37 -0400 (EDT) Authentication-Results: simark.ca; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.a=rsa-sha256 header.s=default header.b=FXzlAULJ; dkim-atps=neutral X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RDNS_DYNAMIC,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 Received: from sourceware.org (ip-8-43-85-97.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id BE0EE1E143 for ; Mon, 6 Jun 2022 11:57:36 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 49C9738344F3 for ; Mon, 6 Jun 2022 15:57:36 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 49C9738344F3 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1654531056; bh=1CCjIvB2tSVwDLhwIDaBVk90OJyyjj3HAJ+9KGIy/tI=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=FXzlAULJ9+QfsajYFT1g948h3HT+WpJn14+k9LT7iUP8PJQW71BX+8lLkSHfW5D9s x4HxKo5asGNjqIqEv89Js6IKAgvd5PU4ndP+0KXRSDzVLNxKfKBnQkopuQyNWaG0yg rFIx1HanGuSXWxlOcZxRFi36Pc1KlNP0jKW1o2nI= Received: from mail-io1-xd29.google.com (mail-io1-xd29.google.com [IPv6:2607:f8b0:4864:20::d29]) by sourceware.org (Postfix) with ESMTPS id 7287A3834E70 for ; Mon, 6 Jun 2022 15:57:16 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 7287A3834E70 Received: by mail-io1-xd29.google.com with SMTP id z197so8479502iof.1 for ; Mon, 06 Jun 2022 08:57:16 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=1CCjIvB2tSVwDLhwIDaBVk90OJyyjj3HAJ+9KGIy/tI=; b=Pm4jK7B4caYmolKKGuo1C37BaiSxxDVhtDUEVXZ1edV/opPy5QedH/dDMB+pdofk3G yqxx1VqwTQhDeZdqHlHqXI9zGp1sXXpmYAFJHRts4guD4D5XBMIEXnnMbANXy/BGH5s5 xC2wM6m1CiRRhx/N8drnfvoTEGsnSSuzec2lt3QbuBJhitnlJ2fTAh8DKNe8Eg0gPR+a eEGQBPjalcJEpOrz5aifZG+aQGPFYnS7XcRzdJMBgbGiRq+4lGZJjRBAq2ssP863F3VO T8d21QaX5H1+u10fMYS5Yta0mNGiQi9YxdntRXjckxXsjafnMKmtlMnWLfIdXBrYGEMn 50vw== X-Gm-Message-State: AOAM531HHSFH6899QufkRaDwAJxKmkH2vaMMO3RLp5qWGBQszpFjVm2T cyqqHPVRpxps6NWoejIL5xUWT2IcP74WBg== X-Google-Smtp-Source: ABdhPJzRFmjPnZ3xXClyla7JioWTwpPszpJBmo1nW8Sa9mUbFFRtkoR1+Rqx6IJsFp18xP8ZskhV+w== X-Received: by 2002:a05:6638:470a:b0:331:bd53:87a2 with SMTP id cs10-20020a056638470a00b00331bd5387a2mr1800548jab.204.1654531035653; Mon, 06 Jun 2022 08:57:15 -0700 (PDT) Received: from murgatroyd.Home (71-211-171-143.hlrn.qwest.net. [71.211.171.143]) by smtp.gmail.com with ESMTPSA id 64-20020a021143000000b0033156d6016asm5503747jaf.91.2022.06.06.08.57.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Jun 2022 08:57:15 -0700 (PDT) To: gdb-patches@sourceware.org Subject: [PATCH] Constify solib_name_from_address Date: Mon, 6 Jun 2022 09:57:12 -0600 Message-Id: <20220606155712.2039476-1-tromey@adacore.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Tom Tromey via Gdb-patches Reply-To: Tom Tromey Cc: Tom Tromey Errors-To: gdb-patches-bounces+public-inbox=simark.ca@sourceware.org Sender: "Gdb-patches" 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. --- 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) { -- 2.34.1