GDB currently misses fetching the list of already-registered JIT modules on attach.
The master branch has been updated by Pedro Alves <palves@sourceware.org>: https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=9bb84c9f97cb81df81f18f4e47d6b24fa37b597c commit 9bb84c9f97cb81df81f18f4e47d6b24fa37b597c Author: Yichao Yu <yyc1992@gmail.com> Date: Thu Mar 31 19:28:47 2016 +0100 Fix PR gdb/19858: GDB doesn't register the JIT libraries on attach Ref: https://sourceware.org/ml/gdb/2016-03/msg00023.html GDB currently fails to fetch the list of already-registered JIT modules on attach. Nothing is calling jit_inferior_init, which is what is responsible for walking the JIT object list at init time. Despite the misleading naming, jit_inferior_created_hook -> jit_inferior_init is only called when the inferior execs. This regressed with the fix for PR gdb/13431 (03bef283c2d3): https://sourceware.org/ml/gdb-patches/2012-02/msg00023.html which removed the inferior_created (jit_inferior_created_observer) observer. Adding an inferior_created observer back fixes the issue. In turn, this exposes a bug in jit_breakpoint_re_set_internal as well, which is returning the wrong result when we already have the breakpoint at the right address. gdb/ChangeLog: 2016-03-31 Yichao Yu <yyc1992@gmail.com> PR gdb/19858 * jit.c (jit_breakpoint_re_set_internal): Return 0 if we already got the breakpoint at the right address. (jit_inferior_created): New function. (_initialize_jit): Install jit_inferior_created as inferior_created observer. Signed-off-by: Pedro Alves <palves@redhat.com>
The master branch has been updated by Pedro Alves <palves@sourceware.org>: https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=40dea8cbf6b40f159bdfab4f3d8ec9010c293e84 commit 40dea8cbf6b40f159bdfab4f3d8ec9010c293e84 Author: Pedro Alves <palves@redhat.com> Date: Thu Mar 31 19:28:47 2016 +0100 Make gdb.base/jit.exp binaries unique This testcase compiles the same program and library differently multiple times using the same file names. Make them unique, to make it easier to debug test problems. gdb/testsuite/ChangeLog: 2016-03-31 Pedro Alves <palves@redhat.com> PR gdb/19858 * gdb.base/jit.exp (compile_jit_test): Add intro comment. Add BINSUFFIX parameter, and handle it. (top level): Adjust calls compile_jit_test.
The master branch has been updated by Pedro Alves <palves@sourceware.org>: https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=64cdf930d9ed85e93ae55adbc20b0f9848ef863b commit 64cdf930d9ed85e93ae55adbc20b0f9848ef863b Author: Pedro Alves <palves@redhat.com> Date: Thu Mar 31 19:28:47 2016 +0100 Add regression test for PR gdb/19858 (JIT code registration on attach) This test would fail without the previous gdb/jit.c fix: (gdb) attach 23031 Attaching to program: .../build/gdb/testsuite/outputs/gdb.base/jit/jit-main, process 23031 [...] 207 WAIT_FOR_GDB; i = 0; /* gdb break here 1 */ (gdb) PASS: gdb.base/jit.exp: attach: one_jit_test-2: attach set var wait_for_gdb = 0 (gdb) PASS: gdb.base/jit.exp: attach: one_jit_test-2: set var wait_for_gdb = 0 info function ^jit_function All functions matching regular expression "^jit_function": (gdb) FAIL: gdb.base/jit.exp: attach: one_jit_test-2: info function ^jit_function gdb/testsuite/ChangeLog: 2016-03-31 Pedro Alves <palves@redhat.com> PR gdb/19858 * gdb.base/jit-main.c: Include unistd.h. (ATTACH): Define to 0 if not already defined. (wait_for_gdb, mypid): New globals. (WAIT_FOR_GDB): New macro. (MAIN): Set an alarm. Store the process's pid. Wait for GDB at some breakpoint locations. * gdb.base/jit.exp (clean_reattach, continue_to_test_location): New procedures. (one_jit_test): Add REATTACH parameter, and handle it. Use continue_to_test_location. (top level): Test attach, and adjusts calls to one_jit_test.
The gdb-7.11-branch branch has been updated by Pedro Alves <palves@sourceware.org>: https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=cd64cabb8c66a5565fc33bf66a07c08bc767e413 commit cd64cabb8c66a5565fc33bf66a07c08bc767e413 Author: Yichao Yu <yyc1992@gmail.com> Date: Thu Mar 31 19:28:47 2016 +0100 Fix PR gdb/19858: GDB doesn't register the JIT libraries on attach Ref: https://sourceware.org/ml/gdb/2016-03/msg00023.html GDB currently fails to fetch the list of already-registered JIT modules on attach. Nothing is calling jit_inferior_init, which is what is responsible for walking the JIT object list at init time. Despite the misleading naming, jit_inferior_created_hook -> jit_inferior_init is only called when the inferior execs. This regressed with the fix for PR gdb/13431 (03bef283c2d3): https://sourceware.org/ml/gdb-patches/2012-02/msg00023.html which removed the inferior_created (jit_inferior_created_observer) observer. Adding an inferior_created observer back fixes the issue. In turn, this exposes a bug in jit_breakpoint_re_set_internal as well, which is returning the wrong result when we already have the breakpoint at the right address. gdb/ChangeLog: 2016-03-31 Yichao Yu <yyc1992@gmail.com> PR gdb/19858 * jit.c (jit_breakpoint_re_set_internal): Return 0 if we already got the breakpoint at the right address. (jit_inferior_created): New function. (_initialize_jit): Install jit_inferior_created as inferior_created observer. Signed-off-by: Pedro Alves <palves@redhat.com>
The gdb-7.11-branch branch has been updated by Pedro Alves <palves@sourceware.org>: https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=89df5d6cce0e91c4b34c7a62ba4a68756a8ed4e7 commit 89df5d6cce0e91c4b34c7a62ba4a68756a8ed4e7 Author: Pedro Alves <palves@redhat.com> Date: Thu Mar 31 19:28:47 2016 +0100 Make gdb.base/jit.exp binaries unique This testcase compiles the same program and library differently multiple times using the same file names. Make them unique, to make it easier to debug test problems. gdb/testsuite/ChangeLog: 2016-03-31 Pedro Alves <palves@redhat.com> PR gdb/19858 * gdb.base/jit.exp (compile_jit_test): Add intro comment. Add BINSUFFIX parameter, and handle it. (top level): Adjust calls compile_jit_test.
The gdb-7.11-branch branch has been updated by Pedro Alves <palves@sourceware.org>: https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=85af34ee0211eedf8d30a5c44dfc59dddf8b512a commit 85af34ee0211eedf8d30a5c44dfc59dddf8b512a Author: Pedro Alves <palves@redhat.com> Date: Thu Mar 31 19:28:47 2016 +0100 Add regression test for PR gdb/19858 (JIT code registration on attach) This test would fail without the previous gdb/jit.c fix: (gdb) attach 23031 Attaching to program: .../build/gdb/testsuite/outputs/gdb.base/jit/jit-main, process 23031 [...] 207 WAIT_FOR_GDB; i = 0; /* gdb break here 1 */ (gdb) PASS: gdb.base/jit.exp: attach: one_jit_test-2: attach set var wait_for_gdb = 0 (gdb) PASS: gdb.base/jit.exp: attach: one_jit_test-2: set var wait_for_gdb = 0 info function ^jit_function All functions matching regular expression "^jit_function": (gdb) FAIL: gdb.base/jit.exp: attach: one_jit_test-2: info function ^jit_function gdb/testsuite/ChangeLog: 2016-03-31 Pedro Alves <palves@redhat.com> PR gdb/19858 * gdb.base/jit-main.c: Include unistd.h. (ATTACH): Define to 0 if not already defined. (wait_for_gdb, mypid): New globals. (WAIT_FOR_GDB): New macro. (MAIN): Set an alarm. Store the process's pid. Wait for GDB at some breakpoint locations. * gdb.base/jit.exp (clean_reattach, continue_to_test_location): New procedures. (one_jit_test): Add REATTACH parameter, and handle it. Use continue_to_test_location. (top level): Test attach, and adjusts calls to one_jit_test.
Fixed.
The master branch has been updated by Jan Kratochvil <jkratoch@sourceware.org>: https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=065005336492337c92d06e87544646635a5b9566 commit 065005336492337c92d06e87544646635a5b9566 Author: Jan Kratochvil <jan.kratochvil@redhat.com> Date: Fri Apr 8 15:38:53 2016 +0200 testsuite: Fix for gcc-4.8: gdb.base/jit.exp gdb.base/jit-so.exp on CentOS-7.2 I get Running /home/jkratoch/redhat/gdb-test-reg/gdb/testsuite/gdb.base/jit.exp ... FAIL: gdb.base/jit.exp: one_jit_test-1: continue to breakpoint: break here 2 (the program exited) FAIL: gdb.base/jit.exp: one_jit_test-2: continue to breakpoint: break here 2 (the program exited) FAIL: gdb.base/jit.exp: attach: one_jit_test-2: continue to breakpoint: break here 2 (the program exited) FAIL: gdb.base/jit.exp: attach: one_jit_test-2: break here 2: set var wait_for_gdb = 1 FAIL: gdb.base/jit.exp: attach: one_jit_test-2: break here 2: detach (the program is no longer running) FAIL: gdb.base/jit.exp: attach: one_jit_test-2: break here 2: attach FAIL: gdb.base/jit.exp: attach: one_jit_test-2: break here 2: set var wait_for_gdb = 0 FAIL: gdb.base/jit.exp: PIE: one_jit_test-1: continue to breakpoint: break here 2 (the program exited) Running /home/jkratoch/redhat/gdb-test-reg/gdb/testsuite/gdb.base/jit-so.exp ... FAIL: gdb.base/jit-so.exp: one_jit_test-1: continue to breakpoint: break here 2 (the program exited) FAIL: gdb.base/jit-so.exp: one_jit_test-2: continue to breakpoint: break here 2 (the program exited) since: 85af34ee0211eedf8d30a5c44dfc59dddf8b512a is the first bad commit commit 85af34ee0211eedf8d30a5c44dfc59dddf8b512a Author: Pedro Alves <palves@redhat.com> Date: Thu Mar 31 19:28:47 2016 +0100 Add regression test for PR gdb/19858 (JIT code registration on attach) The compiled code's .debug_line is wrong (for the simplistic approach of GDB to put a breakpoint on the first address belonging to that source line) and so GDB misses the breakpoint at the last line: WAIT_FOR_GDB; return 0; /* gdb break here 2 */ Most of the patch is just about reindentation, no changes there. gdb/testsuite/ChangeLog 2016-04-08 Jan Kratochvil <jan.kratochvil@redhat.com> Fix compatibility with gcc-4.8.5-4.el7.x86_64. * gdb.base/jit-main.c: Use exit after usage.