public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Hannes Domani <ssbssa@yahoo.de>
To: gdb-patches@sourceware.org
Subject: [PATCH 18/22] Update the source location with Frame.select
Date: Sat,  6 Mar 2021 18:40:58 +0100	[thread overview]
Message-ID: <20210306174102.21597-9-ssbssa@yahoo.de> (raw)
In-Reply-To: <20210306174102.21597-1-ssbssa@yahoo.de>

If the optional argument is True, then the current source location is
also updated, the same as if 'frame #' were used.
With this, a following 'list' call will show the source location of the
current frame instead of the previous one, and the TUI source window is
also updated.

PR python/24534
---
 gdb/python/py-frame.c | 29 ++++++++++++++++++++++++++++-
 gdb/tui/tui-hooks.c   |  8 ++++++++
 gdb/tui/tui-hooks.h   |  2 ++
 3 files changed, 38 insertions(+), 1 deletion(-)

diff --git a/gdb/python/py-frame.c b/gdb/python/py-frame.c
index 8e32ba55de4..ef4eae1d745 100644
--- a/gdb/python/py-frame.c
+++ b/gdb/python/py-frame.c
@@ -28,6 +28,11 @@
 #include "symfile.h"
 #include "objfiles.h"
 
+#ifdef TUI
+#include "tui/tui.h"
+#include "tui/tui-hooks.h"
+#endif
+
 struct frame_object {
   PyObject_HEAD
   struct frame_id frame_id;
@@ -564,12 +569,34 @@ static PyObject *
 frapy_select (PyObject *self, PyObject *args)
 {
   struct frame_info *fi;
+  PyObject *update_sal_obj = NULL;
+
+  if (!PyArg_ParseTuple (args, "|O!", &PyBool_Type, &update_sal_obj))
+    return NULL;
+
+  int update_sal = 0;
+  if (update_sal_obj)
+    {
+      update_sal = PyObject_IsTrue (update_sal_obj);
+      if (update_sal < 0)
+	return NULL;
+    }
 
   try
     {
       FRAPY_REQUIRE_VALID (self, fi);
 
       select_frame (fi);
+
+      if (update_sal)
+	{
+	  set_current_sal_from_frame (fi);
+
+#ifdef TUI
+	  if (tui_active)
+	    tui_frame_changed ();
+#endif
+	}
     }
   catch (const gdb_exception &except)
     {
@@ -748,7 +775,7 @@ Return the frame's symtab and line." },
   { "read_var", frapy_read_var, METH_VARARGS,
     "read_var (variable) -> gdb.Value.\n\
 Return the value of the variable in this frame." },
-  { "select", frapy_select, METH_NOARGS,
+  { "select", frapy_select, METH_VARARGS,
     "Select this frame as the user's current frame." },
   {NULL}  /* Sentinel */
 };
diff --git a/gdb/tui/tui-hooks.c b/gdb/tui/tui-hooks.c
index 2d7660acade..fa8f63e1146 100644
--- a/gdb/tui/tui-hooks.c
+++ b/gdb/tui/tui-hooks.c
@@ -187,6 +187,14 @@ tui_before_prompt (const char *current_gdb_prompt)
   from_source_symtab = false;
 }
 
+void
+tui_frame_changed (void)
+{
+  from_stack = true;
+  tui_refresh_frame_and_register_information ();
+  from_stack = false;
+}
+
 /* Observer for the normal_stop notification.  */
 
 static void
diff --git a/gdb/tui/tui-hooks.h b/gdb/tui/tui-hooks.h
index 11f8ef3d0d1..2ed2021cea6 100644
--- a/gdb/tui/tui-hooks.h
+++ b/gdb/tui/tui-hooks.h
@@ -20,6 +20,8 @@
 #ifndef TUI_TUI_HOOKS_H
 #define TUI_TUI_HOOKS_H
 
+extern void tui_frame_changed (void);
+
 extern void tui_install_hooks (void);
 extern void tui_remove_hooks (void);
 
-- 
2.30.1


  parent reply	other threads:[~2021-03-06 17:41 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20210306174102.21597-1-ssbssa.ref@yahoo.de>
2021-03-06 17:40 ` [PATCH 10/22] Add optional styled argument to gdb.execute Hannes Domani
2021-03-06 17:40   ` [PATCH 11/22] Use styled argument of gdb.execute() for cccw command Hannes Domani
2021-03-06 17:40   ` [PATCH 12/22] Add optional full_window argument to TuiWindow.write Hannes Domani
2021-03-06 18:13     ` Eli Zaretskii
2021-03-11 21:49     ` Tom Tromey
2021-03-06 17:40   ` [PATCH 13/22] Use the full_window argument of TuiWindow.write to prevent flickering Hannes Domani
2021-03-06 17:40   ` [PATCH 14/22] Add set_tui_auto_display python function Hannes Domani
2021-03-06 17:40   ` [PATCH 15/22] Disable automatic display while the display window is active Hannes Domani
2021-03-06 17:40   ` [PATCH 16/22] Show raw flag in info display Hannes Domani
2021-03-06 17:40   ` [PATCH 17/22] Use the raw flag of automatic display to disable pretty printers Hannes Domani
2021-03-11 21:47     ` Tom Tromey
2021-03-06 17:40   ` Hannes Domani [this message]
2021-03-11 21:53     ` [PATCH 18/22] Update the source location with Frame.select Tom Tromey
2021-03-06 17:40   ` [PATCH 19/22] Refresh the TUI source window when changing the frame in the frame window Hannes Domani
2021-03-06 18:13   ` [PATCH 10/22] Add optional styled argument to gdb.execute Eli Zaretskii
2021-03-08 10:01   ` Andrew Burgess

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=20210306174102.21597-9-ssbssa@yahoo.de \
    --to=ssbssa@yahoo.de \
    --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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).