From: Andrew Burgess <aburgess@redhat.com>
To: Enze Li <lienze2010@hotmail.com>
Cc: Tom Tromey <tom@tromey.com>,
Andrew Burgess <andrew.burgess@embecosm.com>,
gdb-patches@sourceware.org
Subject: Re: [PATCH 1/4] gdb/python: make some global variables static
Date: Thu, 25 Nov 2021 18:11:45 +0000 [thread overview]
Message-ID: <20211125181145.GU2662946@redhat.com> (raw)
In-Reply-To: <MEAP282MB02930034F1EEA5B8812300F3DD629@MEAP282MB0293.AUSP282.PROD.OUTLOOK.COM>
* Enze Li <lienze2010@hotmail.com> [2021-11-25 23:02:49 +0800]:
> Hi Andrew,
>
> After using this patch, I encountered the following error when
> compiling.
>
> -----------------------------------------------------------------------
> CXXLD gdb
> /usr/lib64/gcc/x86_64-suse-linux/11/../../../../x86_64-suse-
> linux/bin/ld: extension.o: in function `ext_lang_before_prompt(char
> const*)':
> /home/lee/dev/binutils-gdb/gdb/extension.c:914: undefined reference to
> `extension_language_python'
> /usr/lib64/gcc/x86_64-suse-linux/11/../../../../x86_64-suse-
> linux/bin/ld: extension.o: in function
> `get_ext_lang_defn(extension_language)':
> /home/lee/dev/binutils-gdb/gdb/extension.c:107: undefined reference to
> `extension_language_python'
> /usr/lib64/gcc/x86_64-suse-linux/11/../../../../x86_64-suse-
> linux/bin/ld: /home/lee/dev/binutils-gdb/gdb/extension.c:105: undefined
> reference to `extension_language_python'
> /usr/lib64/gcc/x86_64-suse-linux/11/../../../../x86_64-suse-
> linux/bin/ld: extension.o: in function `get_ext_lang_of_file(char
> const*)':
> /home/lee/dev/binutils-gdb/gdb/extension.c:132: undefined reference to
> `extension_language_python'
> /usr/lib64/gcc/x86_64-suse-linux/11/../../../../x86_64-suse-
> linux/bin/ld: extension.o: in function `ext_lang_initialization()':
> /home/lee/dev/binutils-gdb/gdb/extension.c:331: undefined reference to
> `extension_language_python'
> /usr/lib64/gcc/x86_64-suse-linux/11/../../../../x86_64-suse-
> linux/bin/ld: extension.o:/home/lee/dev/binutils-
> gdb/gdb/extension.c:359: more undefined references to
> `extension_language_python' follow
> collect2: error: ld returned 1 exit status
> make[2]: *** [Makefile:1904: gdb] Error 1
> make[2]: Leaving directory '/home/lee/dev/binutils-gdb/gdb'
> make[1]: *** [Makefile:13458: all-gdb] Error 2
> make[1]: Leaving directory '/home/lee/dev/binutils-gdb'
> make: *** [Makefile:1000: all] Error 2
> ----------------------------------------------------------------------
>
> On Thu, 2021-11-25 at 10:12 +0000, Andrew Burgess via Gdb-patches
> wrote:
> > * Tom Tromey <tom@tromey.com> [2021-10-27 14:20:01 -0600]:
> >
> > > > > > > > "Andrew" == Andrew Burgess <andrew.burgess@embecosm.com>
> > > > > > > > writes:
> > >
> > > Andrew> Make a couple of global variables static in python/python.c.
> > > To do
> > > Andrew> this I had to move the definition of
> > > extension_language_python to
> > > Andrew> later in the file.
> > >
> > > Andrew> There should be no user visible changes after this commit.
> > >
> > > This looks good to me.
> >
> > Thanks, I've pushed this patch.
> >
> > Andrew
> >
>
> Here is my system environment,
> OpenSuse Tumbleweed (Updated just now)
> - gcc 11.2.1 20210816
> [revision 056e324ce46a7924b5cf10f61010cf9dd2ca10e9]
>
> I executed the following command to compile,
> # ./configure --prefix=/path/to/gdb-src/build/
> # make
>
> I guess the problem may be in the macro definition. I tested with the
> following patch and the problem disappeared. Hope this may help to
> solve this problem.
>
> -----------------------------------------------------------------------
> diff --git a/gdb/python/python.c b/gdb/python/python.c
> index d8a6a5978de..bfb691f0eac 100644
> --- a/gdb/python/python.c
> +++ b/gdb/python/python.c
> @@ -164,6 +164,8 @@ static const struct extension_language_ops
> python_extension_ops =
> gdbpy_colorize,
> };
>
> +#endif /* HAVE_PYTHON */
> +
> /* The main struct describing GDB's interface to the Python
> extension language. */
> const struct extension_language_defn extension_language_python =
> @@ -186,6 +188,8 @@ const struct extension_language_defn
> extension_language_python =
> #endif
> };
>
> +#ifdef HAVE_PYTHON
> +
> /* Architecture and language to be used in callbacks from
> the Python interpreter. */
> struct gdbarch *python_gdbarch;
> -----------------------------------------------------------------------
Enze,
Thanks for reporting this, and thanks for looking into the problem and
providing a fix.
I pushed the patch below to resolve this issue.
Thanks,
Andrew
---
commit 9e99facd6cae1a94923166bd02f716d96395c19f
Author: Enze Li <lienze2010@hotmail.com>
Date: Thu Nov 25 18:05:46 2021 +0000
gdb: ensure extension_language_python is always defined
In this commit:
commit c6a6aad52d9e839d6a84ac31cabe2b7e1a2a31a0
Date: Mon Oct 25 17:25:45 2021 +0100
gdb/python: make some global variables static
building without Python was broken. The extension_language_python
global was moved from being always defined, to only being defined when
the HAVE_PYTHON macro was defined. As a consequence, building without
Python support would result in errors like:
/usr/bin/ld: extension.o:(.rodata+0x120): undefined reference to `extension_language_python'
This commit fixes the problem by moving the definition of
extension_language_python outside of the HAVE_PYTHON macro protection.
diff --git a/gdb/python/python.c b/gdb/python/python.c
index d8a6a5978de..bfb691f0eac 100644
--- a/gdb/python/python.c
+++ b/gdb/python/python.c
@@ -164,6 +164,8 @@ static const struct extension_language_ops python_extension_ops =
gdbpy_colorize,
};
+#endif /* HAVE_PYTHON */
+
/* The main struct describing GDB's interface to the Python
extension language. */
const struct extension_language_defn extension_language_python =
@@ -186,6 +188,8 @@ const struct extension_language_defn extension_language_python =
#endif
};
+#ifdef HAVE_PYTHON
+
/* Architecture and language to be used in callbacks from
the Python interpreter. */
struct gdbarch *python_gdbarch;
next prev parent reply other threads:[~2021-11-25 18:11 UTC|newest]
Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-10-26 9:37 [PATCH 0/4] Disassembler Output Styling Andrew Burgess
2021-10-26 9:37 ` [PATCH 1/4] gdb/python: make some global variables static Andrew Burgess
2021-10-27 20:20 ` Tom Tromey
2021-11-25 10:12 ` Andrew Burgess
2021-11-25 15:02 ` Enze Li
2021-11-25 18:11 ` Andrew Burgess [this message]
2021-10-26 9:37 ` [PATCH 2/4] gdb: rename source_styling_changed observer Andrew Burgess
2021-10-27 20:22 ` Tom Tromey
2021-11-25 10:17 ` Andrew Burgess
2021-10-26 9:37 ` [PATCH 3/4] gdb: use python to colorize disassembler output Andrew Burgess
2021-10-27 20:38 ` Tom Tromey
2021-10-28 16:28 ` Andrew Burgess
2021-11-22 14:44 ` Andrew Burgess
2021-10-26 9:37 ` [PATCH 4/4] gdb/python: move styling support to gdb.styling Andrew Burgess
2021-10-27 20:39 ` Tom Tromey
2021-11-25 10:36 ` [PATCHv2 0/2] Disassembler Output Styling Andrew Burgess
2021-11-25 10:36 ` [PATCHv2 1/2] gdb: use python to colorize disassembler output Andrew Burgess
2021-11-25 11:04 ` Eli Zaretskii
2021-11-25 10:36 ` [PATCHv2 2/2] gdb/python: move styling support to gdb.styling Andrew Burgess
2021-12-06 14:32 ` Ping: [PATCHv2 0/2] Disassembler Output Styling Andrew Burgess
2021-12-13 14:12 ` [PATCHv3 " Andrew Burgess
2021-12-13 14:12 ` [PATCHv3 1/2] gdb: use python to colorize disassembler output Andrew Burgess
2021-12-13 14:12 ` [PATCHv3 2/2] gdb/python: move styling support to gdb.styling Andrew Burgess
2022-01-11 14:30 ` [PATCHv4 0/2] Disassembler Output Styling Andrew Burgess
2022-01-11 14:31 ` [PATCHv4 1/2] gdb: use python to colorize disassembler output Andrew Burgess
2022-02-10 21:13 ` Tom Tromey
2022-02-11 14:27 ` Andrew Burgess
2022-02-13 18:02 ` Tom Tromey
2022-02-14 11:22 ` Andrew Burgess
2022-01-11 14:31 ` [PATCHv4 2/2] gdb/python: move styling support to gdb.styling Andrew Burgess
2022-02-10 21:15 ` Tom Tromey
2022-02-10 21:16 ` Tom Tromey
2022-01-21 16:26 ` [PATCHv5 0/2] Disassembler Output Styling Andrew Burgess
2022-01-21 16:26 ` [PATCHv5 1/2] gdb: use python to colorize disassembler output Andrew Burgess
2022-01-21 16:26 ` [PATCHv5 2/2] gdb/python: move styling support to gdb.styling Andrew Burgess
2022-02-03 20:32 ` [PATCHv5 0/2] Disassembler Output Styling Andrew Burgess
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=20211125181145.GU2662946@redhat.com \
--to=aburgess@redhat.com \
--cc=andrew.burgess@embecosm.com \
--cc=gdb-patches@sourceware.org \
--cc=lienze2010@hotmail.com \
--cc=tom@tromey.com \
/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: link
Be 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).