2 ** This module contains functions for displaying the locator information in the locator window.
7 #include "breakpoint.h"
13 #include "tuiSourceWin.h"
16 /*****************************************
17 ** STATIC LOCAL FUNCTIONS FORWARD DECLS **
18 ******************************************/
20 static char *_getFuncNameFromFrame (struct frame_info *);
21 static void _tuiUpdateLocation_command (char *, int);
25 /*****************************************
27 ******************************************/
30 ** tuiClearLocatorDisplay()
34 tuiClearLocatorDisplay (void)
36 tuiClearLocatorDisplay ()
39 TuiGenWinInfoPtr locator = locatorWinInfoPtr ();
42 if (locator->handle != (WINDOW *) NULL)
44 /* No need to werase, since writing a line of
45 * blanks which we do below, is equivalent.
47 /* werase(locator->handle); */
48 wmove (locator->handle, 0, 0);
49 wstandout (locator->handle);
50 for (i = 0; i < locator->width; i++)
51 waddch (locator->handle, ' ');
52 wstandend (locator->handle);
53 tuiRefreshWin (locator);
54 wmove (locator->handle, 0, 0);
55 locator->contentInUse = FALSE;
59 } /* tuiClearLocatorDisplay */
63 ** tuiShowLocatorContent()
67 tuiShowLocatorContent (void)
69 tuiShowLocatorContent ()
73 TuiGenWinInfoPtr locator;
75 locator = locatorWinInfoPtr ();
77 if (m_genWinPtrNotNull (locator) && locator->handle != (WINDOW *) NULL)
79 string = displayableWinContentAt (locator, 0);
80 if (string != (char *) NULL)
82 wmove (locator->handle, 0, 0);
83 wstandout (locator->handle);
84 waddstr (locator->handle, string);
85 wstandend (locator->handle);
86 tuiRefreshWin (locator);
87 wmove (locator->handle, 0, 0);
88 if (string != nullStr ())
90 locator->contentInUse = TRUE;
95 } /* tuiShowLocatorContent */
99 ** tuiSetLocatorInfo().
100 ** Function to update the locator, with the provided arguments.
109 TuiLocatorElementPtr element)
111 tuiSetLocatorInfo (fname, procname, lineNo, addr, element)
116 TuiLocatorElementPtr element;
120 /* first free the old info */
121 if (element->fileName)
122 tuiFree (element->fileName);
123 if (element->procName)
124 tuiFree (element->procName);
126 if (fname == (char *) NULL)
127 element->fileName = fname;
129 element->fileName = tuiStrDup (fname);
130 if (procname == (char *) NULL)
131 element->procName = procname;
133 element->procName = tuiStrDup (procname);
135 element->fileName[0] = (char) 0;
136 element->procName[0] = (char) 0;
137 strcat_to_buf (element->fileName, MAX_LOCATOR_ELEMENT_LEN, fname);
138 strcat_to_buf (element->procName, MAX_LOCATOR_ELEMENT_LEN, procname);
140 element->lineNo = lineNo;
141 element->addr = (Opaque) addr;
144 } /* tuiSetLocatorInfo */
148 ** tuiUpdateLocatorFilename().
149 ** Update only the filename portion of the locator.
153 tuiUpdateLocatorFilename (
156 tuiUpdateLocatorFilename (fileName)
160 TuiGenWinInfoPtr locator = locatorWinInfoPtr ();
162 if (locator->content[0] == (Opaque) NULL)
163 tuiSetLocatorContent ((struct frame_info *) NULL);
164 ((TuiWinElementPtr) locator->content[0])->whichElement.locator.fileName[0] = (char) 0;
165 strcat_to_buf (((TuiWinElementPtr) locator->content[0])->whichElement.locator.fileName,
166 MAX_LOCATOR_ELEMENT_LEN,
169 tuiShowLocatorContent ();
172 } /* tuiUpdateLocatorFilename */
176 ** tui_vUpdateLocatorFilename().
177 ** Update only the filename portion of the locator with args in a va_list.
181 tui_vUpdateLocatorFilename (
184 tui_vUpdateLocatorFilename (args)
190 fileName = va_arg (args, char *);
191 tuiUpdateLocatorFilename (fileName);
194 } /* tui_vUpdateLocatorFilename */
198 ** tuiSwitchFilename().
199 ** Update the filename portion of the locator. Clear the other info in locator.
207 tuiSwitchFilename (fileName)
211 TuiGenWinInfoPtr locator = locatorWinInfoPtr ();
213 if (locator->content[0] == (Opaque) NULL)
214 tuiSetLocatorContent ((struct frame_info *) NULL);
215 ((TuiWinElementPtr) locator->content[0])->whichElement.locator.fileName[0] = (char) 0;
217 tuiSetLocatorInfo (fileName,
221 &((TuiWinElementPtr) locator->content[0])->whichElement.locator);
223 tuiShowLocatorContent ();
226 } /* tuiSwitchFilename */
230 ** tuiGetLocatorFilename().
231 ** Get the filename portion of the locator.
236 tuiGetLocatorFilename (
237 TuiGenWinInfoPtr locator,
240 tuiGetLocatorFilename (locator, filename)
241 TuiGenWinInfoPtr locator;
246 /* the current filename could be non known, in which case the xmalloc would
247 allocate no memory, because the length would be 0 */
248 if (((TuiWinElementPtr) locator->content[0])->whichElement.locator.fileName)
251 strlen (((TuiWinElementPtr) locator->content[0])->whichElement.locator.fileName);
253 (*filename) = (char *) xmalloc (name_length + 1);
255 ((TuiWinElementPtr) locator->content[0])->whichElement.locator.fileName);
259 } /* tuiGetLocatorFilename */
263 ** tuiUpdateLocatorInfoFromFrame().
264 ** Function to update the locator, with the information extracted from frameInfo
268 tuiUpdateLocatorInfoFromFrame (
269 struct frame_info *frameInfo,
270 TuiLocatorElementPtr element)
272 tuiUpdateLocatorInfoFromFrame (frameInfo, element)
273 struct frame_info *frameInfo;
274 TuiLocatorElementPtr element;
277 struct symtab_and_line symtabAndLine;
279 /* now get the new info */
280 symtabAndLine = find_pc_line (frameInfo->pc,
281 (frameInfo->next != (struct frame_info *) NULL &&
282 !frameInfo->next->signal_handler_caller &&
283 !frame_in_dummy (frameInfo->next)));
284 if (symtabAndLine.symtab && symtabAndLine.symtab->filename)
285 tuiSetLocatorInfo (symtabAndLine.symtab->filename,
286 _getFuncNameFromFrame (frameInfo),
288 (Opaque) frameInfo->pc,
291 tuiSetLocatorInfo ((char *) NULL,
292 _getFuncNameFromFrame (frameInfo),
294 (Opaque) frameInfo->pc,
298 } /* tuiUpdateLocatorInfoFromFrame */
302 ** tuiSetLocatorContent().
303 ** Function to set the content of the locator
307 tuiSetLocatorContent (
308 struct frame_info *frameInfo)
310 tuiSetLocatorContent (frameInfo)
311 struct frame_info *frameInfo;
314 TuiGenWinInfoPtr locator = locatorWinInfoPtr ();
315 TuiWinElementPtr element;
316 struct symtab_and_line symtabAndLine;
318 /* Allocate the element if necessary */
319 if (locator->contentSize <= 0)
321 TuiWinContent contentPtr;
323 if ((locator->content = (OpaquePtr) allocContent (1, locator->type)) == (OpaquePtr) NULL)
324 error ("Unable to Allocate Memory to Display Location.");
325 locator->contentSize = 1;
328 if (frameInfo != (struct frame_info *) NULL)
329 tuiUpdateLocatorInfoFromFrame (frameInfo,
330 &((TuiWinElementPtr) locator->content[0])->whichElement.locator);
332 tuiSetLocatorInfo ((char *) NULL,
336 &((TuiWinElementPtr) locator->content[0])->whichElement.locator);
338 } /* tuiSetLocatorContent */
342 ** tuiUpdateLocatorDisplay().
343 ** Function to update the locator display
347 tuiUpdateLocatorDisplay (
348 struct frame_info *frameInfo)
350 tuiUpdateLocatorDisplay (frameInfo)
351 struct frame_info *frameInfo;
354 tuiClearLocatorDisplay ();
355 tuiSetLocatorContent (frameInfo);
356 tuiShowLocatorContent ();
359 } /* tuiUpdateLocatorDisplay */
363 ** tuiShowFrameInfo().
364 ** Function to print the frame inforrmation for the TUI.
369 struct frame_info *fi)
371 tuiShowFrameInfo (fi)
372 struct frame_info *fi;
375 TuiWinInfoPtr winInfo;
380 register int startLine, i;
381 register struct symtab *s;
383 TuiGenWinInfoPtr locator = locatorWinInfoPtr ();
384 int sourceAlreadyDisplayed;
387 s = find_pc_symtab (fi->pc);
388 sourceAlreadyDisplayed = tuiSourceIsDisplayed (s->filename);
389 tuiUpdateLocatorDisplay (fi);
390 for (i = 0; i < (sourceWindows ())->count; i++)
392 winInfo = (TuiWinInfoPtr) (sourceWindows ())->list[i];
393 if (winInfo == srcWin)
396 (((TuiWinElementPtr) locator->content[0])->whichElement.locator.lineNo -
397 (winInfo->generic.viewportHeight / 2)) + 1;
403 if (find_pc_partial_function (fi->pc, (char **) NULL, &low, (CORE_ADDR) NULL) == 0)
404 error ("No function contains program counter for selected frame.\n");
406 low = (CORE_ADDR) tuiGetLowDisassemblyAddress ((Opaque) low, (Opaque) fi->pc);
409 if (winInfo == srcWin)
411 if (!(sourceAlreadyDisplayed && m_tuiLineDisplayedWithinThreshold (
413 ((TuiWinElementPtr) locator->content[0])->whichElement.locator.lineNo)))
414 tuiUpdateSourceWindow (winInfo, s, (Opaque) startLine, TRUE);
416 tuiSetIsExecPointAt ((Opaque)
417 ((TuiWinElementPtr) locator->content[0])->whichElement.locator.lineNo,
422 if (winInfo == disassemWin)
424 if (!m_tuiLineDisplayedWithinThreshold (winInfo,
425 ((TuiWinElementPtr) locator->content[0])->whichElement.locator.addr))
426 tuiUpdateSourceWindow (winInfo, s, (Opaque) low, TRUE);
428 tuiSetIsExecPointAt ((Opaque)
429 ((TuiWinElementPtr) locator->content[0])->whichElement.locator.addr,
433 tuiUpdateExecInfo (winInfo);
438 tuiUpdateLocatorDisplay (fi);
439 for (i = 0; i < (sourceWindows ())->count; i++)
441 winInfo = (TuiWinInfoPtr) (sourceWindows ())->list[i];
442 tuiClearSourceContent (winInfo, EMPTY_SOURCE_PROMPT);
443 tuiUpdateExecInfo (winInfo);
448 } /* tuiShowFrameInfo */
452 ** tui_vShowFrameInfo().
453 ** Function to print the frame inforrmation for the TUI with args in a va_list.
460 tui_vShowFrameInfo (args)
464 struct frame_info *fi;
466 fi = va_arg (args, struct frame_info *);
467 tuiShowFrameInfo (fi);
470 } /* tui_vShowFrameInfo */
474 ** _initialize_tuiStack().
475 ** Function to initialize gdb commands, for tui window stack manipulation.
478 _initialize_tuiStack (void)
482 add_com ("update", class_tui, _tuiUpdateLocation_command,
483 "Update the source window and locator to display the current execution point.\n");
487 } /* _initialize_tuiStack */
490 /*****************************************
491 ** STATIC LOCAL FUNCTIONS **
492 ******************************************/
495 ** _getFuncNameFromFrame().
499 _getFuncNameFromFrame (
500 struct frame_info *frameInfo)
502 _getFuncNameFromFrame (frameInfo)
503 struct frame_info *frameInfo;
506 char *funcName = (char *) NULL;
508 find_pc_partial_function (frameInfo->pc,
513 } /* _getFuncNameFromFrame */
517 ** _tuiUpdateLocation_command().
518 ** Command to update the display with the current execution point
522 _tuiUpdateLocation_command (
526 _tuiUpdateLocation_command (arg, fromTTY)
532 extern void frame_command (char *, int);
533 frame_command ("0", FALSE);
535 struct frame_info *curFrame;
537 /* Obtain the current execution point */
538 if ((curFrame = get_current_frame ()) != (struct frame_info *) NULL)
540 struct frame_info *frame;
543 for (frame = get_prev_frame (curLevel);
544 (frame != (struct frame_info *) NULL && (frame != curFrame));
545 frame = get_prev_frame (frame))
548 if (curFrame != (struct frame_info *) NULL)
549 print_frame_info (frame, curLevel, 0, 1);
554 } /* _tuiUpdateLocation_command */