This is the mail archive of the gdb-cvs@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[binutils-gdb] Add objfile-progspace to Guile interface


https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=85642ba08c459bb2f9d1e7beffa1871c9a93ca66

commit 85642ba08c459bb2f9d1e7beffa1871c9a93ca66
Author: Andy Wingo <wingo@igalia.com>
Date:   Wed Mar 11 14:20:06 2015 +0100

    Add objfile-progspace to Guile interface
    
    This commit adds an objfile-progspace accessor to the (gdb) Guile
    module.
    
    gdb/testsuite/ChangeLog:
    
    	* gdb.guile/scm-objfile.exp: Add objfile-progspace test.
    
    gdb/doc/ChangeLog:
    
    	* guile.texi (Objfiles In Guile): Document objfile-progspace.
    
    gdb/ChangeLog:
    
    	* guile/scm-objfile.c (gdbscm_objfile_progspace): New function.
    	(objfile_functions): Bind gdbscm_objfile_progspace to
    	objfile-progspace.
    	* guile/lib/gdb.scm: Add objfile-progspace to exports.

Diff:
---
 gdb/ChangeLog                           |  7 +++++++
 gdb/doc/ChangeLog                       |  4 ++++
 gdb/doc/guile.texi                      |  5 +++++
 gdb/guile/lib/gdb.scm                   |  1 +
 gdb/guile/scm-objfile.c                 | 17 +++++++++++++++++
 gdb/testsuite/ChangeLog                 |  4 ++++
 gdb/testsuite/gdb.guile/scm-objfile.exp |  3 +++
 7 files changed, 41 insertions(+)

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 4a943f9..38d3005 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,12 @@
 2015-03-11  Andy Wingo  <wingo@igalia.com>
 
+	* guile/scm-objfile.c (gdbscm_objfile_progspace): New function.
+	(objfile_functions): Bind gdbscm_objfile_progspace to
+	objfile-progspace.
+	* guile/lib/gdb.scm: Add objfile-progspace to exports.
+
+2015-03-11  Andy Wingo  <wingo@igalia.com>
+
 	* guile/guile.c (_initialize_guile): Disable automatic
 	finalization, if Guile offers us that possibility.
 	* guile/guile.c (call_initialize_gdb_module):
diff --git a/gdb/doc/ChangeLog b/gdb/doc/ChangeLog
index 92d1d45..0a1db36 100644
--- a/gdb/doc/ChangeLog
+++ b/gdb/doc/ChangeLog
@@ -1,3 +1,7 @@
+2015-03-11  Andy Wingo  <wingo@igalia.com>
+
+	* guile.texi (Objfiles In Guile): Document objfile-progspace.
+
 2015-03-04  Pedro Alves  <palves@redhat.com>
 
 	* gdb.texinfo (Remote Configuration): Document the "set/show
diff --git a/gdb/doc/guile.texi b/gdb/doc/guile.texi
index 53e69f2..4a4365c 100644
--- a/gdb/doc/guile.texi
+++ b/gdb/doc/guile.texi
@@ -2250,6 +2250,11 @@ Return the file name of @var{objfile} as a string,
 with symbolic links resolved.
 @end deffn
 
+@deffn {Scheme Procedure} objfile-progspace objfile
+Return the @code{<gdb:progspace>} that this object file lives in.
+@xref{Progspaces In Guile}, for more on progspaces.
+@end deffn
+
 @deffn {Scheme Procedure} objfile-pretty-printers objfile
 Return the list of registered @code{<gdb:pretty-printer>} objects for
 @var{objfile}.  @xref{Guile Pretty Printing API}, for more information.
diff --git a/gdb/guile/lib/gdb.scm b/gdb/guile/lib/gdb.scm
index e95914a..8f238be 100644
--- a/gdb/guile/lib/gdb.scm
+++ b/gdb/guile/lib/gdb.scm
@@ -271,6 +271,7 @@
  objfile?
  objfile-valid?
  objfile-filename
+ objfile-progspace
  objfile-pretty-printers
  set-objfile-pretty-printers!
  current-objfile
diff --git a/gdb/guile/scm-objfile.c b/gdb/guile/scm-objfile.c
index 8e94b96..080b905 100644
--- a/gdb/guile/scm-objfile.c
+++ b/gdb/guile/scm-objfile.c
@@ -252,6 +252,19 @@ gdbscm_objfile_filename (SCM self)
   return gdbscm_scm_from_c_string (objfile_name (o_smob->objfile));
 }
 
+/* (objfile-progspace <gdb:objfile>) -> <gdb:progspace>
+   Returns the objfile's progspace.
+   Throw's an exception if the underlying objfile is invalid.  */
+
+static SCM
+gdbscm_objfile_progspace (SCM self)
+{
+  objfile_smob *o_smob
+    = ofscm_get_valid_objfile_smob_arg_unsafe (self, SCM_ARG1, FUNC_NAME);
+
+  return psscm_scm_from_pspace (o_smob->objfile->pspace);
+}
+
 /* (objfile-pretty-printers <gdb:objfile>) -> list
    Returns the list of pretty-printers for this objfile.  */
 
@@ -388,6 +401,10 @@ Return #t if the objfile is valid (hasn't been deleted from gdb)." },
     "\
 Return the file name of the objfile." },
 
+  { "objfile-progspace", 1, 0, 0, gdbscm_objfile_progspace,
+    "\
+Return the progspace that the objfile lives in." },
+
   { "objfile-pretty-printers", 1, 0, 0, gdbscm_objfile_pretty_printers,
     "\
 Return a list of pretty-printers of the objfile." },
diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
index 6497aa9..76dcde5 100644
--- a/gdb/testsuite/ChangeLog
+++ b/gdb/testsuite/ChangeLog
@@ -1,3 +1,7 @@
+2015-03-11  Andy Wingo  <wingo@igalia.com>
+
+	* gdb.guile/scm-objfile.exp: Add objfile-progspace test.
+
 2015-03-11  Yao Qi  <yao.qi@linaro.org>
 
 	* gdb.base/catch-syscall.exp: Fix typo in comments.
diff --git a/gdb/testsuite/gdb.guile/scm-objfile.exp b/gdb/testsuite/gdb.guile/scm-objfile.exp
index c58f4c4..8edda94 100644
--- a/gdb/testsuite/gdb.guile/scm-objfile.exp
+++ b/gdb/testsuite/gdb.guile/scm-objfile.exp
@@ -48,6 +48,9 @@ gdb_test "gu (print (->bool (or-map (lambda (o) (string-contains (objfile-filena
 gdb_test "gu (print (objfile-pretty-printers objfile))" \
     "= \\(\\)"
 
+gdb_test "gu (print (eq? (current-progspace) (objfile-progspace objfile)))" \
+    "= #t"
+
 gdb_test "guile (set-objfile-pretty-printers! objfile 0)" \
     "ERROR: .*: Wrong type argument in position 2 \\(expecting list\\): 0.*"


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]