From: Hannes Domani <ssbssa@yahoo.de>
To: gdb-patches@sourceware.org
Subject: [PATCH 6/6] Show column of current execution point in TUI
Date: Sat, 16 May 2020 19:26:33 +0200 [thread overview]
Message-ID: <20200516172632.4803-7-ssbssa@yahoo.de> (raw)
In-Reply-To: <20200516172632.4803-1-ssbssa@yahoo.de>
---
gdb/tui/tui-data.h | 6 +++++-
gdb/tui/tui-source.c | 18 ++++++++++++------
gdb/tui/tui-stack.c | 2 ++
gdb/tui/tui-stack.h | 1 +
gdb/tui/tui-winsource.c | 35 +++++++++++++++++++++++++++++++++--
gdb/tui/tui-winsource.h | 9 +++++++--
6 files changed, 60 insertions(+), 11 deletions(-)
diff --git a/gdb/tui/tui-data.h b/gdb/tui/tui-data.h
index 2dc73b963d..1b36b5930d 100644
--- a/gdb/tui/tui-data.h
+++ b/gdb/tui/tui-data.h
@@ -148,7 +148,11 @@ struct tui_line_or_address
enum tui_line_or_address_kind loa;
union
{
- int line_no;
+ struct
+ {
+ int line_no;
+ int column_no;
+ };
CORE_ADDR addr;
} u;
};
diff --git a/gdb/tui/tui-source.c b/gdb/tui/tui-source.c
index fd5bd7dd96..c82647c0a4 100644
--- a/gdb/tui/tui-source.c
+++ b/gdb/tui/tui-source.c
@@ -93,20 +93,25 @@ tui_source_window::set_contents (struct gdbarch *arch,
{
struct tui_source_element *element = &m_content[cur_line];
- std::string text;
- if (*iter != '\0')
- text = tui_copy_source_line (&iter, cur_line_no,
- m_horizontal_offset,
- line_width, digits);
-
/* Set whether element is the execution point
and whether there is a break point on it. */
element->line_or_addr.loa = LOA_LINE;
element->line_or_addr.u.line_no = cur_line_no;
+ element->line_or_addr.u.column_no = 0;
element->is_exec_point
= (filename_cmp (locator->full_name.c_str (),
symtab_to_fullname (s)) == 0
&& cur_line_no == locator->line_no);
+ element->exec_column = element->is_exec_point ? locator->column_no : 0;
+
+ std::string text;
+ int column = element->exec_column;
+ if (*iter != '\0')
+ text = tui_copy_source_line (&iter, cur_line_no,
+ m_horizontal_offset,
+ line_width, digits, &column);
+ if (element->is_exec_point)
+ element->line_or_addr.u.column_no = column;
m_content[cur_line].line = std::move (text);
@@ -212,6 +217,7 @@ tui_source_window::maybe_update (struct frame_info *fi, symtab_and_line sal)
l.loa = LOA_LINE;
l.u.line_no = sal.line;
+ l.u.column_no = sal.column;
set_is_exec_point_at (l);
}
}
diff --git a/gdb/tui/tui-stack.c b/gdb/tui/tui-stack.c
index f1e075a3d2..052a11ec30 100644
--- a/gdb/tui/tui-stack.c
+++ b/gdb/tui/tui-stack.c
@@ -271,12 +271,14 @@ tui_locator_window::set_locator_info (struct gdbarch *gdbarch_in,
locator_changed_p |= proc_name != procname;
locator_changed_p |= sal.line != line_no;
+ locator_changed_p |= sal.column != column_no;
locator_changed_p |= sal.pc != addr;
locator_changed_p |= gdbarch_in != gdbarch;
locator_changed_p |= full_name != fullname;
proc_name = procname;
line_no = sal.line;
+ column_no = sal.column;
addr = sal.pc;
gdbarch = gdbarch_in;
set_locator_fullname (fullname);
diff --git a/gdb/tui/tui-stack.h b/gdb/tui/tui-stack.h
index fde7c6dd2c..13e4f9537b 100644
--- a/gdb/tui/tui-stack.h
+++ b/gdb/tui/tui-stack.h
@@ -62,6 +62,7 @@ struct tui_locator_window : public tui_gen_win_info
std::string full_name;
std::string proc_name;
int line_no = 0;
+ int column_no = 0;
CORE_ADDR addr = 0;
/* Architecture associated with code at this location. */
struct gdbarch *gdbarch = nullptr;
diff --git a/gdb/tui/tui-winsource.c b/gdb/tui/tui-winsource.c
index db0add9968..24bacbbb18 100644
--- a/gdb/tui/tui-winsource.c
+++ b/gdb/tui/tui-winsource.c
@@ -66,7 +66,7 @@ tui_display_main ()
std::string
tui_copy_source_line (const char **ptr, int line_no, int first_col,
- int line_width, int ndigits)
+ int line_width, int ndigits, int *exec_column)
{
const char *lineptr = *ptr;
@@ -87,6 +87,7 @@ tui_copy_source_line (const char **ptr, int line_no, int first_col,
}
int column = 0;
+ int raw_column = 0;
char c;
do
{
@@ -105,6 +106,7 @@ tui_copy_source_line (const char **ptr, int line_no, int first_col,
++lineptr;
++column;
+ ++raw_column;
auto process_tab = [&] ()
{
@@ -127,6 +129,12 @@ tui_copy_source_line (const char **ptr, int line_no, int first_col,
continue;
}
+ if (exec_column != nullptr && *exec_column == raw_column)
+ {
+ *exec_column = result.size ();
+ exec_column = nullptr;
+ }
+
if (c == '\n' || c == '\r' || c == '\0')
{
/* Nothing. */
@@ -152,6 +160,9 @@ tui_copy_source_line (const char **ptr, int line_no, int first_col,
++lineptr;
*ptr = lineptr;
+ if (exec_column != nullptr)
+ *exec_column = 0;
+
return result;
}
@@ -261,7 +272,20 @@ tui_source_window_base::show_source_line (int lineno)
tui_set_reverse_mode (handle.get (), true);
wmove (handle.get (), lineno, TUI_EXECINFO_SIZE);
- tui_puts (line->line.c_str (), handle.get ());
+ if (line->is_exec_point && line->line_or_addr.u.column_no > 0
+ && line->line_or_addr.u.column_no < line->line.size ())
+ {
+ /* Mark the column by disabling the reverse mode for the
+ corresponding character. */
+ int column = line->line_or_addr.u.column_no;
+ tui_puts (line->line.substr (0, column).c_str (), handle.get ());
+ tui_set_reverse_mode (handle.get (), false);
+ tui_puts (line->line.substr (column, 1).c_str (), handle.get ());
+ tui_set_reverse_mode (handle.get (), true);
+ tui_puts (line->line.substr (column + 1).c_str (), handle.get ());
+ }
+ else
+ tui_puts (line->line.c_str (), handle.get ());
if (line->is_exec_point)
tui_set_reverse_mode (handle.get (), false);
@@ -411,8 +435,15 @@ tui_source_window_base::set_is_exec_point_at (struct tui_line_or_address l)
{
changed = true;
m_content[i].is_exec_point = new_state;
+ m_content[i].exec_column = l.loa == LOA_LINE ? l.u.column_no : 0;
show_source_line (i + 1);
}
+ else if (new_state && m_content[i].is_exec_point && l.loa == LOA_LINE
+ && m_content[i].exec_column != l.u.column_no)
+ {
+ changed = true;
+ m_content[i].exec_column = l.u.column_no;
+ }
i++;
}
if (changed)
diff --git a/gdb/tui/tui-winsource.h b/gdb/tui/tui-winsource.h
index 501dd31ccf..8810ba1dd6 100644
--- a/gdb/tui/tui-winsource.h
+++ b/gdb/tui/tui-winsource.h
@@ -58,6 +58,7 @@ struct tui_source_element
: line (std::move (other.line)),
line_or_addr (other.line_or_addr),
is_exec_point (other.is_exec_point),
+ exec_column (other.exec_column),
break_mode (other.break_mode)
{
}
@@ -65,6 +66,7 @@ struct tui_source_element
std::string line;
struct tui_line_or_address line_or_addr;
bool is_exec_point = false;
+ int exec_column = 0;
tui_bp_flags break_mode = 0;
};
@@ -250,11 +252,14 @@ extern void tui_update_source_windows_with_line (struct symtab_and_line sal);
digits are used; otherwise the line number is formatted with 6
digits and the text is aligned to the next tab stop. Returns a
string holding the desired text. PTR is updated to point to the
- start of the next line. */
+ start of the next line.
+ If EXEC_COLUMN is supplied, it is updated to the position of the
+ specified colum in the returned string. */
extern std::string tui_copy_source_line (const char **ptr,
int line_no, int first_col,
- int line_width, int ndigits);
+ int line_width, int ndigits,
+ int *exec_column = nullptr);
/* Constant definitions. */
#define SCROLL_THRESHOLD 2 /* Threshold for lazy scroll. */
--
2.26.2
next prev parent reply other threads:[~2020-05-16 17:28 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20200516172632.4803-1-ssbssa.ref@yahoo.de>
2020-05-16 17:26 ` [RFC][PATCH 0/6] Step program considering the source column information Hannes Domani
2020-05-16 17:26 ` [PATCH 1/6] Add column information of dwarf to the symbol information Hannes Domani
2020-05-18 16:17 ` Tom Tromey
2020-05-19 12:23 ` Luis Machado
2020-05-16 17:26 ` [PATCH 2/6][PR gdb/25913] Implement nextc and stepc commands Hannes Domani
2020-05-16 17:26 ` [PATCH 3/6] Add column information to maint info line-table Hannes Domani
2020-05-16 17:26 ` [PATCH 4/6] Add LineTableEntry.column to python line table interface Hannes Domani
2020-05-27 13:50 ` Tom de Vries
2020-05-27 14:36 ` Tom Tromey
2020-05-16 17:26 ` [PATCH 5/6][PR gdb/25911] Show column of current execution point in frame info Hannes Domani
2020-05-18 16:20 ` Tom Tromey
2020-05-18 16:37 ` Hannes Domani
2020-05-19 14:51 ` Tom Tromey
2020-05-16 17:26 ` Hannes Domani [this message]
2020-05-16 18:45 ` [RFC][PATCH 0/6] Step program considering the source column information Pedro Alves
2020-05-17 0:08 ` Hannes Domani
2020-05-18 16:21 ` Tom Tromey
2020-05-18 16:28 ` Hannes Domani
2020-05-19 12:27 ` Luis Machado
2020-05-19 16:02 ` Hannes Domani
2020-05-27 15:33 ` Tom de Vries
2020-05-27 16:04 ` Hannes Domani
2020-06-02 9:08 ` Tom de Vries
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200516172632.4803-7-ssbssa@yahoo.de \
--to=ssbssa@yahoo.de \
--cc=gdb-patches@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox