public inbox for archer-commits@sourceware.org
help / color / mirror / Atom feed
* [SCM]  tromey/python: Revert "Remove ensure_python_env"
@ 2017-02-07 19:15 jkratoch
  0 siblings, 0 replies; only message in thread
From: jkratoch @ 2017-02-07 19:15 UTC (permalink / raw)
  To: archer-commits

The branch, tromey/python has been updated
       via  ae0822a1c85201c8e1660ef075a655850833c62c (commit)
       via  c8318cac9884ca911a40f3ab9250d35741b9da14 (commit)
      from  f6f480d42ff823a5c5775b24a9462144768b2abb (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email.

- Log -----------------------------------------------------------------
commit ae0822a1c85201c8e1660ef075a655850833c62c
Author: Jan Kratochvil <jan.kratochvil@redhat.com>
Date:   Tue Feb 7 20:13:16 2017 +0100

    Revert "Remove ensure_python_env"
    
    This reverts commit 17a22718b113a220de121ef4211fc3990d9b1745.

commit c8318cac9884ca911a40f3ab9250d35741b9da14
Author: Jan Kratochvil <jan.kratochvil@redhat.com>
Date:   Tue Feb 7 20:13:06 2017 +0100

    archer-tromey-python port

-----------------------------------------------------------------------

Summary of changes:
 gdb/main.c                   |   18 +++++++++---------
 gdb/python/python-internal.h |    3 +++
 gdb/python/python.c          |   25 ++++++++++++++++++++++++-
 gdb/varobj.c                 |    8 ++++++++
 gdb/varobj.h                 |    2 ++
 5 files changed, 46 insertions(+), 10 deletions(-)

First 500 lines of diff:
diff --git a/gdb/main.c b/gdb/main.c
index 667deb0..67f43e1 100644
--- a/gdb/main.c
+++ b/gdb/main.c
@@ -1165,14 +1165,6 @@ captured_main_1 (struct captured_main_args *context)
       /* We have hit the end of the batch file.  */
       quit_force (NULL, 0);
     }
-}
-
-static void
-captured_main (void *data)
-{
-  struct captured_main_args *context = (struct captured_main_args *) data;
-
-  captured_main_1 (context);
 
 #if HAVE_PYTHON
   if (python_script)
@@ -1180,7 +1172,7 @@ captured_main (void *data)
       extern int pagination_enabled;
       pagination_enabled = 0;
       run_python_script (argc - optind, &argv[optind]);
-      return 1;
+      return;
     }
   else
 #endif
@@ -1197,6 +1189,14 @@ captured_main (void *data)
   /* No exit -- exit is through quit_command.  */
 }
 
+static void
+captured_main (void *data)
+{
+  struct captured_main_args *context = (struct captured_main_args *) data;
+
+  captured_main_1 (context);
+}
+
 int
 gdb_main (struct captured_main_args *args)
 {
diff --git a/gdb/python/python-internal.h b/gdb/python/python-internal.h
index e2ebc1b..d3baba6 100644
--- a/gdb/python/python-internal.h
+++ b/gdb/python/python-internal.h
@@ -542,6 +542,9 @@ class gdbpy_enter_varobj : public gdbpy_enter
 
 };
 
+struct cleanup *ensure_python_env (struct gdbarch *gdbarch,
+				   const struct language_defn *language);
+
 extern struct gdbarch *python_gdbarch;
 extern const struct language_defn *python_language;
 
diff --git a/gdb/python/python.c b/gdb/python/python.c
index 69a72c0..77eed71 100644
--- a/gdb/python/python.c
+++ b/gdb/python/python.c
@@ -243,6 +243,29 @@ gdbpy_enter::~gdbpy_enter ()
   restore_active_ext_lang (m_previous_active);
 }
 
+static void
+restore_python_env (void *p)
+{
+  gdbpy_enter *env = (gdbpy_enter *) p;
+
+  delete env;
+}
+
+/* Called before entering the Python interpreter to install the
+   current language and architecture to be used for Python values.
+   Also set the active extension language for GDB so that SIGINT's
+   are directed our way, and if necessary install the right SIGINT
+   handler.  */
+
+struct cleanup *
+ensure_python_env (struct gdbarch *gdbarch,
+                   const struct language_defn *language)
+{
+  gdbpy_enter *env = new gdbpy_enter (gdbarch, language);
+
+  return make_cleanup (restore_python_env, env);
+}
+
 /* Set the quit flag.  */
 
 static void
@@ -1203,7 +1226,7 @@ gdbpy_cli (PyObject *unused1, PyObject *unused2)
   if (! running_python_script || in_cli)
     return PyErr_Format (PyExc_RuntimeError, "cannot invoke CLI recursively");
   
-  if (ui_out_is_mi_like_p (current_uiout))
+  if (current_uiout->is_mi_like_p ())
     return PyErr_Format (PyExc_RuntimeError, _("Cannot invoke CLI from MI."));
 
   in_cli = 1;
diff --git a/gdb/varobj.c b/gdb/varobj.c
index 3b2771f..c802ef7 100644
--- a/gdb/varobj.c
+++ b/gdb/varobj.c
@@ -226,6 +226,14 @@ is_root_p (const struct varobj *var)
 }
 
 #ifdef HAVE_PYTHON
+/* Helper function to install a Python environment suitable for
+   use during operations on VAR.  */
+struct cleanup *
+varobj_ensure_python_env (const struct varobj *var)
+{
+  return ensure_python_env (var->root->exp->gdbarch,
+			    var->root->exp->language_defn);
+}
 
 /* See python-internal.h.  */
 gdbpy_enter_varobj::gdbpy_enter_varobj (const struct varobj *var)
diff --git a/gdb/varobj.h b/gdb/varobj.h
index 989c8cd..fc7f177 100644
--- a/gdb/varobj.h
+++ b/gdb/varobj.h
@@ -320,6 +320,8 @@ extern int varobj_has_more (const struct varobj *var, int to);
 
 extern int varobj_is_dynamic_p (const struct varobj *var);
 
+extern struct cleanup *varobj_ensure_python_env (const struct varobj *var);
+
 extern int varobj_default_value_is_changeable_p (const struct varobj *var);
 extern int varobj_value_is_changeable_p (const struct varobj *var);
 


hooks/post-receive
--
Repository for Project Archer.


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2017-02-07 19:15 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-02-07 19:15 [SCM] tromey/python: Revert "Remove ensure_python_env" jkratoch

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).