public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Tom Tromey <tom@tromey.com>
To: Simon Farre <simon.farre.cx@gmail.com>
Cc: gdb-patches@sourceware.org,  tom@tromey.org
Subject: Re: [PATCH v3 3/5] [dap & linetable]: Change gdb.LineTableEntry & Add gdb.lookup_linetable
Date: Wed, 07 Feb 2024 13:05:14 -0700	[thread overview]
Message-ID: <8734u4avlx.fsf@tromey.com> (raw)
In-Reply-To: <20240122133115.201205-3-simon.farre.cx@gmail.com> (Simon Farre's message of "Mon, 22 Jan 2024 14:31:13 +0100")

>>>>> "Simon" == Simon Farre <simon.farre.cx@gmail.com> writes:

Thanks for the patch.

Simon>  static PyObject *
Simon> -build_line_table_tuple_from_pcs (int line, const std::vector<CORE_ADDR> &pcs)
Simon> +build_line_table_tuple_from_pcs (int line, const symtab& sym, const std::vector<linetable_entry> &pcs)

gdb uses a line length around 80, so this should be split.
Also the "&" attaches to the "sym", not "symtab" -- this is also true
for "*" in gdb, there's a few instances of this around.

Simon> +/* Search for a symtab whose fullname contains FILENAME and return it's
Simon> +   linetable.  */
Simon> +PyObject *
Simon> +gdbpy_lookup_linetable_by_filename (PyObject *, PyObject *args, PyObject *kw)
Simon> +{
Simon> +  const char *arg = nullptr;
Simon> +  static const char *keywords[] = { "filename", nullptr };
Simon> +
Simon> +  if (!gdb_PyArg_ParseTupleAndKeywords (args, kw, "s", keywords, &arg))
Simon> +    {
Simon> +      return nullptr;
Simon> +    }

Don't need the braces here.

Simon> +
Simon> +  for (objfile *objfile : current_program_space->objfiles ())
Simon> +    for (compunit_symtab *cu : objfile->compunits ())
Simon> +      for (symtab *s : cu->filetabs ())
Simon> +	{
Simon> +	  const auto name = symtab_to_fullname (s);
Simon> +
Simon> +	  if (strstr (name, arg))

This doesn't seem like a great approach to me.
Substring matching isn't how this kind of thing works elsewhere in gdb.

Also this looping approach means that the symtab must somehow have
already been expanded.

Right now, the breakpointLocations request works by calling MI's
-symbol-list-lines.  This calls lookup_symtab, which in the end will try
expanding CUs to find the desired symtab.

Tom

  reply	other threads:[~2024-02-07 20:05 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-22 13:31 [PATCH v3 1/5] [dap & linetable]: Add column to linetable entry Simon Farre
2024-01-22 13:31 ` [PATCH v3 2/5] [dap & linetable]: Add column to maint info linetable output Simon Farre
2024-02-07 19:52   ` Tom Tromey
2024-01-22 13:31 ` [PATCH v3 3/5] [dap & linetable]: Change gdb.LineTableEntry & Add gdb.lookup_linetable Simon Farre
2024-02-07 20:05   ` Tom Tromey [this message]
2024-01-22 13:31 ` [PATCH v3 4/5] [dap & linetable]: Add breakpointLocations request Simon Farre
2024-02-07 19:44   ` Tom Tromey
2024-01-22 13:31 ` [PATCH v3 5/5] [dap & linetable]: Added docs Simon Farre
2024-02-07 19:28 ` [PATCH v3 1/5] [dap & linetable]: Add column to linetable entry Tom Tromey

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=8734u4avlx.fsf@tromey.com \
    --to=tom@tromey.com \
    --cc=gdb-patches@sourceware.org \
    --cc=simon.farre.cx@gmail.com \
    --cc=tom@tromey.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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).