public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
* [Bug gdb/29854] New: ^C should interrupt synchronous wait on cooked index completion
@ 2022-12-05 19:43 simon.marchi at polymtl dot ca
  2022-12-05 23:34 ` [Bug gdb/29854] " tromey at sourceware dot org
                   ` (9 more replies)
  0 siblings, 10 replies; 11+ messages in thread
From: simon.marchi at polymtl dot ca @ 2022-12-05 19:43 UTC (permalink / raw)
  To: gdb-prs

https://sourceware.org/bugzilla/show_bug.cgi?id=29854

            Bug ID: 29854
           Summary: ^C should interrupt synchronous wait on cooked index
                    completion
           Product: gdb
           Version: HEAD
            Status: NEW
          Severity: normal
          Priority: P2
         Component: gdb
          Assignee: unassigned at sourceware dot org
          Reporter: simon.marchi at polymtl dot ca
  Target Milestone: ---

Using commit 09a5d200e6166522e0d0a9276bd6b2227ac5ace1, I do:

$ ./gdb -nx -q --data-directory=data-directory
testsuite/outputs/gdb.gdb/selftest/xgdb
Reading symbols from testsuite/outputs/gdb.gdb/selftest/xgdb...
(gdb) b captured_main
^C

Creating the breakpoint takes some time, doing ^C does nothing.  Attaching to
GDB, I understood that it's because the main thread is waiting on the
`table->wait ()` call, waiting for worker threads to finish building the cooked
indices.  Not sure how we can do it, but it would be nice for ^C to interrupt
that table->wait call and generate a gdb_exception_quit.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug gdb/29854] ^C should interrupt synchronous wait on cooked index completion
  2022-12-05 19:43 [Bug gdb/29854] New: ^C should interrupt synchronous wait on cooked index completion simon.marchi at polymtl dot ca
@ 2022-12-05 23:34 ` tromey at sourceware dot org
  2022-12-06  0:00 ` tromey at sourceware dot org
                   ` (8 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: tromey at sourceware dot org @ 2022-12-05 23:34 UTC (permalink / raw)
  To: gdb-prs

https://sourceware.org/bugzilla/show_bug.cgi?id=29854

Tom Tromey <tromey at sourceware dot org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |tromey at sourceware dot org

--- Comment #1 from Tom Tromey <tromey at sourceware dot org> ---
This seems fine as long as it is just the wait that is
interrupted and not the scan.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug gdb/29854] ^C should interrupt synchronous wait on cooked index completion
  2022-12-05 19:43 [Bug gdb/29854] New: ^C should interrupt synchronous wait on cooked index completion simon.marchi at polymtl dot ca
  2022-12-05 23:34 ` [Bug gdb/29854] " tromey at sourceware dot org
@ 2022-12-06  0:00 ` tromey at sourceware dot org
  2022-12-06  2:38 ` simark at simark dot ca
                   ` (7 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: tromey at sourceware dot org @ 2022-12-06  0:00 UTC (permalink / raw)
  To: gdb-prs

https://sourceware.org/bugzilla/show_bug.cgi?id=29854

--- Comment #2 from Tom Tromey <tromey at sourceware dot org> ---
There doesn't seem to be a good way to interrupt future::wait,
but I suppose the code could use the wait_for variant and check
the quit flag in a loop.

I'm also curious why this is taking long enough to notice.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug gdb/29854] ^C should interrupt synchronous wait on cooked index completion
  2022-12-05 19:43 [Bug gdb/29854] New: ^C should interrupt synchronous wait on cooked index completion simon.marchi at polymtl dot ca
  2022-12-05 23:34 ` [Bug gdb/29854] " tromey at sourceware dot org
  2022-12-06  0:00 ` tromey at sourceware dot org
@ 2022-12-06  2:38 ` simark at simark dot ca
  2022-12-06 15:05 ` tromey at sourceware dot org
                   ` (6 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: simark at simark dot ca @ 2022-12-06  2:38 UTC (permalink / raw)
  To: gdb-prs

https://sourceware.org/bugzilla/show_bug.cgi?id=29854

Simon Marchi <simark at simark dot ca> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |simark at simark dot ca

--- Comment #3 from Simon Marchi <simark at simark dot ca> ---
(In reply to Tom Tromey from comment #1)
> This seems fine as long as it is just the wait that is
> interrupted and not the scan.

Yes, that's what I was thinking, just interrupt the main thread's wait.

> There doesn't seem to be a good way to interrupt future::wait,
> but I suppose the code could use the wait_for variant and check
> the quit flag in a loop.

Meh :(.

> I'm also curious why this is taking long enough to notice.

I'm running my unoptimized build of GDB on itself (test gdb.gdb/selftest.exp). 
So arguably not a very important use case.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug gdb/29854] ^C should interrupt synchronous wait on cooked index completion
  2022-12-05 19:43 [Bug gdb/29854] New: ^C should interrupt synchronous wait on cooked index completion simon.marchi at polymtl dot ca
                   ` (2 preceding siblings ...)
  2022-12-06  2:38 ` simark at simark dot ca
@ 2022-12-06 15:05 ` tromey at sourceware dot org
  2022-12-06 15:34 ` simark at simark dot ca
                   ` (5 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: tromey at sourceware dot org @ 2022-12-06 15:05 UTC (permalink / raw)
  To: gdb-prs

https://sourceware.org/bugzilla/show_bug.cgi?id=29854

--- Comment #4 from Tom Tromey <tromey at sourceware dot org> ---
Created attachment 14484
  --> https://sourceware.org/bugzilla/attachment.cgi?id=14484&action=edit
patch

I couldn't really test this, but maybe you can?

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug gdb/29854] ^C should interrupt synchronous wait on cooked index completion
  2022-12-05 19:43 [Bug gdb/29854] New: ^C should interrupt synchronous wait on cooked index completion simon.marchi at polymtl dot ca
                   ` (3 preceding siblings ...)
  2022-12-06 15:05 ` tromey at sourceware dot org
@ 2022-12-06 15:34 ` simark at simark dot ca
  2022-12-06 19:09 ` tromey at sourceware dot org
                   ` (4 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: simark at simark dot ca @ 2022-12-06 15:34 UTC (permalink / raw)
  To: gdb-prs

https://sourceware.org/bugzilla/show_bug.cgi?id=29854

--- Comment #5 from Simon Marchi <simark at simark dot ca> ---
(In reply to Tom Tromey from comment #4)
> Created attachment 14484 [details]
> patch
> 
> I couldn't really test this, but maybe you can?

It works.

For fun, I added a "maintenance wait-finalize" command, that does:

static void
maintenance_wait_finalize (const char *args, int from_tty)
{
  inferior *inf = current_inferior ();

  for (objfile *o : inf->pspace->objfiles ())
    {
      dwarf_scanner_base *s
        = get_dwarf2_per_objfile (o)->per_bfd->index_table.get ();
      cooked_index_vector *v = dynamic_cast<cooked_index_vector *> (s);
      if (!v)
        continue;

      printf("Waiting for %s\n", objfile_name (o));
      v->wait ();
    }
}

This way, I can measure how much time GDB takes to make the index with:

$ /usr/bin/time ./gdb -nx -q --data-directory=data-directory
testsuite/outputs/gdb.gdb/selftest/xgdb -ex "maint wait-finalize" -batch

With my unoptimized build, it takes about 30 seconds.  With my optimized build
(on the same binary), it takes 2 seconds.  I noticed this, because I would
start gdb.gdb/selftest.exp, then try to interrupt with ^C during the "break
captured_main" command, and runtest would hang for a while, waiting for the GDB
process to exit.

So, it's not really important to fix this, but it fixes an annoyance.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug gdb/29854] ^C should interrupt synchronous wait on cooked index completion
  2022-12-05 19:43 [Bug gdb/29854] New: ^C should interrupt synchronous wait on cooked index completion simon.marchi at polymtl dot ca
                   ` (4 preceding siblings ...)
  2022-12-06 15:34 ` simark at simark dot ca
@ 2022-12-06 19:09 ` tromey at sourceware dot org
  2022-12-06 19:29 ` tromey at sourceware dot org
                   ` (3 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: tromey at sourceware dot org @ 2022-12-06 19:09 UTC (permalink / raw)
  To: gdb-prs

https://sourceware.org/bugzilla/show_bug.cgi?id=29854

--- Comment #6 from Tom Tromey <tromey at sourceware dot org> ---
> With my unoptimized build, it takes about 30 seconds.  With my optimized build
> (on the same binary), it takes 2 seconds.

Wow.  I knew optimization mattered for DWARF reading (maybe the only
spot it does for gdb), but I didn't realize the effect was so big :)

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug gdb/29854] ^C should interrupt synchronous wait on cooked index completion
  2022-12-05 19:43 [Bug gdb/29854] New: ^C should interrupt synchronous wait on cooked index completion simon.marchi at polymtl dot ca
                   ` (5 preceding siblings ...)
  2022-12-06 19:09 ` tromey at sourceware dot org
@ 2022-12-06 19:29 ` tromey at sourceware dot org
  2022-12-25 19:55 ` tromey at sourceware dot org
                   ` (2 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: tromey at sourceware dot org @ 2022-12-06 19:29 UTC (permalink / raw)
  To: gdb-prs

https://sourceware.org/bugzilla/show_bug.cgi?id=29854

Tom Tromey <tromey at sourceware dot org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Assignee|unassigned at sourceware dot org   |tromey at sourceware dot org

--- Comment #7 from Tom Tromey <tromey at sourceware dot org> ---
https://sourceware.org/pipermail/gdb-patches/2022-December/194527.html

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug gdb/29854] ^C should interrupt synchronous wait on cooked index completion
  2022-12-05 19:43 [Bug gdb/29854] New: ^C should interrupt synchronous wait on cooked index completion simon.marchi at polymtl dot ca
                   ` (6 preceding siblings ...)
  2022-12-06 19:29 ` tromey at sourceware dot org
@ 2022-12-25 19:55 ` tromey at sourceware dot org
  2023-02-09 14:35 ` cvs-commit at gcc dot gnu.org
  2023-02-09 14:35 ` tromey at sourceware dot org
  9 siblings, 0 replies; 11+ messages in thread
From: tromey at sourceware dot org @ 2022-12-25 19:55 UTC (permalink / raw)
  To: gdb-prs

https://sourceware.org/bugzilla/show_bug.cgi?id=29854

Tom Tromey <tromey at sourceware dot org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Blocks|                            |29366


Referenced Bugs:

https://sourceware.org/bugzilla/show_bug.cgi?id=29366
[Bug 29366] [meta] New DWARF indexer meta bug
-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug gdb/29854] ^C should interrupt synchronous wait on cooked index completion
  2022-12-05 19:43 [Bug gdb/29854] New: ^C should interrupt synchronous wait on cooked index completion simon.marchi at polymtl dot ca
                   ` (7 preceding siblings ...)
  2022-12-25 19:55 ` tromey at sourceware dot org
@ 2023-02-09 14:35 ` cvs-commit at gcc dot gnu.org
  2023-02-09 14:35 ` tromey at sourceware dot org
  9 siblings, 0 replies; 11+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-02-09 14:35 UTC (permalink / raw)
  To: gdb-prs

https://sourceware.org/bugzilla/show_bug.cgi?id=29854

--- Comment #8 from cvs-commit at gcc dot gnu.org <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Tom Tromey <tromey@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=307733cc0fa864fcb92f4c308a0a27d17552df37

commit 307733cc0fa864fcb92f4c308a0a27d17552df37
Author: Tom Tromey <tromey@adacore.com>
Date:   Tue Dec 6 08:05:28 2022 -0700

    Let user C-c when waiting for DWARF index finalization

    In PR gdb/29854, Simon pointed out that it would be good to be able to
    use C-c when the DWARF cooked index is waiting for finalization.  The
    idea here is to be able to interrupt a command like "break" -- not to
    stop the finalization process itself, which runs in a worker thread.

    This patch implements this idea, by changing the index wait functions
    to, by default, allow a quit.  Polling is done, because there doesn't
    seem to be a better way to interrupt a wait on a std::future.

    For v2, I realized that the thread compatibility code in thread-pool.h
    also needed an update.

    Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=29854

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug gdb/29854] ^C should interrupt synchronous wait on cooked index completion
  2022-12-05 19:43 [Bug gdb/29854] New: ^C should interrupt synchronous wait on cooked index completion simon.marchi at polymtl dot ca
                   ` (8 preceding siblings ...)
  2023-02-09 14:35 ` cvs-commit at gcc dot gnu.org
@ 2023-02-09 14:35 ` tromey at sourceware dot org
  9 siblings, 0 replies; 11+ messages in thread
From: tromey at sourceware dot org @ 2023-02-09 14:35 UTC (permalink / raw)
  To: gdb-prs

https://sourceware.org/bugzilla/show_bug.cgi?id=29854

Tom Tromey <tromey at sourceware dot org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
   Target Milestone|---                         |14.1
         Resolution|---                         |FIXED

--- Comment #9 from Tom Tromey <tromey at sourceware dot org> ---
Fixed.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2023-02-09 14:35 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-12-05 19:43 [Bug gdb/29854] New: ^C should interrupt synchronous wait on cooked index completion simon.marchi at polymtl dot ca
2022-12-05 23:34 ` [Bug gdb/29854] " tromey at sourceware dot org
2022-12-06  0:00 ` tromey at sourceware dot org
2022-12-06  2:38 ` simark at simark dot ca
2022-12-06 15:05 ` tromey at sourceware dot org
2022-12-06 15:34 ` simark at simark dot ca
2022-12-06 19:09 ` tromey at sourceware dot org
2022-12-06 19:29 ` tromey at sourceware dot org
2022-12-25 19:55 ` tromey at sourceware dot org
2023-02-09 14:35 ` cvs-commit at gcc dot gnu.org
2023-02-09 14:35 ` tromey at sourceware dot org

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).