This is the mail archive of the gdb-patches@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]

[RFA] Avoid infinite height for mingw GDB


  The mingw32 GDB debugger starts always with height set to infinite.

  This means that long outputs (long stack frame or long
list of functions) never pause, which is sometimes very annoying.

  Debugging GDB with itself, I found out that
after setting the height correctly inside int_page_info,
height was reset to infinite because a call to tgetnum ("li")
returns -1.
  This patch uses rl_get_screen_size (the function that
first sets height to the correct value) to 
return the correct answer for "li" and "co" parameters.
  The call is guarded using a static call level counter,
to avoid infinite recursion if GDB is not associated to a console
(because in that case no cal to GetConsoleScreenBufferInfo
can be made, which means that rl_get_screen_size
later tries to call tgetnum function.

Comments?


Pierre Muller
GDB pascal language maintainer



ChangeLog entry:

2012-10-17  Pierre Muller  <muller@ics.u-strasbg.fr>

        * windows-termcap.c (tgetent): Handle "li" and "co"
        parameter.

Index: src/gdb/windows-termcap.c
===================================================================
RCS file: /cvs/src/src/gdb/windows-termcap.c,v
retrieving revision 1.11
diff -u -p -r1.11 windows-termcap.c
--- src/gdb/windows-termcap.c   2 Mar 2012 12:56:50 -0000       1.11
+++ src/gdb/windows-termcap.c   16 Oct 2012 22:58:35 -0000
@@ -20,6 +20,9 @@
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/

 #include <stdlib.h>
+#include <strings.h>
+#include "defs.h"
+#include "readline/readline.h"

 /* -Wmissing-prototypes */
 extern int tgetent (char *buffer, char *termtype);
@@ -42,6 +45,26 @@ tgetent (char *buffer, char *termtype)
 int
 tgetnum (char *name)
 {
+  static int tgetnum_level = 0;
+  tgetnum_level++;
+  /* Avoid resetting of height to unlimited in init_page_info function.  */
+  if (((strcmp (name, "li") == 0) || (strcmp (name, "co") == 0))
+      && (tgetnum_level == 1))
+    {
+      int cols, lines;
+      /* This only works because __MINGW32__ specific code does not call
+         tgetnum function within rl_get_screen_size, if the current
+        output is a valid Windows console.
+         The values of COLS and LINES are set earlier inside that function
+         by a call to Windows API function GetConsoleScreenBufferInfo.  */
+      rl_get_screen_size (&cols, &lines);
+      tgetnum_level--;
+      if (strcmp (name, "li") == 0)
+       return lines;
+      else
+       return cols;
+    }
+  tgetnum_level--;
   return -1;
 }


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