binutils-gdb/gdb/testsuite/gdb.base/global-var-nested-by-dso.c

28 lines
863 B
C
Raw Normal View History

/* Copyright 2014-2018 Free Software Foundation, Inc.
Add test for global variable that is nested by another DSO This is just a testcase addition that I am proposing for upstream GDB. We have this in our internal tree, and the related RH bug is: <https://bugzilla.redhat.com/show_bug.cgi?id=809179> (You might not be able to see all the comments without privileges.) This bug is about a global variable that got incorrectly displayed by GDB. This bug has already been fixed a long time ago by Joel's commit: commit 19630284f570790ebf6d50bfb43caa1f125ee88a Author: Joel Brobecker <brobecker@gnat.com> Date: Tue Jun 5 13:50:50 2012 +0000 But I think a testcase for it wouldn't hurt. So, consider the following scenario: $ cat solib1.c int test; void c_main (void) { test = 42; } $ cat solib2.c int test; void b_main (void) { test = 42; } $ cat main.c int main (int argc, char *argv[]) { c_main (); b_main (); return 0; } $ gcc -g -fPIC -shared -o libSO1.so -c solib1.c $ gcc -g -fPIC -shared -o libSO2.so -c solib2.c $ gcc -g -o main -L$PWD -lSO1 -lSO2 main.c $ LD_LIBRARY_PATH=. gdb -q -batch -ex 'b c_main' -ex r -ex n -ex 'p test' ./main ... $1 = 0 This happened with GDB before Joel's commit above. Now, things work and GDB is able to correctly display the nested global variable: $ LD_LIBRARY_PATH=. gdb -q -batch -ex 'b c_main' -ex r -ex n -ex 'p test' ./main ... $1 = 42 The testcase attached tests this behavior. gdb/testsuite/ChangeLog: 2014-09-16 Sergio Durigan Junior <sergiodj@redhat.com> * gdb.base/global-var-nested-by-dso-solib1.c: New file. * gdb.base/global-var-nested-by-dso-solib2.c: Likewise. * gdb.base/global-var-nested-by-dso.c: Likewise. * gdb.base/global-var-nested-by-dso.exp: Likewise.
2014-09-17 04:54:03 +02:00
This file is part of GDB.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
GDB testsuite: Fix warnings with -std=gnu11 Since upstream GCC has changed the default C language dialect to 'gnu11', it yields multiple warnings in the GDB testsuite for missing function return types and implicit function declarations. This patch attempts to fix these. gdb/testsuite/ChangeLog: * gdb.ada/cond_lang/foo.c (callme): Add return type. * gdb.base/call-sc.c (zed): Likewise. * gdb.base/checkpoint.c (main): Likewise. * gdb.base/dump.c (main): Likewise. * gdb.base/gcore.c (main): Likewise. * gdb.base/huge.c (main): Likewise. * gdb.base/multi-forks.c (main): Likewise. * gdb.base/pr10179-a.c (main): Likewise. * gdb.base/savedregs.c (main): Likewise. * gdb.base/sigaltstack.c (main): Likewise. * gdb.base/siginfo.c (main): Likewise. * gdb.base/structs.c (zed): Likewise. * gdb.mi/mi-stack.c (callee3, callee2, callee1, main): Likewise. * gdb.mi/mi-syn-frame.c (main): Likewise. * gdb.mi/until.c (foo, main): Likewise. * gdb.base/global-var-nested-by-dso.c (b_main, c_main): Declare. * gdb.base/solib-weak.c (foo): Declare. * gdb.base/attach-twice.c: Include stdio.h. * gdb.base/weaklib1.c: Likewise. * gdb.base/weaklib2.c: Likewise. * gdb.base/catch-signal-fork.c: Include stdio.h and sys/wait.h. * gdb.mi/mi-condbreak-call-thr-state-mt.c: Include stdio.h and unistd.h. * gdb.base/attach-pie-misread.c: Include stdlib.h. * gdb.mi/mi-exit-code.c: Likewise. * gdb.base/break-interp-lib.c: Include string.h. * gdb.base/coremaker.c: Likewise. * gdb.base/testenv.c: Likewise. * gdb.python/py-finish-breakpoint.c: Likewise. * gdb.base/inferior-died.c: Include sys/wait.h. * gdb.base/fileio.c: Include time.h. * gdb.base/async-shell.c: Include unistd.h. * gdb.base/dprintf-non-stop.c: Likewise. * gdb.base/info-os.c: Likewise. * gdb.mi/mi-console.c: Likewise. * gdb.mi/watch-nonstop.c: Likewise. * gdb.python/py-events.c: Likewise. * gdb.base/async.c (baz): Move up before its invocation. * gdb.base/code_elim2.c (my_global_func): Likewise. * gdb.base/skip-solib-lib.c (multiply): Likewise. * gdb.base/advance.c (func2): Likewise.
2014-10-28 13:39:22 +01:00
extern void b_main (void);
extern void c_main (void);
Add test for global variable that is nested by another DSO This is just a testcase addition that I am proposing for upstream GDB. We have this in our internal tree, and the related RH bug is: <https://bugzilla.redhat.com/show_bug.cgi?id=809179> (You might not be able to see all the comments without privileges.) This bug is about a global variable that got incorrectly displayed by GDB. This bug has already been fixed a long time ago by Joel's commit: commit 19630284f570790ebf6d50bfb43caa1f125ee88a Author: Joel Brobecker <brobecker@gnat.com> Date: Tue Jun 5 13:50:50 2012 +0000 But I think a testcase for it wouldn't hurt. So, consider the following scenario: $ cat solib1.c int test; void c_main (void) { test = 42; } $ cat solib2.c int test; void b_main (void) { test = 42; } $ cat main.c int main (int argc, char *argv[]) { c_main (); b_main (); return 0; } $ gcc -g -fPIC -shared -o libSO1.so -c solib1.c $ gcc -g -fPIC -shared -o libSO2.so -c solib2.c $ gcc -g -o main -L$PWD -lSO1 -lSO2 main.c $ LD_LIBRARY_PATH=. gdb -q -batch -ex 'b c_main' -ex r -ex n -ex 'p test' ./main ... $1 = 0 This happened with GDB before Joel's commit above. Now, things work and GDB is able to correctly display the nested global variable: $ LD_LIBRARY_PATH=. gdb -q -batch -ex 'b c_main' -ex r -ex n -ex 'p test' ./main ... $1 = 42 The testcase attached tests this behavior. gdb/testsuite/ChangeLog: 2014-09-16 Sergio Durigan Junior <sergiodj@redhat.com> * gdb.base/global-var-nested-by-dso-solib1.c: New file. * gdb.base/global-var-nested-by-dso-solib2.c: Likewise. * gdb.base/global-var-nested-by-dso.c: Likewise. * gdb.base/global-var-nested-by-dso.exp: Likewise.
2014-09-17 04:54:03 +02:00
int
main (int argc, char *argv[])
{
c_main ();
b_main ();
return 0;
}