xref: /dflybsd-src/contrib/gdb-7/gdb/tui/tui-source.c (revision de8e141f24382815c10a4012d209bbbf7abf1112)
15796c8dcSSimon Schubert /* TUI display source window.
25796c8dcSSimon Schubert 
3*ef5ccd6cSJohn Marino    Copyright (C) 1998-2013 Free Software Foundation, Inc.
45796c8dcSSimon Schubert 
55796c8dcSSimon Schubert    Contributed by Hewlett-Packard Company.
65796c8dcSSimon Schubert 
75796c8dcSSimon Schubert    This file is part of GDB.
85796c8dcSSimon Schubert 
95796c8dcSSimon Schubert    This program is free software; you can redistribute it and/or modify
105796c8dcSSimon Schubert    it under the terms of the GNU General Public License as published by
115796c8dcSSimon Schubert    the Free Software Foundation; either version 3 of the License, or
125796c8dcSSimon Schubert    (at your option) any later version.
135796c8dcSSimon Schubert 
145796c8dcSSimon Schubert    This program is distributed in the hope that it will be useful,
155796c8dcSSimon Schubert    but WITHOUT ANY WARRANTY; without even the implied warranty of
165796c8dcSSimon Schubert    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
175796c8dcSSimon Schubert    GNU General Public License for more details.
185796c8dcSSimon Schubert 
195796c8dcSSimon Schubert    You should have received a copy of the GNU General Public License
205796c8dcSSimon Schubert    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
215796c8dcSSimon Schubert 
225796c8dcSSimon Schubert #include "defs.h"
235796c8dcSSimon Schubert #include <ctype.h>
245796c8dcSSimon Schubert #include "symtab.h"
255796c8dcSSimon Schubert #include "frame.h"
265796c8dcSSimon Schubert #include "breakpoint.h"
275796c8dcSSimon Schubert #include "source.h"
285796c8dcSSimon Schubert #include "symtab.h"
295796c8dcSSimon Schubert #include "objfiles.h"
30c50c785cSJohn Marino #include "filenames.h"
315796c8dcSSimon Schubert 
325796c8dcSSimon Schubert #include "tui/tui.h"
335796c8dcSSimon Schubert #include "tui/tui-data.h"
345796c8dcSSimon Schubert #include "tui/tui-stack.h"
355796c8dcSSimon Schubert #include "tui/tui-winsource.h"
365796c8dcSSimon Schubert #include "tui/tui-source.h"
375796c8dcSSimon Schubert 
385796c8dcSSimon Schubert #include "gdb_string.h"
395796c8dcSSimon Schubert #include "gdb_curses.h"
405796c8dcSSimon Schubert 
415796c8dcSSimon Schubert /* Function to display source in the source window.  */
425796c8dcSSimon Schubert enum tui_status
tui_set_source_content(struct symtab * s,int line_no,int noerror)435796c8dcSSimon Schubert tui_set_source_content (struct symtab *s,
445796c8dcSSimon Schubert 			int line_no,
455796c8dcSSimon Schubert 			int noerror)
465796c8dcSSimon Schubert {
475796c8dcSSimon Schubert   enum tui_status ret = TUI_FAILURE;
485796c8dcSSimon Schubert 
49*ef5ccd6cSJohn Marino   if (s != (struct symtab *) NULL)
505796c8dcSSimon Schubert     {
515796c8dcSSimon Schubert       FILE *stream;
525796c8dcSSimon Schubert       int i, desc, c, line_width, nlines;
535796c8dcSSimon Schubert       char *src_line = 0;
545796c8dcSSimon Schubert 
555796c8dcSSimon Schubert       if ((ret = tui_alloc_source_buffer (TUI_SRC_WIN)) == TUI_SUCCESS)
565796c8dcSSimon Schubert 	{
575796c8dcSSimon Schubert 	  line_width = TUI_SRC_WIN->generic.width - 1;
585796c8dcSSimon Schubert 	  /* Take hilite (window border) into account, when
595796c8dcSSimon Schubert 	     calculating the number of lines.  */
605796c8dcSSimon Schubert 	  nlines = (line_no + (TUI_SRC_WIN->generic.height - 2)) - line_no;
615796c8dcSSimon Schubert 	  desc = open_source_file (s);
625796c8dcSSimon Schubert 	  if (desc < 0)
635796c8dcSSimon Schubert 	    {
645796c8dcSSimon Schubert 	      if (!noerror)
655796c8dcSSimon Schubert 		{
66*ef5ccd6cSJohn Marino 		  const char *filename = symtab_to_filename_for_display (s);
67*ef5ccd6cSJohn Marino 		  char *name = alloca (strlen (filename) + 100);
68cf7f2e2dSJohn Marino 
69*ef5ccd6cSJohn Marino 		  sprintf (name, "%s:%d", filename, line_no);
705796c8dcSSimon Schubert 		  print_sys_errmsg (name, errno);
715796c8dcSSimon Schubert 		}
725796c8dcSSimon Schubert 	      ret = TUI_FAILURE;
735796c8dcSSimon Schubert 	    }
745796c8dcSSimon Schubert 	  else
755796c8dcSSimon Schubert 	    {
765796c8dcSSimon Schubert 	      if (s->line_charpos == 0)
775796c8dcSSimon Schubert 		find_source_lines (s, desc);
785796c8dcSSimon Schubert 
795796c8dcSSimon Schubert 	      if (line_no < 1 || line_no > s->nlines)
805796c8dcSSimon Schubert 		{
815796c8dcSSimon Schubert 		  close (desc);
82*ef5ccd6cSJohn Marino 		  printf_unfiltered ("Line number %d out of range; "
83*ef5ccd6cSJohn Marino 				     "%s has %d lines.\n",
84*ef5ccd6cSJohn Marino 				     line_no,
85*ef5ccd6cSJohn Marino 				     symtab_to_filename_for_display (s),
86*ef5ccd6cSJohn Marino 				     s->nlines);
875796c8dcSSimon Schubert 		}
885796c8dcSSimon Schubert 	      else if (lseek (desc, s->line_charpos[line_no - 1], 0) < 0)
895796c8dcSSimon Schubert 		{
905796c8dcSSimon Schubert 		  close (desc);
91*ef5ccd6cSJohn Marino 		  perror_with_name (symtab_to_filename_for_display (s));
925796c8dcSSimon Schubert 		}
935796c8dcSSimon Schubert 	      else
945796c8dcSSimon Schubert 		{
955796c8dcSSimon Schubert 		  int offset, cur_line_no, cur_line, cur_len, threshold;
96c50c785cSJohn Marino 		  struct tui_gen_win_info *locator
97c50c785cSJohn Marino 		    = tui_locator_win_info_ptr ();
98c50c785cSJohn Marino                   struct tui_source_info *src
99c50c785cSJohn Marino 		    = &TUI_SRC_WIN->detail.source_info;
100*ef5ccd6cSJohn Marino 		  const char *s_filename = symtab_to_filename_for_display (s);
1015796c8dcSSimon Schubert 
1025796c8dcSSimon Schubert                   if (TUI_SRC_WIN->generic.title)
1035796c8dcSSimon Schubert                     xfree (TUI_SRC_WIN->generic.title);
104*ef5ccd6cSJohn Marino                   TUI_SRC_WIN->generic.title = xstrdup (s_filename);
1055796c8dcSSimon Schubert 
106*ef5ccd6cSJohn Marino 		  xfree (src->fullname);
107*ef5ccd6cSJohn Marino 		  src->fullname = xstrdup (symtab_to_fullname (s));
1085796c8dcSSimon Schubert 
1095796c8dcSSimon Schubert 		  /* Determine the threshold for the length of the
1105796c8dcSSimon Schubert                      line and the offset to start the display.  */
1115796c8dcSSimon Schubert 		  offset = src->horizontal_offset;
1125796c8dcSSimon Schubert 		  threshold = (line_width - 1) + offset;
1135796c8dcSSimon Schubert 		  stream = fdopen (desc, FOPEN_RT);
1145796c8dcSSimon Schubert 		  clearerr (stream);
1155796c8dcSSimon Schubert 		  cur_line = 0;
1165796c8dcSSimon Schubert 		  src->gdbarch = get_objfile_arch (s->objfile);
1175796c8dcSSimon Schubert 		  src->start_line_or_addr.loa = LOA_LINE;
1185796c8dcSSimon Schubert 		  cur_line_no = src->start_line_or_addr.u.line_no = line_no;
1195796c8dcSSimon Schubert 		  if (offset > 0)
1205796c8dcSSimon Schubert 		    src_line = (char *) xmalloc (
1215796c8dcSSimon Schubert 					   (threshold + 1) * sizeof (char));
1225796c8dcSSimon Schubert 		  while (cur_line < nlines)
1235796c8dcSSimon Schubert 		    {
124c50c785cSJohn Marino 		      struct tui_win_element *element
125c50c785cSJohn Marino 			= (struct tui_win_element *)
1265796c8dcSSimon Schubert 			TUI_SRC_WIN->generic.content[cur_line];
1275796c8dcSSimon Schubert 
1285796c8dcSSimon Schubert 		      /* Get the first character in the line.  */
1295796c8dcSSimon Schubert 		      c = fgetc (stream);
1305796c8dcSSimon Schubert 
1315796c8dcSSimon Schubert 		      if (offset == 0)
1325796c8dcSSimon Schubert 			src_line = ((struct tui_win_element *)
1335796c8dcSSimon Schubert 				   TUI_SRC_WIN->generic.content[
1345796c8dcSSimon Schubert 					cur_line])->which_element.source.line;
1355796c8dcSSimon Schubert 		      /* Init the line with the line number.  */
1365796c8dcSSimon Schubert 		      sprintf (src_line, "%-6d", cur_line_no);
1375796c8dcSSimon Schubert 		      cur_len = strlen (src_line);
138c50c785cSJohn Marino 		      i = cur_len - ((cur_len / tui_default_tab_len ())
139c50c785cSJohn Marino 				     * tui_default_tab_len ());
1405796c8dcSSimon Schubert 		      while (i < tui_default_tab_len ())
1415796c8dcSSimon Schubert 			{
1425796c8dcSSimon Schubert 			  src_line[cur_len] = ' ';
1435796c8dcSSimon Schubert 			  i++;
1445796c8dcSSimon Schubert 			  cur_len++;
1455796c8dcSSimon Schubert 			}
1465796c8dcSSimon Schubert 		      src_line[cur_len] = (char) 0;
1475796c8dcSSimon Schubert 
1485796c8dcSSimon Schubert 		      /* Set whether element is the execution point
1495796c8dcSSimon Schubert 		         and whether there is a break point on it.  */
1505796c8dcSSimon Schubert 		      element->which_element.source.line_or_addr.loa =
1515796c8dcSSimon Schubert 			LOA_LINE;
1525796c8dcSSimon Schubert 		      element->which_element.source.line_or_addr.u.line_no =
1535796c8dcSSimon Schubert 			cur_line_no;
1545796c8dcSSimon Schubert 		      element->which_element.source.is_exec_point =
155c50c785cSJohn Marino 			(filename_cmp (((struct tui_win_element *)
156*ef5ccd6cSJohn Marino 				       locator->content[0])->which_element.locator.full_name,
157*ef5ccd6cSJohn Marino 				       symtab_to_fullname (s)) == 0
1585796c8dcSSimon Schubert 			 && cur_line_no == ((struct tui_win_element *)
1595796c8dcSSimon Schubert 					    locator->content[0])->which_element.locator.line_no);
1605796c8dcSSimon Schubert 		      if (c != EOF)
1615796c8dcSSimon Schubert 			{
1625796c8dcSSimon Schubert 			  i = strlen (src_line) - 1;
1635796c8dcSSimon Schubert 			  do
1645796c8dcSSimon Schubert 			    {
1655796c8dcSSimon Schubert 			      if ((c != '\n') && (c != '\r')
1665796c8dcSSimon Schubert 				  && (++i < threshold))
1675796c8dcSSimon Schubert 				{
1685796c8dcSSimon Schubert 				  if (c < 040 && c != '\t')
1695796c8dcSSimon Schubert 				    {
1705796c8dcSSimon Schubert 				      src_line[i++] = '^';
1715796c8dcSSimon Schubert 				      src_line[i] = c + 0100;
1725796c8dcSSimon Schubert 				    }
1735796c8dcSSimon Schubert 				  else if (c == 0177)
1745796c8dcSSimon Schubert 				    {
1755796c8dcSSimon Schubert 				      src_line[i++] = '^';
1765796c8dcSSimon Schubert 				      src_line[i] = '?';
1775796c8dcSSimon Schubert 				    }
1785796c8dcSSimon Schubert 				  else
1795796c8dcSSimon Schubert 				    { /* Store the charcter in the
1805796c8dcSSimon Schubert 					 line buffer.  If it is a tab,
1815796c8dcSSimon Schubert 					 then translate to the correct
1825796c8dcSSimon Schubert 					 number of chars so we don't
1835796c8dcSSimon Schubert 					 overwrite our buffer.  */
1845796c8dcSSimon Schubert 				      if (c == '\t')
1855796c8dcSSimon Schubert 					{
186c50c785cSJohn Marino 					  int j, max_tab_len
187c50c785cSJohn Marino 					    = tui_default_tab_len ();
1885796c8dcSSimon Schubert 
189c50c785cSJohn Marino 					  for (j = i - ((i / max_tab_len)
190c50c785cSJohn Marino 							* max_tab_len);
1915796c8dcSSimon Schubert 					       j < max_tab_len
1925796c8dcSSimon Schubert 						 && i < threshold;
1935796c8dcSSimon Schubert 					       i++, j++)
1945796c8dcSSimon Schubert 					    src_line[i] = ' ';
1955796c8dcSSimon Schubert 					  i--;
1965796c8dcSSimon Schubert 					}
1975796c8dcSSimon Schubert 				      else
1985796c8dcSSimon Schubert 					src_line[i] = c;
1995796c8dcSSimon Schubert 				    }
2005796c8dcSSimon Schubert 				  src_line[i + 1] = 0;
2015796c8dcSSimon Schubert 				}
2025796c8dcSSimon Schubert 			      else
2035796c8dcSSimon Schubert 				{ /* If we have not reached EOL, then
2045796c8dcSSimon Schubert 				     eat chars until we do.  */
2055796c8dcSSimon Schubert 				  while (c != EOF && c != '\n' && c != '\r')
2065796c8dcSSimon Schubert 				    c = fgetc (stream);
2075796c8dcSSimon Schubert 				  /* Handle non-'\n' end-of-line.  */
2085796c8dcSSimon Schubert 				  if (c == '\r'
2095796c8dcSSimon Schubert 				      && (c = fgetc (stream)) != '\n'
2105796c8dcSSimon Schubert 				      && c != EOF)
2115796c8dcSSimon Schubert 				    {
2125796c8dcSSimon Schubert 				       ungetc (c, stream);
2135796c8dcSSimon Schubert 				       c = '\r';
2145796c8dcSSimon Schubert 				    }
2155796c8dcSSimon Schubert 
2165796c8dcSSimon Schubert 				}
2175796c8dcSSimon Schubert 			    }
2185796c8dcSSimon Schubert 			  while (c != EOF && c != '\n' && c != '\r'
2195796c8dcSSimon Schubert 				 && i < threshold
2205796c8dcSSimon Schubert 				 && (c = fgetc (stream)));
2215796c8dcSSimon Schubert 			}
2225796c8dcSSimon Schubert 		      /* Now copy the line taking the offset into
2235796c8dcSSimon Schubert 			 account.  */
2245796c8dcSSimon Schubert 		      if (strlen (src_line) > offset)
225c50c785cSJohn Marino 			strcpy (((struct tui_win_element *)
226c50c785cSJohn Marino 				 TUI_SRC_WIN->generic.content[cur_line])->which_element.source.line,
2275796c8dcSSimon Schubert 				&src_line[offset]);
2285796c8dcSSimon Schubert 		      else
2295796c8dcSSimon Schubert 			((struct tui_win_element *)
2305796c8dcSSimon Schubert 			 TUI_SRC_WIN->generic.content[
2315796c8dcSSimon Schubert 			  cur_line])->which_element.source.line[0] = (char) 0;
2325796c8dcSSimon Schubert 		      cur_line++;
2335796c8dcSSimon Schubert 		      cur_line_no++;
2345796c8dcSSimon Schubert 		    }
2355796c8dcSSimon Schubert 		  if (offset > 0)
2365796c8dcSSimon Schubert 		    xfree (src_line);
2375796c8dcSSimon Schubert 		  fclose (stream);
2385796c8dcSSimon Schubert 		  TUI_SRC_WIN->generic.content_size = nlines;
2395796c8dcSSimon Schubert 		  ret = TUI_SUCCESS;
2405796c8dcSSimon Schubert 		}
2415796c8dcSSimon Schubert 	    }
2425796c8dcSSimon Schubert 	}
2435796c8dcSSimon Schubert     }
2445796c8dcSSimon Schubert   return ret;
2455796c8dcSSimon Schubert }
2465796c8dcSSimon Schubert 
2475796c8dcSSimon Schubert 
2485796c8dcSSimon Schubert /* elz: This function sets the contents of the source window to empty
2495796c8dcSSimon Schubert    except for a line in the middle with a warning message about the
2505796c8dcSSimon Schubert    source not being available.  This function is called by
2515796c8dcSSimon Schubert    tui_erase_source_contents(), which in turn is invoked when the
2525796c8dcSSimon Schubert    source files cannot be accessed.  */
2535796c8dcSSimon Schubert 
2545796c8dcSSimon Schubert void
tui_set_source_content_nil(struct tui_win_info * win_info,char * warning_string)2555796c8dcSSimon Schubert tui_set_source_content_nil (struct tui_win_info *win_info,
2565796c8dcSSimon Schubert 			    char *warning_string)
2575796c8dcSSimon Schubert {
2585796c8dcSSimon Schubert   int line_width;
2595796c8dcSSimon Schubert   int n_lines;
2605796c8dcSSimon Schubert   int curr_line = 0;
2615796c8dcSSimon Schubert 
2625796c8dcSSimon Schubert   line_width = win_info->generic.width - 1;
2635796c8dcSSimon Schubert   n_lines = win_info->generic.height - 2;
2645796c8dcSSimon Schubert 
2655796c8dcSSimon Schubert   /* Set to empty each line in the window, except for the one which
2665796c8dcSSimon Schubert      contains the message.  */
2675796c8dcSSimon Schubert   while (curr_line < win_info->generic.content_size)
2685796c8dcSSimon Schubert     {
2695796c8dcSSimon Schubert       /* Set the information related to each displayed line to null:
2705796c8dcSSimon Schubert          i.e. the line number is 0, there is no bp, it is not where
2715796c8dcSSimon Schubert          the program is stopped.  */
2725796c8dcSSimon Schubert 
2735796c8dcSSimon Schubert       struct tui_win_element *element =
2745796c8dcSSimon Schubert 	(struct tui_win_element *) win_info->generic.content[curr_line];
275cf7f2e2dSJohn Marino 
2765796c8dcSSimon Schubert       element->which_element.source.line_or_addr.loa = LOA_LINE;
2775796c8dcSSimon Schubert       element->which_element.source.line_or_addr.u.line_no = 0;
2785796c8dcSSimon Schubert       element->which_element.source.is_exec_point = FALSE;
2795796c8dcSSimon Schubert       element->which_element.source.has_break = FALSE;
2805796c8dcSSimon Schubert 
2815796c8dcSSimon Schubert       /* Set the contents of the line to blank.  */
2825796c8dcSSimon Schubert       element->which_element.source.line[0] = (char) 0;
2835796c8dcSSimon Schubert 
2845796c8dcSSimon Schubert       /* If the current line is in the middle of the screen, then we
2855796c8dcSSimon Schubert          want to display the 'no source available' message in it.
2865796c8dcSSimon Schubert          Note: the 'weird' arithmetic with the line width and height
2875796c8dcSSimon Schubert          comes from the function tui_erase_source_content().  We need
2885796c8dcSSimon Schubert          to keep the screen and the window's actual contents in
2895796c8dcSSimon Schubert          synch.  */
2905796c8dcSSimon Schubert 
2915796c8dcSSimon Schubert       if (curr_line == (n_lines / 2 + 1))
2925796c8dcSSimon Schubert 	{
2935796c8dcSSimon Schubert 	  int i;
2945796c8dcSSimon Schubert 	  int xpos;
2955796c8dcSSimon Schubert 	  int warning_length = strlen (warning_string);
2965796c8dcSSimon Schubert 	  char *src_line;
2975796c8dcSSimon Schubert 
2985796c8dcSSimon Schubert 	  src_line = element->which_element.source.line;
2995796c8dcSSimon Schubert 
3005796c8dcSSimon Schubert 	  if (warning_length >= ((line_width - 1) / 2))
3015796c8dcSSimon Schubert 	    xpos = 1;
3025796c8dcSSimon Schubert 	  else
3035796c8dcSSimon Schubert 	    xpos = (line_width - 1) / 2 - warning_length;
3045796c8dcSSimon Schubert 
3055796c8dcSSimon Schubert 	  for (i = 0; i < xpos; i++)
3065796c8dcSSimon Schubert 	    src_line[i] = ' ';
3075796c8dcSSimon Schubert 
3085796c8dcSSimon Schubert 	  sprintf (src_line + i, "%s", warning_string);
3095796c8dcSSimon Schubert 
3105796c8dcSSimon Schubert 	  for (i = xpos + warning_length; i < line_width; i++)
3115796c8dcSSimon Schubert 	    src_line[i] = ' ';
3125796c8dcSSimon Schubert 
3135796c8dcSSimon Schubert 	  src_line[i] = '\n';
3145796c8dcSSimon Schubert 
3155796c8dcSSimon Schubert 	}			/* end if */
3165796c8dcSSimon Schubert 
3175796c8dcSSimon Schubert       curr_line++;
3185796c8dcSSimon Schubert 
3195796c8dcSSimon Schubert     }				/* end while */
3205796c8dcSSimon Schubert }
3215796c8dcSSimon Schubert 
3225796c8dcSSimon Schubert 
3235796c8dcSSimon Schubert /* Function to display source in the source window.  This function
3245796c8dcSSimon Schubert    initializes the horizontal scroll to 0.  */
3255796c8dcSSimon Schubert void
tui_show_symtab_source(struct gdbarch * gdbarch,struct symtab * s,struct tui_line_or_address line,int noerror)3265796c8dcSSimon Schubert tui_show_symtab_source (struct gdbarch *gdbarch, struct symtab *s,
3275796c8dcSSimon Schubert 			struct tui_line_or_address line,
3285796c8dcSSimon Schubert 			int noerror)
3295796c8dcSSimon Schubert {
3305796c8dcSSimon Schubert   TUI_SRC_WIN->detail.source_info.horizontal_offset = 0;
3315796c8dcSSimon Schubert   tui_update_source_window_as_is (TUI_SRC_WIN, gdbarch, s, line, noerror);
3325796c8dcSSimon Schubert }
3335796c8dcSSimon Schubert 
3345796c8dcSSimon Schubert 
3355796c8dcSSimon Schubert /* Answer whether the source is currently displayed in the source
3365796c8dcSSimon Schubert    window.  */
3375796c8dcSSimon Schubert int
tui_source_is_displayed(const char * fullname)338*ef5ccd6cSJohn Marino tui_source_is_displayed (const char *fullname)
3395796c8dcSSimon Schubert {
340*ef5ccd6cSJohn Marino   return (TUI_SRC_WIN != NULL
341*ef5ccd6cSJohn Marino 	  && TUI_SRC_WIN->generic.content_in_use
342c50c785cSJohn Marino 	  && (filename_cmp (((struct tui_win_element *)
343c50c785cSJohn Marino 			     (tui_locator_win_info_ptr ())->
344*ef5ccd6cSJohn Marino 			     content[0])->which_element.locator.full_name,
345*ef5ccd6cSJohn Marino 			    fullname) == 0));
3465796c8dcSSimon Schubert }
3475796c8dcSSimon Schubert 
3485796c8dcSSimon Schubert 
3495796c8dcSSimon Schubert /* Scroll the source forward or backward vertically.  */
3505796c8dcSSimon Schubert void
tui_vertical_source_scroll(enum tui_scroll_direction scroll_direction,int num_to_scroll)3515796c8dcSSimon Schubert tui_vertical_source_scroll (enum tui_scroll_direction scroll_direction,
3525796c8dcSSimon Schubert 			    int num_to_scroll)
3535796c8dcSSimon Schubert {
3545796c8dcSSimon Schubert   if (TUI_SRC_WIN->generic.content != NULL)
3555796c8dcSSimon Schubert     {
3565796c8dcSSimon Schubert       struct tui_line_or_address l;
3575796c8dcSSimon Schubert       struct symtab *s;
3585796c8dcSSimon Schubert       tui_win_content content = (tui_win_content) TUI_SRC_WIN->generic.content;
3595796c8dcSSimon Schubert       struct symtab_and_line cursal = get_current_source_symtab_and_line ();
3605796c8dcSSimon Schubert 
3615796c8dcSSimon Schubert       if (cursal.symtab == (struct symtab *) NULL)
3625796c8dcSSimon Schubert 	s = find_pc_symtab (get_frame_pc (get_selected_frame (NULL)));
3635796c8dcSSimon Schubert       else
3645796c8dcSSimon Schubert 	s = cursal.symtab;
3655796c8dcSSimon Schubert 
3665796c8dcSSimon Schubert       l.loa = LOA_LINE;
3675796c8dcSSimon Schubert       if (scroll_direction == FORWARD_SCROLL)
3685796c8dcSSimon Schubert 	{
3695796c8dcSSimon Schubert 	  l.u.line_no = content[0]->which_element.source.line_or_addr.u.line_no
3705796c8dcSSimon Schubert 	    + num_to_scroll;
3715796c8dcSSimon Schubert 	  if (l.u.line_no > s->nlines)
3725796c8dcSSimon Schubert 	    /* line = s->nlines - win_info->generic.content_size + 1; */
3735796c8dcSSimon Schubert 	    /* elz: fix for dts 23398.  */
374c50c785cSJohn Marino 	    l.u.line_no
375c50c785cSJohn Marino 	      = content[0]->which_element.source.line_or_addr.u.line_no;
3765796c8dcSSimon Schubert 	}
3775796c8dcSSimon Schubert       else
3785796c8dcSSimon Schubert 	{
3795796c8dcSSimon Schubert 	  l.u.line_no = content[0]->which_element.source.line_or_addr.u.line_no
3805796c8dcSSimon Schubert 	    - num_to_scroll;
3815796c8dcSSimon Schubert 	  if (l.u.line_no <= 0)
3825796c8dcSSimon Schubert 	    l.u.line_no = 1;
3835796c8dcSSimon Schubert 	}
3845796c8dcSSimon Schubert 
3855796c8dcSSimon Schubert       print_source_lines (s, l.u.line_no, l.u.line_no + 1, 0);
3865796c8dcSSimon Schubert     }
3875796c8dcSSimon Schubert }
388