[gdb/f14/master] * Sat Aug 7 2010 Jan Kratochvil <jan.kratochvil at redhat.com> - 7.1.90.20100806-9.fc14 - Fix python g
Jan Kratochvil
jkratoch at fedoraproject.org
Sat Aug 7 15:34:30 UTC 2010
commit a8ba821c57bdb8381233369c7e5821168692c69d
Author: Jan Kratochvil <jan.kratochvil at redhat.com>
Date: Sat Aug 7 17:34:15 2010 +0200
* Sat Aug 7 2010 Jan Kratochvil <jan.kratochvil at redhat.com> - 7.1.90.20100806-9.fc14
- Fix python gdb.execute to_string pagination (BZ 620930).
gdb-upstream.patch | 380 ++++++++++++++++++++++++++++++++++++++++++++++++++++
gdb.spec | 9 +-
2 files changed, 386 insertions(+), 3 deletions(-)
---
diff --git a/gdb-upstream.patch b/gdb-upstream.patch
new file mode 100644
index 0000000..fa26730
--- /dev/null
+++ b/gdb-upstream.patch
@@ -0,0 +1,380 @@
+https://bugzilla.redhat.com/show_bug.cgi?id=620930
+
+http://sourceware.org/ml/gdb-cvs/2010-08/msg00031.html
+
+### src/gdb/ChangeLog 2010/08/06 19:45:58 1.12064
+### src/gdb/ChangeLog 2010/08/07 15:00:36 1.12065
+## -1,3 +1,22 @@
++2010-08-07 Jan Kratochvil <jan.kratochvil at redhat.com>
++
++ * defs.h (make_cleanup_restore_uinteger, make_cleanup_restore_ui_file)
++ (make_cleanup_restore_page_info)
++ (set_batch_flag_and_make_cleanup_restore_page_info): New declarations.
++ * gdbcmd.h (execute_command_to_string): New declaration.
++ * python/python.c (struct restore_ui_file_closure, restore_ui_file)
++ (make_cleanup_restore_ui_file): Move to utils.c
++ (execute_gdb_command) <to_string>: Move ...
++ * top.c (execute_command_to_string): ... here. Call
++ set_batch_flag_and_make_cleanup_restore_page_info.
++ * utils.c (make_cleanup_restore_integer): New source file blank line.
++ (make_cleanup_restore_uinteger): New.
++ (struct restore_ui_file_closure, do_restore_ui_file)
++ (make_cleanup_restore_ui_file): Move here from python/python.c.
++ (init_page_info) <batch_flag>
++ (do_restore_page_info_cleanup, make_cleanup_restore_page_info)
++ (set_batch_flag_and_make_cleanup_restore_page_info): New.
++
+ 2010-08-06 Maciej W. Rozycki <macro at codesourcery.com>
+
+ * thread.c (add_thread_silent): Use null_ptid instead of
+### src/gdb/testsuite/ChangeLog 2010/08/02 23:41:18 1.2405
+### src/gdb/testsuite/ChangeLog 2010/08/07 15:00:38 1.2406
+## -1,3 +1,10 @@
++2010-08-07 Jan Kratochvil <jan.kratochvil at redhat.com>
++
++ * gdb.python/python.exp (show height, set height 10)
++ (verify pagination beforehand, verify pagination beforehand: q)
++ (gdb.execute does not page, verify pagination afterwards)
++ (verify pagination afterwards: q): New.
++
+ 2010-08-02 Doug Evans <dje at google.com>
+
+ * gdb.cp/namespace.exp: When "print ::cOtherFileClassVar" fails
+### src/gdb/doc/ChangeLog 2010/07/31 15:34:41 1.1093
+### src/gdb/doc/ChangeLog 2010/08/07 15:00:38 1.1094
+## -1,3 +1,9 @@
++2010-08-07 Jan Kratochvil <jan.kratochvil at redhat.com>
++ Eli Zaretskii <eliz at gnu.org>
++
++ * gdb.texinfo (Mode Options) <-batch>
++ (Basic Python) <gdb.execute>: Describe setting width and height.
++
+ 2010-07-31 Paul Pluzhnikov <ppluzhnikov at google.com>
+
+ * gdb.texinfo (Threads): Document 'debug libthread-db'.
+Index: gdb-7.1.90.20100806/gdb/defs.h
+===================================================================
+--- gdb-7.1.90.20100806.orig/gdb/defs.h 2010-08-07 17:18:27.000000000 +0200
++++ gdb-7.1.90.20100806/gdb/defs.h 2010-08-07 17:18:31.000000000 +0200
+@@ -351,6 +351,10 @@ struct obstack;
+ extern struct cleanup *make_cleanup_obstack_free (struct obstack *obstack);
+
+ extern struct cleanup *make_cleanup_restore_integer (int *variable);
++extern struct cleanup *make_cleanup_restore_uinteger (unsigned int *variable);
++
++extern struct cleanup *
++ make_cleanup_restore_ui_file (struct ui_file **variable);
+
+ extern struct cleanup *make_final_cleanup (make_cleanup_ftype *, void *);
+
+@@ -383,6 +387,10 @@ extern int yquery (const char *, ...) AT
+
+ extern void init_page_info (void);
+
++extern struct cleanup *make_cleanup_restore_page_info (void);
++extern struct cleanup *
++ set_batch_flag_and_make_cleanup_restore_page_info (void);
++
+ extern char *gdb_realpath (const char *);
+ extern char *xfullpath (const char *);
+
+Index: gdb-7.1.90.20100806/gdb/gdbcmd.h
+===================================================================
+--- gdb-7.1.90.20100806.orig/gdb/gdbcmd.h 2010-08-07 17:18:27.000000000 +0200
++++ gdb-7.1.90.20100806/gdb/gdbcmd.h 2010-08-07 17:18:40.000000000 +0200
+@@ -128,6 +128,8 @@ extern void execute_command (char *, int
+
+ enum command_control_type execute_control_command (struct command_line *);
+
++extern char *execute_command_to_string (char *p, int from_tty);
++
+ extern void print_command_line (struct command_line *, unsigned int,
+ struct ui_file *);
+ extern void print_command_lines (struct ui_out *,
+Index: gdb-7.1.90.20100806/gdb/top.c
+===================================================================
+--- gdb-7.1.90.20100806.orig/gdb/top.c 2010-08-07 17:18:27.000000000 +0200
++++ gdb-7.1.90.20100806/gdb/top.c 2010-08-07 17:18:31.000000000 +0200
+@@ -458,6 +458,39 @@ execute_command (char *p, int from_tty)
+ }
+ }
+
++/* Run execute_command for P and FROM_TTY. Capture its output into the
++ returned string, do not display it to the screen. BATCH_FLAG will be
++ temporarily set to true. */
++
++char *
++execute_command_to_string (char *p, int from_tty)
++{
++ struct ui_file *str_file;
++ struct cleanup *cleanup;
++ char *retval;
++
++ /* GDB_STDOUT should be better already restored during these
++ restoration callbacks. */
++ cleanup = set_batch_flag_and_make_cleanup_restore_page_info ();
++
++ str_file = mem_fileopen ();
++
++ make_cleanup_restore_ui_file (&gdb_stdout);
++ make_cleanup_restore_ui_file (&gdb_stderr);
++ make_cleanup_ui_file_delete (str_file);
++
++ gdb_stdout = str_file;
++ gdb_stderr = str_file;
++
++ execute_command (p, from_tty);
++
++ retval = ui_file_xstrdup (str_file, NULL);
++
++ do_cleanups (cleanup);
++
++ return retval;
++}
++
+ /* Read commands from `instream' and execute them
+ until end of file or error reading instream. */
+
+Index: gdb-7.1.90.20100806/gdb/utils.c
+===================================================================
+--- gdb-7.1.90.20100806.orig/gdb/utils.c 2010-08-07 17:18:27.000000000 +0200
++++ gdb-7.1.90.20100806/gdb/utils.c 2010-08-07 17:18:31.000000000 +0200
+@@ -339,6 +339,7 @@ restore_integer (void *p)
+
+ /* Remember the current value of *VARIABLE and make it restored when the cleanup
+ is run. */
++
+ struct cleanup *
+ make_cleanup_restore_integer (int *variable)
+ {
+@@ -352,6 +353,43 @@ make_cleanup_restore_integer (int *varia
+ xfree);
+ }
+
++/* Remember the current value of *VARIABLE and make it restored when the cleanup
++ is run. */
++
++struct cleanup *
++make_cleanup_restore_uinteger (unsigned int *variable)
++{
++ return make_cleanup_restore_integer ((int *) variable);
++}
++
++struct restore_ui_file_closure
++{
++ struct ui_file **variable;
++ struct ui_file *value;
++};
++
++static void
++do_restore_ui_file (void *p)
++{
++ struct restore_ui_file_closure *closure = p;
++
++ *(closure->variable) = closure->value;
++}
++
++/* Remember the current value of *VARIABLE and make it restored when
++ the cleanup is run. */
++
++struct cleanup *
++make_cleanup_restore_ui_file (struct ui_file **variable)
++{
++ struct restore_ui_file_closure *c = XNEW (struct restore_ui_file_closure);
++
++ c->variable = variable;
++ c->value = *variable;
++
++ return make_cleanup_dtor (do_restore_ui_file, (void *) c, xfree);
++}
++
+ struct cleanup *
+ make_my_cleanup2 (struct cleanup **pmy_chain, make_cleanup_ftype *function,
+ void *arg, void (*free_arg) (void *))
+@@ -2034,6 +2072,12 @@ static int wrap_column;
+ void
+ init_page_info (void)
+ {
++ if (batch_flag)
++ {
++ lines_per_page = UINT_MAX;
++ chars_per_line = UINT_MAX;
++ }
++ else
+ #if defined(TUI)
+ if (!tui_get_command_dimension (&chars_per_line, &lines_per_page))
+ #endif
+@@ -2078,6 +2122,44 @@ init_page_info (void)
+ set_width ();
+ }
+
++/* Helper for make_cleanup_restore_page_info. */
++
++static void
++do_restore_page_info_cleanup (void *arg)
++{
++ set_screen_size ();
++ set_width ();
++}
++
++/* Provide cleanup for restoring the terminal size. */
++
++struct cleanup *
++make_cleanup_restore_page_info (void)
++{
++ struct cleanup *back_to;
++
++ back_to = make_cleanup (do_restore_page_info_cleanup, NULL);
++ make_cleanup_restore_uinteger (&lines_per_page);
++ make_cleanup_restore_uinteger (&chars_per_line);
++
++ return back_to;
++}
++
++/* Temporarily set BATCH_FLAG and the associated unlimited terminal size.
++ Provide cleanup for restoring the original state. */
++
++struct cleanup *
++set_batch_flag_and_make_cleanup_restore_page_info (void)
++{
++ struct cleanup *back_to = make_cleanup_restore_page_info ();
++
++ make_cleanup_restore_integer (&batch_flag);
++ batch_flag = 1;
++ init_page_info ();
++
++ return back_to;
++}
++
+ /* Set the screen size based on LINES_PER_PAGE and CHARS_PER_LINE. */
+
+ static void
+Index: gdb-7.1.90.20100806/gdb/doc/gdb.texinfo
+===================================================================
+--- gdb-7.1.90.20100806.orig/gdb/doc/gdb.texinfo 2010-08-07 17:18:27.000000000 +0200
++++ gdb-7.1.90.20100806/gdb/doc/gdb.texinfo 2010-08-07 17:18:31.000000000 +0200
+@@ -1031,9 +1031,9 @@ Run in batch mode. Exit with status @co
+ command files specified with @samp{-x} (and all commands from
+ initialization files, if not inhibited with @samp{-n}). Exit with
+ nonzero status if an error occurs in executing the @value{GDBN} commands
+-in the command files. Batch mode also disables pagination;
+- at pxref{Screen Size} and acts as if @kbd{set confirm off} were in
+-effect (@pxref{Messages/Warnings}).
++in the command files. Batch mode also disables pagination, sets unlimited
++terminal width and height @pxref{Screen Size}, and acts as if @kbd{set confirm
++off} were in effect (@pxref{Messages/Warnings}).
+
+ Batch mode may be useful for running @value{GDBN} as a filter, for
+ example to download and run a program on another computer; in order to
+@@ -20432,7 +20432,9 @@ By default, any output produced by @var{
+ @value{GDBN}'s standard output. If the @var{to_string} parameter is
+ @code{True}, then output will be collected by @code{gdb.execute} and
+ returned as a string. The default is @code{False}, in which case the
+-return value is @code{None}.
++return value is @code{None}. If @var{to_string} is @code{True}, the
++ at value{GDBN} virtual terminal will be temporarily set to unlimited width
++and height, and its pagination will be disabled; @pxref{Screen Size}.
+ @end defun
+
+ @findex gdb.breakpoints
+Index: gdb-7.1.90.20100806/gdb/python/python.c
+===================================================================
+--- gdb-7.1.90.20100806.orig/gdb/python/python.c 2010-08-07 17:18:27.000000000 +0200
++++ gdb-7.1.90.20100806/gdb/python/python.c 2010-08-07 17:18:31.000000000 +0200
+@@ -309,33 +309,6 @@ gdbpy_target_wide_charset (PyObject *sel
+ return PyUnicode_Decode (cset, strlen (cset), host_charset (), NULL);
+ }
+
+-struct restore_ui_file_closure
+-{
+- struct ui_file **variable;
+- struct ui_file *value;
+-};
+-
+-static void
+-restore_ui_file (void *p)
+-{
+- struct restore_ui_file_closure *closure = p;
+-
+- *(closure->variable) = closure->value;
+-}
+-
+-/* Remember the current value of *VARIABLE and make it restored when
+- the cleanup is run. */
+-struct cleanup *
+-make_cleanup_restore_ui_file (struct ui_file **variable)
+-{
+- struct restore_ui_file_closure *c = XNEW (struct restore_ui_file_closure);
+-
+- c->variable = variable;
+- c->value = *variable;
+-
+- return make_cleanup_dtor (restore_ui_file, (void *) c, xfree);
+-}
+-
+ /* A Python function which evaluates a string using the gdb CLI. */
+
+ static PyObject *
+@@ -376,27 +349,15 @@ execute_gdb_command (PyObject *self, PyO
+ /* Copy the argument text in case the command modifies it. */
+ char *copy = xstrdup (arg);
+ struct cleanup *cleanup = make_cleanup (xfree, copy);
+- struct ui_file *str_file = NULL;
+
+ if (to_string)
++ result = execute_command_to_string (copy, from_tty);
++ else
+ {
+- str_file = mem_fileopen ();
+-
+- make_cleanup_restore_ui_file (&gdb_stdout);
+- make_cleanup_restore_ui_file (&gdb_stderr);
+- make_cleanup_ui_file_delete (str_file);
+-
+- gdb_stdout = str_file;
+- gdb_stderr = str_file;
++ result = NULL;
++ execute_command (copy, from_tty);
+ }
+
+- execute_command (copy, from_tty);
+-
+- if (str_file)
+- result = ui_file_xstrdup (str_file, NULL);
+- else
+- result = NULL;
+-
+ do_cleanups (cleanup);
+ }
+ GDB_PY_HANDLE_EXCEPTION (except);
+Index: gdb-7.1.90.20100806/gdb/testsuite/gdb.python/python.exp
+===================================================================
+--- gdb-7.1.90.20100806.orig/gdb/testsuite/gdb.python/python.exp 2010-08-07 17:18:27.000000000 +0200
++++ gdb-7.1.90.20100806/gdb/testsuite/gdb.python/python.exp 2010-08-07 17:18:31.000000000 +0200
+@@ -87,3 +87,26 @@ gdb_test "python import itertools; print
+ gdb_test_no_output \
+ "python x = gdb.execute('printf \"%d\", 23', to_string = True)"
+ gdb_test "python print x" "23"
++
++# Test (no) pagination of the executed command.
++gdb_test "show height" {Number of lines gdb thinks are in a page is unlimited\.}
++set lines 10
++gdb_test_no_output "set height $lines"
++
++set test "verify pagination beforehand"
++gdb_test_multiple "python print \"\\n\" * $lines" $test {
++ -re "---Type <return> to continue, or q <return> to quit---$" {
++ pass $test
++ }
++}
++gdb_test "q" "Quit" "verify pagination beforehand: q"
++
++gdb_test "python if gdb.execute('python print \"\\\\n\" * $lines', to_string=True) == \"\\n\" * [expr $lines + 1]: print \"yes\"" "yes" "gdb.execute does not page"
++
++set test "verify pagination afterwards"
++gdb_test_multiple "python print \"\\n\" * $lines" $test {
++ -re "---Type <return> to continue, or q <return> to quit---$" {
++ pass $test
++ }
++}
++gdb_test "q" "Quit" "verify pagination afterwards: q"
diff --git a/gdb.spec b/gdb.spec
index 4d1ab6b..76269b2 100644
--- a/gdb.spec
+++ b/gdb.spec
@@ -36,7 +36,7 @@ Version: 7.1.90.20100806
# The release always contains a leading reserved number, start it at 1.
# `upstream' is not a part of `name' to stay fully rpm dependencies compatible for the testing.
-Release: 8%{?_with_upstream:.upstream}%{dist}
+Release: 9%{?_with_upstream:.upstream}%{dist}
License: GPLv3+ and GPLv3+ with exceptions and GPLv2+ and GPLv2+ with exceptions and GPL+ and LGPLv2+ and GFDL and BSD and Public Domain
Group: Development/Debuggers
@@ -226,7 +226,7 @@ Patch229: gdb-6.3-bz140532-ppc-unwinding-test.patch
Patch231: gdb-6.3-bz202689-exec-from-pthread-test.patch
# Backported fixups post the source tarball.
-#Patch232: gdb-upstream.patch
+Patch232: gdb-upstream.patch
# Testcase for PPC Power6/DFP instructions disassembly (BZ 230000).
Patch234: gdb-6.6-bz230000-power6-disassembly-test.patch
@@ -562,7 +562,7 @@ rm -f gdb/jv-exp.c gdb/m2-exp.c gdb/objc-exp.c gdb/p-exp.c
%if 0%{!?_with_upstream:1}
-#patch232 -p1
+%patch232 -p1
%patch349 -p1
%patch420 -p1
%patch1 -p1
@@ -1007,6 +1007,9 @@ fi
%endif
%changelog
+* Sat Aug 7 2010 Jan Kratochvil <jan.kratochvil at redhat.com> - 7.1.90.20100806-9.fc14
+- Fix python gdb.execute to_string pagination (BZ 620930).
+
* Fri Aug 6 2010 Jan Kratochvil <jan.kratochvil at redhat.com> - 7.1.90.20100806-8.fc14
- Out of memory is just an error, not fatal (uninitialized VLS vars, BZ 568248).
More information about the scm-commits
mailing list