From: Paul Pluzhnikov <ppluzhnikov@google.com>
To: Joel Brobecker <brobecker@adacore.com>
Cc: Jan Kratochvil <jan.kratochvil@redhat.com>,
gdb-patches@sourceware.org, Yuri <yuri@rawbw.com>,
Tom Tromey <tromey@redhat.com>
Subject: Re: [patch,7.3] Fix JIT clang-lli gdb-7.3 regression Re: [gdb-7.3] Error in gdb-llvm integration: Unable to read JIT descriptor from remote memory!
Date: Tue, 05 Jul 2011 21:08:00 -0000 [thread overview]
Message-ID: <CALoOobNUGG=07Sj9oPHfKu=zbT8tiG482N-U-cd_oZht-NmSMA@mail.gmail.com> (raw)
In-Reply-To: <20110705170728.GY2407@adacore.com>
[-- Attachment #1: Type: text/plain, Size: 1087 bytes --]
On Tue, Jul 5, 2011 at 10:07 AM, Joel Brobecker <brobecker@adacore.com> wrote:
> We're getting ready to produce the first gdb-7.3 candidate release,
> and we're thinking of either:
> - going with Jan's patch for now, with a view of possibly
> making it better with a followup patch if necessary;
> - releasing 7.3 with JIT as a known problem, hopefully to be
> fixed for 7.3.1, depending on how safe the fix is perceived.
Another option is to apply a better fix (provided it is deemed safe) ...
Certainly it's ok with me if you decide to go with Jan's patch for now.
It took me much longer to create a test case (I don't have 'lli'), then
it did to fix the problem once I had the repro.
Thanks,
--
Paul Pluzhnikov
2011-07-05 Paul Pluzhnikov <ppluzhnikov@google.com>
jit.c (jit_breakpoint_re_set_internal): Call jit_inferior_init.
testsuite/ChangeLog:
2011-07-05 Paul Pluzhnikov <ppluzhnikov@google.com>
* gdb.base/jit-so.exp: New test.
* gdb.base/jit-dlmain.c: New file.
* gdb.base/jit-main.c: Allow "main" to be elsewhere.
[-- Attachment #2: gdb-jit-20110705.txt --]
[-- Type: text/plain, Size: 6978 bytes --]
Index: jit.c
===================================================================
RCS file: /cvs/src/src/gdb/jit.c,v
retrieving revision 1.12
diff -u -p -n -p -r1.12 jit.c
*** jit.c 17 Apr 2011 18:38:45 -0000 1.12
--- jit.c 5 Jul 2011 20:58:12 -0000
*************** static const char *const jit_descriptor_
*** 40,45 ****
--- 40,48 ----
static const struct inferior_data *jit_inferior_data = NULL;
+ static void
+ jit_inferior_init (struct gdbarch *gdbarch);
+
/* Non-zero if we want to see trace of jit level stuff. */
static int jit_debug = 0;
*************** jit_breakpoint_re_set_internal (struct g
*** 351,356 ****
--- 354,364 ----
inf_data->breakpoint_addr = SYMBOL_VALUE_ADDRESS (reg_symbol);
if (inf_data->breakpoint_addr == 0)
return 2;
+
+ /* If we have not read the jit descriptor yet (e.g. because the JITer
+ itself is in a shared library which just got loaded), do so now. */
+ if (inf_data->descriptor_addr == 0)
+ jit_inferior_init (gdbarch);
}
else
return 0;
Index: testsuite/gdb.base/jit-dlmain.c
===================================================================
RCS file: testsuite/gdb.base/jit-dlmain.c
diff -N testsuite/gdb.base/jit-dlmain.c
*** /dev/null 1 Jan 1970 00:00:00 -0000
--- testsuite/gdb.base/jit-dlmain.c 5 Jul 2011 20:58:12 -0000
***************
*** 0 ****
--- 1,16 ----
+ #include <dlfcn.h>
+ #include <stdio.h>
+
+ int main (int argc, char *argv[])
+ {
+ void *h = dlopen ("jit-dlmain-so.so", RTLD_LAZY);
+ int (*p_main) (int, char **);
+
+ if (h == NULL) return 1;
+
+ p_main = dlsym (h, "jit_dl_main");
+ if (p_main == NULL) return 2;
+
+ h = h; /* break here after-dlopen */
+ return (*p_main) (argc, argv);
+ }
Index: testsuite/gdb.base/jit-main.c
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.base/jit-main.c,v
retrieving revision 1.2
diff -u -p -n -p -r1.2 jit-main.c
*** testsuite/gdb.base/jit-main.c 15 Mar 2011 21:03:44 -0000 1.2
--- testsuite/gdb.base/jit-main.c 5 Jul 2011 20:58:12 -0000
*************** update_locations (const void *const addr
*** 117,124 ****
}
}
int
! main (int argc, char *argv[])
{
/* These variables are here so they can easily be set from jit.exp. */
const char *libname = NULL;
--- 117,128 ----
}
}
+ #ifndef MAIN
+ #define MAIN main
+ #endif
+
int
! MAIN (int argc, char *argv[])
{
/* These variables are here so they can easily be set from jit.exp. */
const char *libname = NULL;
Index: testsuite/gdb.base/jit-so.exp
===================================================================
RCS file: testsuite/gdb.base/jit-so.exp
diff -N testsuite/gdb.base/jit-so.exp
*** /dev/null 1 Jan 1970 00:00:00 -0000
--- testsuite/gdb.base/jit-so.exp 5 Jul 2011 20:58:12 -0000
***************
*** 0 ****
--- 1,117 ----
+ # Copyright 2011 Free Software Foundation, Inc.
+
+ # 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/>.
+
+ # The same tests as in jit.exp, but loading JITer itself from a shared
+ # library.
+
+ if $tracelevel {
+ strace $tracelevel
+ }
+
+ if {[skip_shlib_tests]} {
+ untested jit-so.exp
+ return -1
+ }
+
+ if {[get_compiler_info not-used]} {
+ warning "Could not get compiler info"
+ untested jit-so.exp
+ return 1
+ }
+
+ #
+ # test running programs
+ #
+
+ set testfile jit-dlmain
+ set srcfile ${testfile}.c
+ set binfile ${objdir}/${subdir}/${testfile}
+ if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug shlib_load}] != "" } {
+ untested jit-so.exp
+ return -1
+ }
+
+ set testfile2 jit-main
+ set srcfile2 ${testfile2}.c
+ set binfile2 ${objdir}/${subdir}/${testfile2}.so
+ if { [gdb_compile_shlib "${srcdir}/${subdir}/${srcfile2}" ${binfile2} {debug additional_flags="-DMAIN=jit_dl_main"}] != "" } {
+ untested jit.exp
+ return -1
+ }
+
+ set solib_testfile "jit-solib"
+ set solib_srcfile "${srcdir}/${subdir}/${solib_testfile}.c"
+ set solib_binfile "${objdir}/${subdir}/${solib_testfile}.so"
+ set solib_binfile_test_msg "OBJDIR/${subdir}/${solib_testfile}.so"
+
+ # Note: compiling without debug info: the library goes through symbol
+ # renaming by munging on its symbol table, and that wouldn't work for .debug
+ # sections. Also, output for "info function" changes when debug info is resent.
+ if { [gdb_compile_shlib ${solib_srcfile} ${solib_binfile} {}] != "" } {
+ untested jit-so.exp
+ return -1
+ }
+
+ proc one_jit_test {count match_str} {
+ global verbose testfile srcfile2 solib_binfile solib_binfile_test_msg pf_prefix
+
+ set old_pf_prefix $pf_prefix
+ set pf_prefix "one_jit_test-$count"
+
+ clean_restart $testfile
+
+ # This is just to help debugging when things fail
+ if {$verbose > 0} {
+ gdb_test "set debug jit 1"
+ }
+
+ if { ![runto_main] } {
+ fail "Can't run to main"
+ return
+ }
+
+ gdb_breakpoint [gdb_get_line_number "break here after-dlopen" ]
+ gdb_continue_to_breakpoint "break here after-dlopen"
+
+ gdb_breakpoint "$srcfile2:[gdb_get_line_number {break here 0} $srcfile2]"
+ gdb_continue_to_breakpoint "break here 0"
+
+ # Poke desired values directly into inferior instead of using "set args"
+ # because "set args" does not work under gdbserver.
+ gdb_test_no_output "set var argc = 2"
+ gdb_test_no_output "set var libname = \"$solib_binfile\"" "set var libname = \"$solib_binfile_test_msg\""
+ gdb_test_no_output "set var count = $count"
+
+ gdb_breakpoint "$srcfile2:[gdb_get_line_number {break here 1} $srcfile2]"
+ gdb_continue_to_breakpoint "break here 1"
+
+ gdb_test "info function jit_function" "$match_str"
+
+ # This is just to help debugging when things fail
+ if {$verbose > 0} {
+ gdb_test "maintenance print objfiles"
+ gdb_test "maintenance info break"
+ }
+
+ gdb_breakpoint "$srcfile2:[gdb_get_line_number {break here 2} $srcfile2]"
+ gdb_continue_to_breakpoint "break here 2"
+ # All jit librares must have been unregistered
+ gdb_test "info function jit_function" \
+ "All functions matching regular expression \"jit_function\":" \
+ set pf_prefix $old_pf_prefix
+ }
+
+ one_jit_test 1 "${hex} jit_function_0000"
+ one_jit_test 2 "${hex} jit_function_0000\[\r\n\]+${hex} jit_function_0001"
next prev parent reply other threads:[~2011-07-05 21:07 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <4E0FAB8D.2070709@rawbw.com>
2011-07-04 22:21 ` Jan Kratochvil
2011-07-05 2:26 ` Paul Pluzhnikov
2011-07-05 8:00 ` [patch,7.3] Fix JIT clang-lli gdb-7.3 regression Jan Kratochvil
2011-07-05 17:08 ` [patch,7.3] Fix JIT clang-lli gdb-7.3 regression Re: [gdb-7.3] Error in gdb-llvm integration: Unable to read JIT descriptor from remote memory! Tom Tromey
2011-07-05 17:44 ` Joel Brobecker
2011-07-05 21:08 ` Paul Pluzhnikov [this message]
2011-07-05 22:18 ` Joel Brobecker
2011-07-05 22:23 ` Paul Pluzhnikov
2011-07-06 12:10 ` [patch,7.3] Fix JIT clang-lli gdb-7.3 regression Jan Kratochvil
2011-07-06 16:12 ` Joel Brobecker
2011-07-06 16:35 ` Paul Pluzhnikov
2011-07-06 16:37 ` Jan Kratochvil
2011-07-06 17:12 ` Paul Pluzhnikov
2011-07-06 17:26 ` Jan Kratochvil
2011-07-06 17:04 ` [patch,7.3] Fix JIT clang-lli gdb-7.3 regression Re: [gdb-7.3] Error in gdb-llvm integration: Unable to read JIT descriptor from remote memory! Paul Pluzhnikov
2011-07-06 22:18 ` Joel Brobecker
2011-07-06 22:50 ` Paul Pluzhnikov
2011-07-06 22:52 ` Joel Brobecker
2011-07-07 12:10 ` Jan Kratochvil
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='CALoOobNUGG=07Sj9oPHfKu=zbT8tiG482N-U-cd_oZht-NmSMA@mail.gmail.com' \
--to=ppluzhnikov@google.com \
--cc=brobecker@adacore.com \
--cc=gdb-patches@sourceware.org \
--cc=jan.kratochvil@redhat.com \
--cc=tromey@redhat.com \
--cc=yuri@rawbw.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