summaryrefslogtreecommitdiff
path: root/gdb/tui/tui-disasm.c
diff options
context:
space:
mode:
Diffstat (limited to 'gdb/tui/tui-disasm.c')
-rw-r--r--gdb/tui/tui-disasm.c176
1 files changed, 85 insertions, 91 deletions
diff --git a/gdb/tui/tui-disasm.c b/gdb/tui/tui-disasm.c
index 99143a4ed64..19226b35c1d 100644
--- a/gdb/tui/tui-disasm.c
+++ b/gdb/tui/tui-disasm.c
@@ -29,7 +29,7 @@
#include "value.h"
#include "source.h"
#include "disasm.h"
-
+#include "gdb_string.h"
#include "tui/tui.h"
#include "tui/tui-data.h"
#include "tui/tui-win.h"
@@ -38,13 +38,7 @@
#include "tui/tui-stack.h"
#include "tui/tui-file.h"
-#ifdef HAVE_NCURSES_H
-#include <ncurses.h>
-#else
-#ifdef HAVE_CURSES_H
-#include <curses.h>
-#endif
-#endif
+#include "gdb_curses.h"
struct tui_asm_line
{
@@ -95,24 +89,24 @@ tui_disassemble (struct tui_asm_line* lines, CORE_ADDR pc, int count)
static CORE_ADDR
tui_find_disassembly_address (CORE_ADDR pc, int from)
{
- register CORE_ADDR newLow;
- int maxLines;
+ CORE_ADDR new_low;
+ int max_lines;
int i;
struct tui_asm_line* lines;
- maxLines = (from > 0) ? from : - from;
- if (maxLines <= 1)
+ max_lines = (from > 0) ? from : - from;
+ if (max_lines <= 1)
return pc;
lines = (struct tui_asm_line*) alloca (sizeof (struct tui_asm_line)
- * maxLines);
- memset (lines, 0, sizeof (struct tui_asm_line) * maxLines);
+ * max_lines);
+ memset (lines, 0, sizeof (struct tui_asm_line) * max_lines);
- newLow = pc;
+ new_low = pc;
if (from > 0)
{
- tui_disassemble (lines, pc, maxLines);
- newLow = lines[maxLines - 1].addr;
+ tui_disassemble (lines, pc, max_lines);
+ new_low = lines[max_lines - 1].addr;
}
else
{
@@ -123,17 +117,17 @@ tui_find_disassembly_address (CORE_ADDR pc, int from)
/* Find backward an address which is a symbol
and for which disassembling from that address will fill
completely the window. */
- pos = maxLines - 1;
+ pos = max_lines - 1;
do {
- newLow -= 1 * maxLines;
- msymbol = lookup_minimal_symbol_by_pc_section (newLow, 0);
+ new_low -= 1 * max_lines;
+ msymbol = lookup_minimal_symbol_by_pc_section (new_low, 0);
if (msymbol)
- newLow = SYMBOL_VALUE_ADDRESS (msymbol);
+ new_low = SYMBOL_VALUE_ADDRESS (msymbol);
else
- newLow += 1 * maxLines;
+ new_low += 1 * max_lines;
- tui_disassemble (lines, newLow, maxLines);
+ tui_disassemble (lines, new_low, max_lines);
last_addr = lines[pos].addr;
} while (last_addr > pc && msymbol);
@@ -148,7 +142,7 @@ tui_find_disassembly_address (CORE_ADDR pc, int from)
CORE_ADDR next_addr;
pos++;
- if (pos >= maxLines)
+ if (pos >= max_lines)
pos = 0;
next_addr = tui_disassemble (&lines[pos], last_addr, 1);
@@ -159,29 +153,29 @@ tui_find_disassembly_address (CORE_ADDR pc, int from)
last_addr = next_addr;
} while (last_addr <= pc);
pos++;
- if (pos >= maxLines)
+ if (pos >= max_lines)
pos = 0;
- newLow = lines[pos].addr;
+ new_low = lines[pos].addr;
}
- for (i = 0; i < maxLines; i++)
+ for (i = 0; i < max_lines; i++)
{
xfree (lines[i].addr_string);
xfree (lines[i].insn);
}
- return newLow;
+ return new_low;
}
/* Function to set the disassembly window's content. */
enum tui_status
tui_set_disassem_content (CORE_ADDR pc)
{
- TuiStatus ret = TUI_FAILURE;
- register int i;
- register int offset = disassemWin->detail.sourceInfo.horizontalOffset;
- register int lineWidth, maxLines;
+ enum tui_status ret = TUI_FAILURE;
+ int i;
+ int offset = TUI_DISASM_WIN->detail.source_info.horizontal_offset;
+ int line_width, max_lines;
CORE_ADDR cur_pc;
- TuiGenWinInfoPtr locator = locatorWinInfoPtr ();
- int tab_len = tuiDefaultTabLen ();
+ struct tui_gen_win_info * locator = tui_locator_win_info_ptr ();
+ int tab_len = tui_default_tab_len ();
struct tui_asm_line* lines;
int insn_pos;
int addr_size, max_size;
@@ -190,29 +184,29 @@ tui_set_disassem_content (CORE_ADDR pc)
if (pc == 0)
return TUI_FAILURE;
- ret = tuiAllocSourceBuffer (disassemWin);
+ ret = tui_alloc_source_buffer (TUI_DISASM_WIN);
if (ret != TUI_SUCCESS)
return ret;
- disassemWin->detail.sourceInfo.startLineOrAddr.addr = pc;
+ TUI_DISASM_WIN->detail.source_info.start_line_or_addr.addr = pc;
cur_pc = (CORE_ADDR)
- (((TuiWinElementPtr) locator->content[0])->whichElement.locator.addr);
+ (((struct tui_win_element *) locator->content[0])->which_element.locator.addr);
- maxLines = disassemWin->generic.height - 2; /* account for hilite */
+ max_lines = TUI_DISASM_WIN->generic.height - 2; /* account for hilite */
/* Get temporary table that will hold all strings (addr & insn). */
lines = (struct tui_asm_line*) alloca (sizeof (struct tui_asm_line)
- * maxLines);
- memset (lines, 0, sizeof (struct tui_asm_line) * maxLines);
+ * max_lines);
+ memset (lines, 0, sizeof (struct tui_asm_line) * max_lines);
- lineWidth = disassemWin->generic.width - 1;
+ line_width = TUI_DISASM_WIN->generic.width - 1;
- tui_disassemble (lines, pc, maxLines);
+ tui_disassemble (lines, pc, max_lines);
/* See what is the maximum length of an address and of a line. */
addr_size = 0;
max_size = 0;
- for (i = 0; i < maxLines; i++)
+ for (i = 0; i < max_lines; i++)
{
size_t len = strlen (lines[i].addr_string);
if (len > addr_size)
@@ -229,22 +223,22 @@ tui_set_disassem_content (CORE_ADDR pc)
insn_pos = (1 + (addr_size / tab_len)) * tab_len;
/* Now construct each line */
- for (i = 0; i < maxLines; i++)
+ for (i = 0; i < max_lines; i++)
{
- TuiWinElementPtr element;
- TuiSourceElement* src;
- int curLen;
+ struct tui_win_element * element;
+ struct tui_source_element* src;
+ int cur_len;
- element = (TuiWinElementPtr) disassemWin->generic.content[i];
- src = &element->whichElement.source;
+ element = (struct tui_win_element *) TUI_DISASM_WIN->generic.content[i];
+ src = &element->which_element.source;
strcpy (line, lines[i].addr_string);
- curLen = strlen (line);
+ cur_len = strlen (line);
/* Add spaces to make the instructions start on the same column */
- while (curLen < insn_pos)
+ while (cur_len < insn_pos)
{
strcat (line, " ");
- curLen++;
+ cur_len++;
}
strcat (line, lines[i].insn);
@@ -255,38 +249,38 @@ tui_set_disassem_content (CORE_ADDR pc)
else
src->line[0] = '\0';
- src->lineOrAddr.addr = lines[i].addr;
- src->isExecPoint = lines[i].addr == cur_pc;
+ src->line_or_addr.addr = lines[i].addr;
+ src->is_exec_point = lines[i].addr == cur_pc;
/* See whether there is a breakpoint installed. */
- src->hasBreak = (!src->isExecPoint
+ src->has_break = (!src->is_exec_point
&& breakpoint_here_p (pc) != no_breakpoint_here);
xfree (lines[i].addr_string);
xfree (lines[i].insn);
}
- disassemWin->generic.contentSize = i;
+ TUI_DISASM_WIN->generic.content_size = i;
return TUI_SUCCESS;
}
/* Function to display the disassembly window with disassembled code. */
void
-tui_show_disassem (CORE_ADDR startAddr)
+tui_show_disassem (CORE_ADDR start_addr)
{
- struct symtab *s = find_pc_symtab (startAddr);
- TuiWinInfoPtr winWithFocus = tuiWinWithFocus ();
- TuiLineOrAddress val;
+ struct symtab *s = find_pc_symtab (start_addr);
+ struct tui_win_info * win_with_focus = tui_win_with_focus ();
+ union tui_line_or_address val;
- val.addr = startAddr;
- tuiAddWinToLayout (DISASSEM_WIN);
- tuiUpdateSourceWindow (disassemWin, s, val, FALSE);
+ val.addr = start_addr;
+ tui_add_win_to_layout (DISASSEM_WIN);
+ tui_update_source_window (TUI_DISASM_WIN, s, val, FALSE);
/*
** if the focus was in the src win, put it in the asm win, if the
** source view isn't split
*/
- if (currentLayout () != SRC_DISASSEM_COMMAND && winWithFocus == srcWin)
- tuiSetWinFocusTo (disassemWin);
+ if (tui_current_layout () != SRC_DISASSEM_COMMAND && win_with_focus == TUI_SRC_WIN)
+ tui_set_win_focus_to (TUI_DISASM_WIN);
return;
}
@@ -294,29 +288,29 @@ tui_show_disassem (CORE_ADDR startAddr)
/* Function to display the disassembly window. */
void
-tui_show_disassem_and_update_source (CORE_ADDR startAddr)
+tui_show_disassem_and_update_source (CORE_ADDR start_addr)
{
struct symtab_and_line sal;
- tui_show_disassem (startAddr);
- if (currentLayout () == SRC_DISASSEM_COMMAND)
+ tui_show_disassem (start_addr);
+ if (tui_current_layout () == SRC_DISASSEM_COMMAND)
{
- TuiLineOrAddress val;
+ union tui_line_or_address val;
/*
** Update what is in the source window if it is displayed too,
** note that it follows what is in the disassembly window and visa-versa
*/
- sal = find_pc_line (startAddr, 0);
- val.lineNo = sal.line;
- tuiUpdateSourceWindow (srcWin, sal.symtab, val, TRUE);
+ sal = find_pc_line (start_addr, 0);
+ val.line_no = sal.line;
+ tui_update_source_window (TUI_SRC_WIN, sal.symtab, val, TRUE);
if (sal.symtab)
{
set_current_source_symtab_and_line (&sal);
- tuiUpdateLocatorFilename (sal.symtab->filename);
+ tui_update_locator_filename (sal.symtab->filename);
}
else
- tuiUpdateLocatorFilename ("?");
+ tui_update_locator_filename ("?");
}
return;
@@ -325,12 +319,12 @@ tui_show_disassem_and_update_source (CORE_ADDR startAddr)
CORE_ADDR
tui_get_begin_asm_address (void)
{
- TuiGenWinInfoPtr locator;
- TuiLocatorElementPtr element;
+ struct tui_gen_win_info * locator;
+ struct tui_locator_element * element;
CORE_ADDR addr;
- locator = locatorWinInfoPtr ();
- element = &((TuiWinElementPtr) locator->content[0])->whichElement.locator;
+ locator = tui_locator_win_info_ptr ();
+ element = &((struct tui_win_element *) locator->content[0])->which_element.locator;
if (element->addr == 0)
{
@@ -358,13 +352,13 @@ tui_get_begin_asm_address (void)
disassembly window. This may or may not be the same as the
low address input. */
CORE_ADDR
-tuiGetLowDisassemblyAddress (CORE_ADDR low, CORE_ADDR pc)
+tui_get_low_disassembly_address (CORE_ADDR low, CORE_ADDR pc)
{
int pos;
/* Determine where to start the disassembly so that the pc is about in the
middle of the viewport. */
- pos = tuiDefaultWinViewportHeight (DISASSEM_WIN, DISASSEM_COMMAND) / 2;
+ pos = tui_default_win_viewport_height (DISASSEM_WIN, DISASSEM_COMMAND) / 2;
pc = tui_find_disassembly_address (pc, -pos);
if (pc < low)
@@ -374,30 +368,30 @@ tuiGetLowDisassemblyAddress (CORE_ADDR low, CORE_ADDR pc)
/* Scroll the disassembly forward or backward vertically. */
void
-tui_vertical_disassem_scroll (enum tui_scroll_direction scrollDirection,
- int numToScroll)
+tui_vertical_disassem_scroll (enum tui_scroll_direction scroll_direction,
+ int num_to_scroll)
{
- if (disassemWin->generic.content != (OpaquePtr) NULL)
+ if (TUI_DISASM_WIN->generic.content != NULL)
{
CORE_ADDR pc;
- TuiWinContent content;
+ tui_win_content content;
struct symtab *s;
- TuiLineOrAddress val;
- int maxLines, dir;
+ union tui_line_or_address val;
+ int max_lines, dir;
struct symtab_and_line cursal = get_current_source_symtab_and_line ();
- content = (TuiWinContent) disassemWin->generic.content;
+ content = (tui_win_content) TUI_DISASM_WIN->generic.content;
if (cursal.symtab == (struct symtab *) NULL)
s = find_pc_symtab (get_frame_pc (deprecated_selected_frame));
else
s = cursal.symtab;
/* account for hilite */
- maxLines = disassemWin->generic.height - 2;
- pc = content[0]->whichElement.source.lineOrAddr.addr;
- dir = (scrollDirection == FORWARD_SCROLL) ? maxLines : - maxLines;
+ max_lines = TUI_DISASM_WIN->generic.height - 2;
+ pc = content[0]->which_element.source.line_or_addr.addr;
+ dir = (scroll_direction == FORWARD_SCROLL) ? max_lines : - max_lines;
val.addr = tui_find_disassembly_address (pc, dir);
- tuiUpdateSourceWindowAsIs (disassemWin, s, val, FALSE);
+ tui_update_source_window_as_is (TUI_DISASM_WIN, s, val, FALSE);
}
}