Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(52)

Side by Side Diff: gdb/tui/tui-source.c

Issue 124383005: GDB 7.6.50 (Closed) Base URL: http://git.chromium.org/native_client/nacl-gdb.git@upstream
Patch Set: Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « gdb/tui/tui-source.h ('k') | gdb/tui/tui-stack.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* TUI display source window. 1 /* TUI display source window.
2 2
3 Copyright (C) 1998-2004, 2007-2012 Free Software Foundation, Inc. 3 Copyright (C) 1998-2013 Free Software Foundation, Inc.
4 4
5 Contributed by Hewlett-Packard Company. 5 Contributed by Hewlett-Packard Company.
6 6
7 This file is part of GDB. 7 This file is part of GDB.
8 8
9 This program is free software; you can redistribute it and/or modify 9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by 10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 3 of the License, or 11 the Free Software Foundation; either version 3 of the License, or
12 (at your option) any later version. 12 (at your option) any later version.
13 13
(...skipping 14 matching lines...) Expand all
28 #include "symtab.h" 28 #include "symtab.h"
29 #include "objfiles.h" 29 #include "objfiles.h"
30 #include "filenames.h" 30 #include "filenames.h"
31 31
32 #include "tui/tui.h" 32 #include "tui/tui.h"
33 #include "tui/tui-data.h" 33 #include "tui/tui-data.h"
34 #include "tui/tui-stack.h" 34 #include "tui/tui-stack.h"
35 #include "tui/tui-winsource.h" 35 #include "tui/tui-winsource.h"
36 #include "tui/tui-source.h" 36 #include "tui/tui-source.h"
37 37
38 #include "gdb_string.h" 38 #include <string.h>
39 #include "gdb_curses.h" 39 #include "gdb_curses.h"
40 40
41 /* Function to display source in the source window. */ 41 /* Function to display source in the source window. */
42 enum tui_status 42 enum tui_status
43 tui_set_source_content (struct symtab *s, 43 tui_set_source_content (struct symtab *s,
44 int line_no, 44 int line_no,
45 int noerror) 45 int noerror)
46 { 46 {
47 enum tui_status ret = TUI_FAILURE; 47 enum tui_status ret = TUI_FAILURE;
48 48
49 if (s != (struct symtab *) NULL && s->filename != (char *) NULL) 49 if (s != (struct symtab *) NULL)
50 { 50 {
51 FILE *stream; 51 FILE *stream;
52 int i, desc, c, line_width, nlines; 52 int i, desc, c, line_width, nlines;
53 char *src_line = 0; 53 char *src_line = 0;
54 54
55 if ((ret = tui_alloc_source_buffer (TUI_SRC_WIN)) == TUI_SUCCESS) 55 if ((ret = tui_alloc_source_buffer (TUI_SRC_WIN)) == TUI_SUCCESS)
56 { 56 {
57 line_width = TUI_SRC_WIN->generic.width - 1; 57 line_width = TUI_SRC_WIN->generic.width - 1;
58 /* Take hilite (window border) into account, when 58 /* Take hilite (window border) into account, when
59 calculating the number of lines. */ 59 calculating the number of lines. */
60 nlines = (line_no + (TUI_SRC_WIN->generic.height - 2)) - line_no; 60 nlines = (line_no + (TUI_SRC_WIN->generic.height - 2)) - line_no;
61 desc = open_source_file (s); 61 desc = open_source_file (s);
62 if (desc < 0) 62 if (desc < 0)
63 { 63 {
64 if (!noerror) 64 if (!noerror)
65 { 65 {
66 » » char *name = alloca (strlen (s->filename) + 100); 66 » » const char *filename = symtab_to_filename_for_display (s);
67 » » char *name = alloca (strlen (filename) + 100);
67 68
68 » » sprintf (name, "%s:%d", s->filename, line_no); 69 » » sprintf (name, "%s:%d", filename, line_no);
69 print_sys_errmsg (name, errno); 70 print_sys_errmsg (name, errno);
70 } 71 }
71 ret = TUI_FAILURE; 72 ret = TUI_FAILURE;
72 } 73 }
73 else 74 else
74 { 75 {
75 if (s->line_charpos == 0) 76 if (s->line_charpos == 0)
76 find_source_lines (s, desc); 77 find_source_lines (s, desc);
77 78
78 if (line_no < 1 || line_no > s->nlines) 79 if (line_no < 1 || line_no > s->nlines)
79 { 80 {
80 close (desc); 81 close (desc);
81 » » printf_unfiltered ( 82 » » printf_unfiltered ("Line number %d out of range; "
82 » » » "Line number %d out of range; %s has %d lines.\n", 83 » » » » "%s has %d lines.\n",
83 » » » » line_no, s->filename, s->nlines); 84 » » » » line_no,
85 » » » » symtab_to_filename_for_display (s),
86 » » » » s->nlines);
84 } 87 }
85 else if (lseek (desc, s->line_charpos[line_no - 1], 0) < 0) 88 else if (lseek (desc, s->line_charpos[line_no - 1], 0) < 0)
86 { 89 {
87 close (desc); 90 close (desc);
88 » » perror_with_name (s->filename); 91 » » perror_with_name (symtab_to_filename_for_display (s));
89 } 92 }
90 else 93 else
91 { 94 {
92 int offset, cur_line_no, cur_line, cur_len, threshold; 95 int offset, cur_line_no, cur_line, cur_len, threshold;
93 struct tui_gen_win_info *locator 96 struct tui_gen_win_info *locator
94 = tui_locator_win_info_ptr (); 97 = tui_locator_win_info_ptr ();
95 struct tui_source_info *src 98 struct tui_source_info *src
96 = &TUI_SRC_WIN->detail.source_info; 99 = &TUI_SRC_WIN->detail.source_info;
100 const char *s_filename = symtab_to_filename_for_display (s);
97 101
98 if (TUI_SRC_WIN->generic.title) 102 if (TUI_SRC_WIN->generic.title)
99 xfree (TUI_SRC_WIN->generic.title); 103 xfree (TUI_SRC_WIN->generic.title);
100 TUI_SRC_WIN->generic.title = xstrdup (s->filename); 104 TUI_SRC_WIN->generic.title = xstrdup (s_filename);
101 105
102 if (src->filename) 106 » » xfree (src->fullname);
103 xfree (src->filename); 107 » » src->fullname = xstrdup (symtab_to_fullname (s));
104 src->filename = xstrdup (s->filename);
105 108
106 /* Determine the threshold for the length of the 109 /* Determine the threshold for the length of the
107 line and the offset to start the display. */ 110 line and the offset to start the display. */
108 offset = src->horizontal_offset; 111 offset = src->horizontal_offset;
109 threshold = (line_width - 1) + offset; 112 threshold = (line_width - 1) + offset;
110 stream = fdopen (desc, FOPEN_RT); 113 stream = fdopen (desc, FOPEN_RT);
111 clearerr (stream); 114 clearerr (stream);
112 cur_line = 0; 115 cur_line = 0;
113 src->gdbarch = get_objfile_arch (s->objfile); 116 src->gdbarch = get_objfile_arch (s->objfile);
114 src->start_line_or_addr.loa = LOA_LINE; 117 src->start_line_or_addr.loa = LOA_LINE;
(...skipping 28 matching lines...) Expand all
143 src_line[cur_len] = (char) 0; 146 src_line[cur_len] = (char) 0;
144 147
145 /* Set whether element is the execution point 148 /* Set whether element is the execution point
146 and whether there is a break point on it. */ 149 and whether there is a break point on it. */
147 element->which_element.source.line_or_addr.loa = 150 element->which_element.source.line_or_addr.loa =
148 LOA_LINE; 151 LOA_LINE;
149 element->which_element.source.line_or_addr.u.line_no = 152 element->which_element.source.line_or_addr.u.line_no =
150 cur_line_no; 153 cur_line_no;
151 element->which_element.source.is_exec_point = 154 element->which_element.source.is_exec_point =
152 (filename_cmp (((struct tui_win_element *) 155 (filename_cmp (((struct tui_win_element *)
153 » » » » locator->content[0])->which_element.locat or.file_name, 156 » » » » locator->content[0])->which_element.locat or.full_name,
154 » » » » s->filename) == 0 157 » » » » symtab_to_fullname (s)) == 0
155 && cur_line_no == ((struct tui_win_element *) 158 && cur_line_no == ((struct tui_win_element *)
156 locator->content[0])->which_element. locator.line_no); 159 locator->content[0])->which_element. locator.line_no);
157 if (c != EOF) 160 if (c != EOF)
158 { 161 {
159 i = strlen (src_line) - 1; 162 i = strlen (src_line) - 1;
160 do 163 do
161 { 164 {
162 if ((c != '\n') && (c != '\r') 165 if ((c != '\n') && (c != '\r')
163 && (++i < threshold)) 166 && (++i < threshold))
164 { 167 {
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
325 int noerror) 328 int noerror)
326 { 329 {
327 TUI_SRC_WIN->detail.source_info.horizontal_offset = 0; 330 TUI_SRC_WIN->detail.source_info.horizontal_offset = 0;
328 tui_update_source_window_as_is (TUI_SRC_WIN, gdbarch, s, line, noerror); 331 tui_update_source_window_as_is (TUI_SRC_WIN, gdbarch, s, line, noerror);
329 } 332 }
330 333
331 334
332 /* Answer whether the source is currently displayed in the source 335 /* Answer whether the source is currently displayed in the source
333 window. */ 336 window. */
334 int 337 int
335 tui_source_is_displayed (char *fname) 338 tui_source_is_displayed (const char *fullname)
336 { 339 {
337 return (TUI_SRC_WIN->generic.content_in_use 340 return (TUI_SRC_WIN != NULL
341 » && TUI_SRC_WIN->generic.content_in_use
338 && (filename_cmp (((struct tui_win_element *) 342 && (filename_cmp (((struct tui_win_element *)
339 (tui_locator_win_info_ptr ())-> 343 (tui_locator_win_info_ptr ())->
340 » » » content[0])->which_element.locator.file_name, 344 » » » content[0])->which_element.locator.full_name,
341 » » » fname) == 0)); 345 » » » fullname) == 0));
342 } 346 }
343 347
344 348
345 /* Scroll the source forward or backward vertically. */ 349 /* Scroll the source forward or backward vertically. */
346 void 350 void
347 tui_vertical_source_scroll (enum tui_scroll_direction scroll_direction, 351 tui_vertical_source_scroll (enum tui_scroll_direction scroll_direction,
348 int num_to_scroll) 352 int num_to_scroll)
349 { 353 {
350 if (TUI_SRC_WIN->generic.content != NULL) 354 if (TUI_SRC_WIN->generic.content != NULL)
351 { 355 {
(...skipping 22 matching lines...) Expand all
374 { 378 {
375 l.u.line_no = content[0]->which_element.source.line_or_addr.u.line_no 379 l.u.line_no = content[0]->which_element.source.line_or_addr.u.line_no
376 - num_to_scroll; 380 - num_to_scroll;
377 if (l.u.line_no <= 0) 381 if (l.u.line_no <= 0)
378 l.u.line_no = 1; 382 l.u.line_no = 1;
379 } 383 }
380 384
381 print_source_lines (s, l.u.line_no, l.u.line_no + 1, 0); 385 print_source_lines (s, l.u.line_no, l.u.line_no + 1, 0);
382 } 386 }
383 } 387 }
OLDNEW
« no previous file with comments | « gdb/tui/tui-source.h ('k') | gdb/tui/tui-stack.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698