Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Sanjoy Das <sanjoy@playingwithpointers.com>
To: gdb-patches@sourceware.org
Cc: Sanjoy Das <sanjoy@playingwithpointers.com>
Subject: [PATCH 2/7] Relocatable directory for loading JIT readers.
Date: Wed, 24 Aug 2011 18:57:00 -0000	[thread overview]
Message-ID: <1314212467-7391-3-git-send-email-sanjoy@playingwithpointers.com> (raw)
In-Reply-To: <1314212467-7391-1-git-send-email-sanjoy@playingwithpointers.com>

Add a new directory `jit_reader_dir' to jit.c, which is relocated
during initialization.  The value of the directory can be set by using
--with-jit-reader-dir on configure and defaults to `${libdir}/gdb'.
---
 gdb/config.in    |    6 ++++++
 gdb/configure    |   51 +++++++++++++++++++++++++++++++++++++++++++++++++++
 gdb/configure.ac |    4 ++++
 gdb/jit.c        |    4 ++++
 4 files changed, 65 insertions(+), 0 deletions(-)

diff --git a/gdb/config.in b/gdb/config.in
index c1d7c68..b1aef82 100644
--- a/gdb/config.in
+++ b/gdb/config.in
@@ -982,3 +982,9 @@
 
 /* Define as `fork' if `vfork' does not work. */
 #undef vfork
+
+/* The directory from which JIT readers should be loaded. */
+#undef JIT_READER_DIR
+
+/* Define if JIT_READER_DIR should be relocated when GDB is moved. */
+#undef JIT_READER_DIR_RELOCATABLE
diff --git a/gdb/configure b/gdb/configure
index 31469f2..c6dfbf7 100755
--- a/gdb/configure
+++ b/gdb/configure
@@ -666,6 +666,7 @@ python_prog_path
 LTLIBEXPAT
 LIBEXPAT
 HAVE_LIBEXPAT
+JIT_READER_DIR
 TARGET_PTR
 READLINE_TEXI_INCFLAG
 READLINE_CFLAGS
@@ -964,6 +965,7 @@ with_zlib
 with_libiconv_prefix
 with_iconv_bin
 with_system_readline
+with_jit_reader_dir
 with_expat
 with_gnu_ld
 enable_rpath
@@ -1664,6 +1666,8 @@ Optional Packages:
                           search for libiconv in DIR/include and DIR/lib
   --with-iconv-bin=PATH   specify where to find the iconv program
   --with-system-readline  use installed readline library
+  --with-jit-reader-dir=PATH
+                          directory to load the JIT readers from
   --with-expat            include expat support (auto/yes/no)
   --with-gnu-ld           assume the C compiler uses GNU ld default=no
   --with-libexpat-prefix[=DIR]  search for libexpat in DIR/include and DIR/lib
@@ -9931,6 +9935,53 @@ ac_config_files="$ac_config_files jit-reader.h:jit-reader.in"
 
 
 
+
+# Check whether --with-jit-reader-dir was given.
+if test "${with_jit_reader_dir+set}" = set; then :
+  withval=$with_jit_reader_dir;
+    JIT_READER_DIR=$withval
+else
+  JIT_READER_DIR=${libdir}/gdb
+fi
+
+
+  test "x$prefix" = xNONE && prefix="$ac_default_prefix"
+  test "x$exec_prefix" = xNONE && exec_prefix='${prefix}'
+  ac_define_dir=`eval echo $JIT_READER_DIR`
+  ac_define_dir=`eval echo $ac_define_dir`
+
+cat >>confdefs.h <<_ACEOF
+#define JIT_READER_DIR "$ac_define_dir"
+_ACEOF
+
+
+
+
+  if test "x$exec_prefix" = xNONE || test "x$exec_prefix" = 'x${prefix}'; then
+     if test "x$prefix" = xNONE; then
+     	test_prefix=/usr/local
+     else
+	test_prefix=$prefix
+     fi
+  else
+     test_prefix=$exec_prefix
+  fi
+  value=0
+  case ${ac_define_dir} in
+     "${test_prefix}"|"${test_prefix}/"*|\
+	'${exec_prefix}'|'${exec_prefix}/'*)
+     value=1
+     ;;
+  esac
+
+cat >>confdefs.h <<_ACEOF
+#define JIT_READER_DIR_RELOCATABLE $value
+_ACEOF
+
+
+
+
+
 # Check whether --with-expat was given.
 if test "${with_expat+set}" = set; then :
   withval=$with_expat;
diff --git a/gdb/configure.ac b/gdb/configure.ac
index abeb251..ee73e9b 100644
--- a/gdb/configure.ac
+++ b/gdb/configure.ac
@@ -595,6 +595,10 @@ fi
 AC_SUBST(TARGET_PTR)
 AC_CONFIG_FILES([jit-reader.h:jit-reader.in])
 
+GDB_AC_WITH_DIR([JIT_READER_DIR], [jit-reader-dir],
+                [directory to load the JIT readers from],
+                [${libdir}/gdb])
+
 AC_ARG_WITH(expat,
   AS_HELP_STRING([--with-expat], [include expat support (auto/yes/no)]),
   [], [with_expat=auto])
diff --git a/gdb/jit.c b/gdb/jit.c
index e3bb81a..cab27a9 100644
--- a/gdb/jit.c
+++ b/gdb/jit.c
@@ -33,6 +33,8 @@
 #include "target.h"
 #include "gdb_stat.h"
 
+static const char *jit_reader_dir = NULL;
+
 static const struct objfile_data *jit_objfile_data;
 
 static const char *const jit_break_name = "__jit_debug_register_code";
@@ -548,6 +550,8 @@ extern void _initialize_jit (void);
 void
 _initialize_jit (void)
 {
+  jit_reader_dir = relocate_gdb_directory (JIT_READER_DIR,
+                                           JIT_READER_DIR_RELOCATABLE);
   add_setshow_zinteger_cmd ("jit", class_maintenance, &jit_debug,
 			    _("Set JIT debugging."),
 			    _("Show JIT debugging."),
-- 
1.7.5.4


  parent reply	other threads:[~2011-08-24 18:57 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-08-24 18:57 JIT Debug Info Reader (re-roll) Sanjoy Das
2011-08-24 18:57 ` [PATCH 5/7] Use the loaded reader Sanjoy Das
2011-08-24 18:57 ` [PATCH 3/7] Platform agnostic dynamic loading code Sanjoy Das
2011-08-29 10:03   ` Pedro Alves
2011-08-29 12:54     ` Sanjoy Das
2011-08-29 14:22       ` Pedro Alves
2011-08-30  6:01         ` Sanjoy Das
2011-08-30 18:40           ` Tom Tromey
2011-08-24 18:57 ` [PATCH 1/7] Introduce jit-reader.in and modify build system Sanjoy Das
2011-08-24 18:57 ` [PATCH 4/7] New commands for loading and unloading a reader Sanjoy Das
2011-08-24 18:57 ` Sanjoy Das [this message]
2011-08-24 18:57 ` [PATCH 6/7] New JIT unwinder Sanjoy Das
2011-08-24 19:04   ` Jan Kratochvil
2011-08-24 19:08     ` Sanjoy Das
2011-08-24 18:57 ` [PATCH 7/7] Documentation Sanjoy Das
2011-08-24 20:14   ` Eli Zaretskii
2011-08-27 13:08 JIT Debug Info Reader Sanjoy Das
2011-08-27 13:08 ` [PATCH 2/7] Relocatable directory for loading JIT readers Sanjoy Das
2011-08-27 13:08 [PATCH 6/7] New JIT unwinder Sanjoy Das
     [not found] ` <1314518609-10204-1-git-send-email-sanjoy@playingwithpointers.com>
2011-08-28  8:05   ` [PATCH 2/7] Relocatable directory for loading JIT readers Sanjoy Das
2011-08-30 18:32     ` Tom Tromey
2011-08-31  3:31 JIT Reader (re-roll) Sanjoy Das
2011-08-31  3:31 ` [PATCH 2/7] Relocatable directory for loading JIT readers Sanjoy Das

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=1314212467-7391-3-git-send-email-sanjoy@playingwithpointers.com \
    --to=sanjoy@playingwithpointers.com \
    --cc=gdb-patches@sourceware.org \
    /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