public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Tom Tromey <tom@tromey.com>
To: Hannes Domani via Gdb-patches <gdb-patches@sourceware.org>
Cc: Hannes Domani <ssbssa@yahoo.de>
Subject: Re: [PATCHv2 1/2] Implement locals TUI window
Date: Mon, 13 Nov 2023 13:07:59 -0700	[thread overview]
Message-ID: <8734x9s9gg.fsf@tromey.com> (raw)
In-Reply-To: <20210604162400.3255-1-ssbssa@yahoo.de> (Hannes Domani via Gdb-patches's message of "Fri, 4 Jun 2021 18:23:59 +0200")

>>>>> "Hannes" == Hannes Domani via Gdb-patches <gdb-patches@sourceware.org> writes:

I'm sorry about the extreme delay on this.

Hannes> gdb/ChangeLog:
Hannes> 2021-06-04  Hannes Domani  <ssbssa@yahoo.de>

Hannes> 	PR tui/17849
Hannes> 	* data-directory/Makefile.in: Add tui_windows.py.
Hannes> 	* python/lib/gdb/command/tui_windows.py: New file.

I recently became aware there was a v2 of this patch.  I must have
missed it when you originally sent it.

Hannes> +PY3 = sys.version_info[0] == 3
Hannes> +
Hannes> +if PY3:
Hannes> +    basestring = str

Can drop this now.

Hannes> +def val_cmp_color(prev, cur, sym_not_init, argument, empty=False):
Hannes> +    """Returns the color escape sequences for variable name and value."""
Hannes> +    var_col_s, var_col_e, val_col_s, val_col_e = "", "", "", ""
Hannes> +    if empty:
Hannes> +        # Variable without contents
Hannes> +        var_col_s, var_col_e = "\033[1;30m", "\033[0m"
Hannes> +    elif prev is None:
Hannes> +        # New variable
Hannes> +        var_col_s, var_col_e = "\033[1;32m", "\033[0m"
Hannes> +    elif prev != cur:
Hannes> +        # Variable contents changed
Hannes> +        val_col_s, val_col_e = "\033[1;31m", "\033[0m"
Hannes> +    if argument:
Hannes> +        # Variable is a function argument
Hannes> +        var_col_s, var_col_e = "\033[1;35m", "\033[0m"
Hannes> +    elif sym_not_init:
Hannes> +        # Variable was not yet initialized
Hannes> +        var_col_s, var_col_e = "\033[33m", "\033[0m"
Hannes> +    return (var_col_s, var_col_e, val_col_s, val_col_e)

Perhaps these should have 'set style' parameters?
Or reuse existing ones?

Hannes> +def is_string_element_type(t):
Hannes> +    """Return if an array of this type is considered a string."""
Hannes> +    target_type = t.target().strip_typedefs()
Hannes> +    return target_type.code == gdb.TYPE_CODE_INT and (
Hannes> +        target_type.name == "char" or is_typedef_of(t.target(), "wchar_t")
Hannes> +    )

There's a more direct way of doing some of this stuff now.
This code can probably reuse the work done for DAP.

Hannes> +class ArrayPrinter(object):
Hannes> +    """Pretty printer for arrays."""

Same for this and the other "no-op" printers.

Hannes> +class StructPrinter(object):
...
Hannes> +        for f in fields:
Hannes> +            if not hasattr(f, "bitpos"):
Hannes> +                continue

Oops, I think this points out a bug in NoOpStructPrinter.
I'll fix that.

Hannes> +            # Disable dynamic_type for base classes, to prevent infinite
Hannes> +            # recursion.
Hannes> +            if child_v.type.code == gdb.TYPE_CODE_STRUCT and f.is_base_class:
Hannes> +                pp = None
Hannes> +                if not self.raw:

Hmm I wonder if this is one as well.

Hannes> +                                if key is not None:
Hannes> +                                    self.add_val(
Hannes> +                                        "[" + str(key) + "]",
Hannes> +                                        fnc,
Hannes> +                                        vc,
Hannes> +                                        inset + 1,
Hannes> +                                        0,
Hannes> +                                        cur_vals,
Hannes> +                                        keep_prev,
Hannes> +                                        False,
Hannes> +                                        False,
Hannes> +                                        False,
Hannes> +                                        raw,
Hannes> +                                        fmt,
Hannes> +                                        None,
Hannes> +                                    )
Hannes> +                                else:
Hannes> +                                    self.add_val(
Hannes> +                                        "value",
Hannes> +                                        fnc,
Hannes> +                                        vc,
Hannes> +                                        inset + 1,
Hannes> +                                        0,
Hannes> +                                        cur_vals,
Hannes> +                                        keep_prev,
Hannes> +                                        False,
Hannes> +                                        False,
Hannes> +                                        False,
Hannes> +                                        raw,
Hannes> +                                        fmt,
Hannes> +                                        None,
Hannes> +                                    )

Some things like this could probably be simplified?

I found some of this code pretty hard to follow.

Tom

      parent reply	other threads:[~2023-11-13 20:08 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20210604162400.3255-1-ssbssa.ref@yahoo.de>
2021-06-04 16:23 ` Hannes Domani
2021-06-04 16:24   ` [PATCHv2 2/2] Use method children instead of to_string in pretty printers Hannes Domani
2021-07-17 19:19     ` Joel Brobecker
2023-11-13 20:07   ` Tom Tromey [this message]

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=8734x9s9gg.fsf@tromey.com \
    --to=tom@tromey.com \
    --cc=gdb-patches@sourceware.org \
    --cc=ssbssa@yahoo.de \
    /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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).