g++ and gdb problem: debug symbols for shared libraries not found
up vote
1
down vote
favorite
I am porting a large set of applications and libraries from Debian 7 to Ubuntu 16.04. This is a GNU autotools project, so libtool is involved. gdb cannot find the symbols for the majority of the shared libraries, even though I am building with options that have always worked for me before. I am wondering if anyone else has encountered this problem, and if so what recommendations they might have.
I am using gdb version Ubuntu 7.11.1-0ubuntu1~16.5) 7.11.1.
I am compiling with -g O0 and other compiler options. These options are consistently employed when building 12 libraries. Exactly one of them emerges from the build process with debugging symbols. We'll designate that one libA. (In the discussion below, is just a substitution for the project path.)
Leaving out many -I directives, the options being used are:
-g -O0 -Wconversion -Woverloaded-virtual -Wall -Werror -Wreturn-type -
Wformat -Wparentheses -Wswitch -Wno-deprecated -Wsign-compare -fno-
strict-aliasing -Wunused -D__STDC_LIMIT_MACROS -MT MyModule.lo -MD -MP
-MF .deps/MyModule.Tpo -fPIC -DPIC -o .libs/MyModule.o
When I look at libA using gdb, file, and other utilities it looks fine.
u16dev01:(18:01:32):file libA.so.0.0.0 ~/dev/product-
<path>lib/liba/.libs
libA.so.0.0.0: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV),
dynamically linked,
BuildID[sha1]=14dc765142914be4c32a07eaa1683b5b2a2f6dae, not stripped
The object files look like this:
u16dev01:(18:01:43):file AModule1.o
<path>/lib/liba/.libs
AModule1.o: ELF 64-bit LSB relocatable, x86-64, version 1 (SYSV), not
stripped
If I open the shared library with gdb, I have symbols and I can list the code. If I open any of its .o files with gdb, I get symbols and can list code.
Of the remaining 11, the file command reports two as being SYSV and the other 9 as being GNU/Linux, for example:
u16dev01:(18:08:34):file libD.so.0.0.0
~/<path>/lib/.libs
libD.so.0.0.0: ELF 64-bit LSB shared object, x86-64,
version 1 (GNU/Linux), dynamically linked,
BuildID[sha1]=059733fbc888c3dce86eae21984ea82cddc5b0e9, not stripped
gdb sees no symbols when I open this library or any of its .o files. The file command also reports GNU/Linux for the .o files. There are no symbols.
There are two libraries which file reports as SYSV. Their .o files are also devoid of debugging information, and so are the libraries.
I renamed the strip program to preclude the possibility of the Makefiles from running strip, even though a careful search of compiler output told me it wasn't. So this is not a case of symbols being stripped after library build.
I tried to build a little test library, using the compiler options of my project. It builds a SYSV library and gdb loads debug symbols just fine.
objdump -g output is sparse in the cases when gdb can't load symbols.
I and a couple of my colleagues have been scratching our heads over this one for a few days now. Why does the build procedure produce viable symbols for only one of the libraries? There's nothing special about that library. Why are 9 of the remaining 11 reported GNU/Linux and 2 reported as SYSV? Why don't those 2 have symbols either?
Any ideas would be very appreciated.
g++ gdb
New contributor
add a comment |
up vote
1
down vote
favorite
I am porting a large set of applications and libraries from Debian 7 to Ubuntu 16.04. This is a GNU autotools project, so libtool is involved. gdb cannot find the symbols for the majority of the shared libraries, even though I am building with options that have always worked for me before. I am wondering if anyone else has encountered this problem, and if so what recommendations they might have.
I am using gdb version Ubuntu 7.11.1-0ubuntu1~16.5) 7.11.1.
I am compiling with -g O0 and other compiler options. These options are consistently employed when building 12 libraries. Exactly one of them emerges from the build process with debugging symbols. We'll designate that one libA. (In the discussion below, is just a substitution for the project path.)
Leaving out many -I directives, the options being used are:
-g -O0 -Wconversion -Woverloaded-virtual -Wall -Werror -Wreturn-type -
Wformat -Wparentheses -Wswitch -Wno-deprecated -Wsign-compare -fno-
strict-aliasing -Wunused -D__STDC_LIMIT_MACROS -MT MyModule.lo -MD -MP
-MF .deps/MyModule.Tpo -fPIC -DPIC -o .libs/MyModule.o
When I look at libA using gdb, file, and other utilities it looks fine.
u16dev01:(18:01:32):file libA.so.0.0.0 ~/dev/product-
<path>lib/liba/.libs
libA.so.0.0.0: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV),
dynamically linked,
BuildID[sha1]=14dc765142914be4c32a07eaa1683b5b2a2f6dae, not stripped
The object files look like this:
u16dev01:(18:01:43):file AModule1.o
<path>/lib/liba/.libs
AModule1.o: ELF 64-bit LSB relocatable, x86-64, version 1 (SYSV), not
stripped
If I open the shared library with gdb, I have symbols and I can list the code. If I open any of its .o files with gdb, I get symbols and can list code.
Of the remaining 11, the file command reports two as being SYSV and the other 9 as being GNU/Linux, for example:
u16dev01:(18:08:34):file libD.so.0.0.0
~/<path>/lib/.libs
libD.so.0.0.0: ELF 64-bit LSB shared object, x86-64,
version 1 (GNU/Linux), dynamically linked,
BuildID[sha1]=059733fbc888c3dce86eae21984ea82cddc5b0e9, not stripped
gdb sees no symbols when I open this library or any of its .o files. The file command also reports GNU/Linux for the .o files. There are no symbols.
There are two libraries which file reports as SYSV. Their .o files are also devoid of debugging information, and so are the libraries.
I renamed the strip program to preclude the possibility of the Makefiles from running strip, even though a careful search of compiler output told me it wasn't. So this is not a case of symbols being stripped after library build.
I tried to build a little test library, using the compiler options of my project. It builds a SYSV library and gdb loads debug symbols just fine.
objdump -g output is sparse in the cases when gdb can't load symbols.
I and a couple of my colleagues have been scratching our heads over this one for a few days now. Why does the build procedure produce viable symbols for only one of the libraries? There's nothing special about that library. Why are 9 of the remaining 11 reported GNU/Linux and 2 reported as SYSV? Why don't those 2 have symbols either?
Any ideas would be very appreciated.
g++ gdb
New contributor
Have you downloaded a full set of development libraries
– rhubarbdog
Dec 3 at 23:45
I've many development packages: build-essentials, libc6-dev, libxml2-dev, libstdc++-5-dev, and others. (99 total ... I have boost dev libraries installed but not referring to them yet.) GNU autotools, of course.
– robgarv
Dec 4 at 0:24
add a comment |
up vote
1
down vote
favorite
up vote
1
down vote
favorite
I am porting a large set of applications and libraries from Debian 7 to Ubuntu 16.04. This is a GNU autotools project, so libtool is involved. gdb cannot find the symbols for the majority of the shared libraries, even though I am building with options that have always worked for me before. I am wondering if anyone else has encountered this problem, and if so what recommendations they might have.
I am using gdb version Ubuntu 7.11.1-0ubuntu1~16.5) 7.11.1.
I am compiling with -g O0 and other compiler options. These options are consistently employed when building 12 libraries. Exactly one of them emerges from the build process with debugging symbols. We'll designate that one libA. (In the discussion below, is just a substitution for the project path.)
Leaving out many -I directives, the options being used are:
-g -O0 -Wconversion -Woverloaded-virtual -Wall -Werror -Wreturn-type -
Wformat -Wparentheses -Wswitch -Wno-deprecated -Wsign-compare -fno-
strict-aliasing -Wunused -D__STDC_LIMIT_MACROS -MT MyModule.lo -MD -MP
-MF .deps/MyModule.Tpo -fPIC -DPIC -o .libs/MyModule.o
When I look at libA using gdb, file, and other utilities it looks fine.
u16dev01:(18:01:32):file libA.so.0.0.0 ~/dev/product-
<path>lib/liba/.libs
libA.so.0.0.0: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV),
dynamically linked,
BuildID[sha1]=14dc765142914be4c32a07eaa1683b5b2a2f6dae, not stripped
The object files look like this:
u16dev01:(18:01:43):file AModule1.o
<path>/lib/liba/.libs
AModule1.o: ELF 64-bit LSB relocatable, x86-64, version 1 (SYSV), not
stripped
If I open the shared library with gdb, I have symbols and I can list the code. If I open any of its .o files with gdb, I get symbols and can list code.
Of the remaining 11, the file command reports two as being SYSV and the other 9 as being GNU/Linux, for example:
u16dev01:(18:08:34):file libD.so.0.0.0
~/<path>/lib/.libs
libD.so.0.0.0: ELF 64-bit LSB shared object, x86-64,
version 1 (GNU/Linux), dynamically linked,
BuildID[sha1]=059733fbc888c3dce86eae21984ea82cddc5b0e9, not stripped
gdb sees no symbols when I open this library or any of its .o files. The file command also reports GNU/Linux for the .o files. There are no symbols.
There are two libraries which file reports as SYSV. Their .o files are also devoid of debugging information, and so are the libraries.
I renamed the strip program to preclude the possibility of the Makefiles from running strip, even though a careful search of compiler output told me it wasn't. So this is not a case of symbols being stripped after library build.
I tried to build a little test library, using the compiler options of my project. It builds a SYSV library and gdb loads debug symbols just fine.
objdump -g output is sparse in the cases when gdb can't load symbols.
I and a couple of my colleagues have been scratching our heads over this one for a few days now. Why does the build procedure produce viable symbols for only one of the libraries? There's nothing special about that library. Why are 9 of the remaining 11 reported GNU/Linux and 2 reported as SYSV? Why don't those 2 have symbols either?
Any ideas would be very appreciated.
g++ gdb
New contributor
I am porting a large set of applications and libraries from Debian 7 to Ubuntu 16.04. This is a GNU autotools project, so libtool is involved. gdb cannot find the symbols for the majority of the shared libraries, even though I am building with options that have always worked for me before. I am wondering if anyone else has encountered this problem, and if so what recommendations they might have.
I am using gdb version Ubuntu 7.11.1-0ubuntu1~16.5) 7.11.1.
I am compiling with -g O0 and other compiler options. These options are consistently employed when building 12 libraries. Exactly one of them emerges from the build process with debugging symbols. We'll designate that one libA. (In the discussion below, is just a substitution for the project path.)
Leaving out many -I directives, the options being used are:
-g -O0 -Wconversion -Woverloaded-virtual -Wall -Werror -Wreturn-type -
Wformat -Wparentheses -Wswitch -Wno-deprecated -Wsign-compare -fno-
strict-aliasing -Wunused -D__STDC_LIMIT_MACROS -MT MyModule.lo -MD -MP
-MF .deps/MyModule.Tpo -fPIC -DPIC -o .libs/MyModule.o
When I look at libA using gdb, file, and other utilities it looks fine.
u16dev01:(18:01:32):file libA.so.0.0.0 ~/dev/product-
<path>lib/liba/.libs
libA.so.0.0.0: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV),
dynamically linked,
BuildID[sha1]=14dc765142914be4c32a07eaa1683b5b2a2f6dae, not stripped
The object files look like this:
u16dev01:(18:01:43):file AModule1.o
<path>/lib/liba/.libs
AModule1.o: ELF 64-bit LSB relocatable, x86-64, version 1 (SYSV), not
stripped
If I open the shared library with gdb, I have symbols and I can list the code. If I open any of its .o files with gdb, I get symbols and can list code.
Of the remaining 11, the file command reports two as being SYSV and the other 9 as being GNU/Linux, for example:
u16dev01:(18:08:34):file libD.so.0.0.0
~/<path>/lib/.libs
libD.so.0.0.0: ELF 64-bit LSB shared object, x86-64,
version 1 (GNU/Linux), dynamically linked,
BuildID[sha1]=059733fbc888c3dce86eae21984ea82cddc5b0e9, not stripped
gdb sees no symbols when I open this library or any of its .o files. The file command also reports GNU/Linux for the .o files. There are no symbols.
There are two libraries which file reports as SYSV. Their .o files are also devoid of debugging information, and so are the libraries.
I renamed the strip program to preclude the possibility of the Makefiles from running strip, even though a careful search of compiler output told me it wasn't. So this is not a case of symbols being stripped after library build.
I tried to build a little test library, using the compiler options of my project. It builds a SYSV library and gdb loads debug symbols just fine.
objdump -g output is sparse in the cases when gdb can't load symbols.
I and a couple of my colleagues have been scratching our heads over this one for a few days now. Why does the build procedure produce viable symbols for only one of the libraries? There's nothing special about that library. Why are 9 of the remaining 11 reported GNU/Linux and 2 reported as SYSV? Why don't those 2 have symbols either?
Any ideas would be very appreciated.
g++ gdb
g++ gdb
New contributor
New contributor
New contributor
asked Dec 3 at 23:37
robgarv
163
163
New contributor
New contributor
Have you downloaded a full set of development libraries
– rhubarbdog
Dec 3 at 23:45
I've many development packages: build-essentials, libc6-dev, libxml2-dev, libstdc++-5-dev, and others. (99 total ... I have boost dev libraries installed but not referring to them yet.) GNU autotools, of course.
– robgarv
Dec 4 at 0:24
add a comment |
Have you downloaded a full set of development libraries
– rhubarbdog
Dec 3 at 23:45
I've many development packages: build-essentials, libc6-dev, libxml2-dev, libstdc++-5-dev, and others. (99 total ... I have boost dev libraries installed but not referring to them yet.) GNU autotools, of course.
– robgarv
Dec 4 at 0:24
Have you downloaded a full set of development libraries
– rhubarbdog
Dec 3 at 23:45
Have you downloaded a full set of development libraries
– rhubarbdog
Dec 3 at 23:45
I've many development packages: build-essentials, libc6-dev, libxml2-dev, libstdc++-5-dev, and others. (99 total ... I have boost dev libraries installed but not referring to them yet.) GNU autotools, of course.
– robgarv
Dec 4 at 0:24
I've many development packages: build-essentials, libc6-dev, libxml2-dev, libstdc++-5-dev, and others. (99 total ... I have boost dev libraries installed but not referring to them yet.) GNU autotools, of course.
– robgarv
Dec 4 at 0:24
add a comment |
2 Answers
2
active
oldest
votes
up vote
1
down vote
The problem was eventually tracked down to a legacy custom m4 macro. It failed to detect a library package and clobbered its contribution to the variables that were written to Makefile.in for include paths. The result was a -I with no path in the sequence of many -I directives. Oddly this produced no error ... but it did seem to cause the -g option which immediately followed it to be "swallowed". (The result was a long list of -I paths which ended with "-I -g". It looks like this prevented g++ from processing the -g option.).
Correcting the erroneous m4 macro to produce a non-empty and valid include file path fixed the problem.
New contributor
add a comment |
up vote
0
down vote
You need to use -g in your compile command. See the man page for gcc at the section titled: Options for Debugging Your Program
They have some cautions when used with the -O option.
Hmmm ... without turning off optimizations, it can be tricky understanding what's going on when stepping thru code. -O0 is supposed to turn off optimization (and it's always worked for me before). Apparently the manual recommends a -Og option ... so I tried that. Made no difference. So then I tried just -g ... no -O option of any kind. Exact same results. It's quite baffling. Thanks for the response.
– robgarv
Dec 4 at 7:53
add a comment |
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
1
down vote
The problem was eventually tracked down to a legacy custom m4 macro. It failed to detect a library package and clobbered its contribution to the variables that were written to Makefile.in for include paths. The result was a -I with no path in the sequence of many -I directives. Oddly this produced no error ... but it did seem to cause the -g option which immediately followed it to be "swallowed". (The result was a long list of -I paths which ended with "-I -g". It looks like this prevented g++ from processing the -g option.).
Correcting the erroneous m4 macro to produce a non-empty and valid include file path fixed the problem.
New contributor
add a comment |
up vote
1
down vote
The problem was eventually tracked down to a legacy custom m4 macro. It failed to detect a library package and clobbered its contribution to the variables that were written to Makefile.in for include paths. The result was a -I with no path in the sequence of many -I directives. Oddly this produced no error ... but it did seem to cause the -g option which immediately followed it to be "swallowed". (The result was a long list of -I paths which ended with "-I -g". It looks like this prevented g++ from processing the -g option.).
Correcting the erroneous m4 macro to produce a non-empty and valid include file path fixed the problem.
New contributor
add a comment |
up vote
1
down vote
up vote
1
down vote
The problem was eventually tracked down to a legacy custom m4 macro. It failed to detect a library package and clobbered its contribution to the variables that were written to Makefile.in for include paths. The result was a -I with no path in the sequence of many -I directives. Oddly this produced no error ... but it did seem to cause the -g option which immediately followed it to be "swallowed". (The result was a long list of -I paths which ended with "-I -g". It looks like this prevented g++ from processing the -g option.).
Correcting the erroneous m4 macro to produce a non-empty and valid include file path fixed the problem.
New contributor
The problem was eventually tracked down to a legacy custom m4 macro. It failed to detect a library package and clobbered its contribution to the variables that were written to Makefile.in for include paths. The result was a -I with no path in the sequence of many -I directives. Oddly this produced no error ... but it did seem to cause the -g option which immediately followed it to be "swallowed". (The result was a long list of -I paths which ended with "-I -g". It looks like this prevented g++ from processing the -g option.).
Correcting the erroneous m4 macro to produce a non-empty and valid include file path fixed the problem.
New contributor
New contributor
answered yesterday
robgarv
163
163
New contributor
New contributor
add a comment |
add a comment |
up vote
0
down vote
You need to use -g in your compile command. See the man page for gcc at the section titled: Options for Debugging Your Program
They have some cautions when used with the -O option.
Hmmm ... without turning off optimizations, it can be tricky understanding what's going on when stepping thru code. -O0 is supposed to turn off optimization (and it's always worked for me before). Apparently the manual recommends a -Og option ... so I tried that. Made no difference. So then I tried just -g ... no -O option of any kind. Exact same results. It's quite baffling. Thanks for the response.
– robgarv
Dec 4 at 7:53
add a comment |
up vote
0
down vote
You need to use -g in your compile command. See the man page for gcc at the section titled: Options for Debugging Your Program
They have some cautions when used with the -O option.
Hmmm ... without turning off optimizations, it can be tricky understanding what's going on when stepping thru code. -O0 is supposed to turn off optimization (and it's always worked for me before). Apparently the manual recommends a -Og option ... so I tried that. Made no difference. So then I tried just -g ... no -O option of any kind. Exact same results. It's quite baffling. Thanks for the response.
– robgarv
Dec 4 at 7:53
add a comment |
up vote
0
down vote
up vote
0
down vote
You need to use -g in your compile command. See the man page for gcc at the section titled: Options for Debugging Your Program
They have some cautions when used with the -O option.
You need to use -g in your compile command. See the man page for gcc at the section titled: Options for Debugging Your Program
They have some cautions when used with the -O option.
answered Dec 4 at 2:31
ubfan1
9,14141527
9,14141527
Hmmm ... without turning off optimizations, it can be tricky understanding what's going on when stepping thru code. -O0 is supposed to turn off optimization (and it's always worked for me before). Apparently the manual recommends a -Og option ... so I tried that. Made no difference. So then I tried just -g ... no -O option of any kind. Exact same results. It's quite baffling. Thanks for the response.
– robgarv
Dec 4 at 7:53
add a comment |
Hmmm ... without turning off optimizations, it can be tricky understanding what's going on when stepping thru code. -O0 is supposed to turn off optimization (and it's always worked for me before). Apparently the manual recommends a -Og option ... so I tried that. Made no difference. So then I tried just -g ... no -O option of any kind. Exact same results. It's quite baffling. Thanks for the response.
– robgarv
Dec 4 at 7:53
Hmmm ... without turning off optimizations, it can be tricky understanding what's going on when stepping thru code. -O0 is supposed to turn off optimization (and it's always worked for me before). Apparently the manual recommends a -Og option ... so I tried that. Made no difference. So then I tried just -g ... no -O option of any kind. Exact same results. It's quite baffling. Thanks for the response.
– robgarv
Dec 4 at 7:53
Hmmm ... without turning off optimizations, it can be tricky understanding what's going on when stepping thru code. -O0 is supposed to turn off optimization (and it's always worked for me before). Apparently the manual recommends a -Og option ... so I tried that. Made no difference. So then I tried just -g ... no -O option of any kind. Exact same results. It's quite baffling. Thanks for the response.
– robgarv
Dec 4 at 7:53
add a comment |
robgarv is a new contributor. Be nice, and check out our Code of Conduct.
robgarv is a new contributor. Be nice, and check out our Code of Conduct.
robgarv is a new contributor. Be nice, and check out our Code of Conduct.
robgarv is a new contributor. Be nice, and check out our Code of Conduct.
Thanks for contributing an answer to Ask Ubuntu!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1098257%2fg-and-gdb-problem-debug-symbols-for-shared-libraries-not-found%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Have you downloaded a full set of development libraries
– rhubarbdog
Dec 3 at 23:45
I've many development packages: build-essentials, libc6-dev, libxml2-dev, libstdc++-5-dev, and others. (99 total ... I have boost dev libraries installed but not referring to them yet.) GNU autotools, of course.
– robgarv
Dec 4 at 0:24