public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
* [Bug dap/31354] New: [gdb/dap] FAIL: gdb.dap/pause.exp: python command failed
@ 2024-02-08  8:41 vries at gcc dot gnu.org
  2024-02-08 12:47 ` [Bug dap/31354] " vries at gcc dot gnu.org
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: vries at gcc dot gnu.org @ 2024-02-08  8:41 UTC (permalink / raw)
  To: gdb-prs

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

            Bug ID: 31354
           Summary: [gdb/dap] FAIL: gdb.dap/pause.exp: python command
                    failed
           Product: gdb
           Version: HEAD
            Status: NEW
          Severity: normal
          Priority: P2
         Component: dap
          Assignee: unassigned at sourceware dot org
          Reporter: vries at gcc dot gnu.org
  Target Milestone: ---

I found a problem in the gdb.dap/pause.exp test-case.

It generates a python file, but fails to use it.  This fixes it:
...
diff --git a/gdb/testsuite/gdb.dap/pause.exp b/gdb/testsuite/gdb.dap/pause.exp
index e1e0d957fc6..c1b12fc373c 100644
--- a/gdb/testsuite/gdb.dap/pause.exp
+++ b/gdb/testsuite/gdb.dap/pause.exp
@@ -130,7 +130,7 @@ dap_read_response cancel $cancel_id
 # does not continue the inferior) can be canceled.
 #

-write_file py "while True:\n  pass"
+set gdbfile [write_file py "while True:\n  pass"]
 set cont_id [dap_send_request evaluate \
                 [format {o expression [s "source %s"] context [s repl]} \
                      $gdbfile]]
...

Then we run into:
...
Running /home/vries/gdb/src/gdb/testsuite/gdb.dap/pause.exp ...
FAIL: gdb.dap/pause.exp: python command failed
WARNING: While evaluating expression in gdb_assert: key "message" not known in
dictionary

                === gdb Summary ===

# of expected passes            18
# of unexpected failures        1
# of unresolved testcases       1
...

In more detail:
...
>>> {"seq": 12, "type": "request", "command": "evaluate", "arguments": {"expression": "source /home/vries/gdb/build/gdb/testsuite/outputs/gdb.dap/pause/pause.py", "context": "repl"}}
>>> {"seq": 13, "type": "request", "command": "cancel", "arguments": {"requestId": 12}}
Content-Length: 327^M
^M
{"request_seq": 12, "type": "response", "command": "evaluate", "body":
{"result": "Traceback (most recent call last):\n  File
\"/home/vries/gdb/build/gdb/testsuite/outputs/gdb.dap/pause/pause.py\", line 1,
in <module>\n    while True:\n          ^^^^\nKeyboardInterrupt\n",
"variablesReference": 0}, "success": true, "seq": 28}Content-Length: 88^M
^M
{"request_seq": 13, "type": "response", "command": "cancel", "success": true,
"seq": 29}FAIL: gdb.dap/pause.exp: python command failed
WARNING: While evaluating expression in gdb_assert: key "message" not known in
dictionary
UNRESOLVED: gdb.dap/pause.exp: python command canceled
...

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

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

* [Bug dap/31354] [gdb/dap] FAIL: gdb.dap/pause.exp: python command failed
  2024-02-08  8:41 [Bug dap/31354] New: [gdb/dap] FAIL: gdb.dap/pause.exp: python command failed vries at gcc dot gnu.org
@ 2024-02-08 12:47 ` vries at gcc dot gnu.org
  2024-02-08 16:54 ` tromey at sourceware dot org
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: vries at gcc dot gnu.org @ 2024-02-08 12:47 UTC (permalink / raw)
  To: gdb-prs

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

--- Comment #1 from Tom de Vries <vries at gcc dot gnu.org> ---
So, AFAICT the following happens:
- dap calls gdb.interrupt to cancel a request
- in gdbpy_interrupt, the quit flag is set
- at the end of gdbpy_interrupt, the no_python_sigint destructor is called,
  which calls restore_active_language, during which check_quit_flag is called,
  followed by set_quit_flag
- this calls gdbpy_set_quit_flag, which calls PyErr_SetInterrupt
  (I'm not sure if that's legal at this point.  It's not necessary to hold the
GIL,
  but we're also in a PyEval_SaveThread context which has set thread state to
null).
- the interrupt is caught while executing the python script using
PyRun_SimpleFile,
  throwing a KeyboardInterrupt exception
- the KeyboardInterrupt propagates up to PyRun_SimpleFile, where the exception
is
  dumped on the output 
- PyRun_SimpleFile returns -1 because of the KeyboardInterrupt exception, but
  that's silently ignored by python_run_simple_file

The KeyboardInterrupt is intended to propagate all the way up to the python
runnable, which would capture the exception and hand it back to the dap thread,
but instead it's captured by PyRun_SimpleFile.

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

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

* [Bug dap/31354] [gdb/dap] FAIL: gdb.dap/pause.exp: python command failed
  2024-02-08  8:41 [Bug dap/31354] New: [gdb/dap] FAIL: gdb.dap/pause.exp: python command failed vries at gcc dot gnu.org
  2024-02-08 12:47 ` [Bug dap/31354] " vries at gcc dot gnu.org
@ 2024-02-08 16:54 ` tromey at sourceware dot org
  2024-02-15 18:55 ` tromey at sourceware dot org
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: tromey at sourceware dot org @ 2024-02-08 16:54 UTC (permalink / raw)
  To: gdb-prs

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

Tom Tromey <tromey at sourceware dot org> changed:

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

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

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

* [Bug dap/31354] [gdb/dap] FAIL: gdb.dap/pause.exp: python command failed
  2024-02-08  8:41 [Bug dap/31354] New: [gdb/dap] FAIL: gdb.dap/pause.exp: python command failed vries at gcc dot gnu.org
  2024-02-08 12:47 ` [Bug dap/31354] " vries at gcc dot gnu.org
  2024-02-08 16:54 ` tromey at sourceware dot org
@ 2024-02-15 18:55 ` tromey at sourceware dot org
  2024-02-16 18:38 ` tromey at sourceware dot org
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: tromey at sourceware dot org @ 2024-02-15 18:55 UTC (permalink / raw)
  To: gdb-prs

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

Tom Tromey <tromey at sourceware dot org> changed:

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

--- Comment #2 from Tom Tromey <tromey at sourceware dot org> ---
PyRun_SimpleFile doesn't let the caller access the error anyway.
I think we need to have gdb call something else here.

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

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

* [Bug dap/31354] [gdb/dap] FAIL: gdb.dap/pause.exp: python command failed
  2024-02-08  8:41 [Bug dap/31354] New: [gdb/dap] FAIL: gdb.dap/pause.exp: python command failed vries at gcc dot gnu.org
                   ` (2 preceding siblings ...)
  2024-02-15 18:55 ` tromey at sourceware dot org
@ 2024-02-16 18:38 ` tromey at sourceware dot org
  2024-02-27 16:56 ` cvs-commit at gcc dot gnu.org
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: tromey at sourceware dot org @ 2024-02-16 18:38 UTC (permalink / raw)
  To: gdb-prs

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

--- Comment #3 from Tom Tromey <tromey at sourceware dot org> ---
https://sourceware.org/pipermail/gdb-patches/2024-February/206626.html

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

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

* [Bug dap/31354] [gdb/dap] FAIL: gdb.dap/pause.exp: python command failed
  2024-02-08  8:41 [Bug dap/31354] New: [gdb/dap] FAIL: gdb.dap/pause.exp: python command failed vries at gcc dot gnu.org
                   ` (3 preceding siblings ...)
  2024-02-16 18:38 ` tromey at sourceware dot org
@ 2024-02-27 16:56 ` cvs-commit at gcc dot gnu.org
  2024-02-27 16:56 ` cvs-commit at gcc dot gnu.org
  2024-02-27 16:57 ` tromey at sourceware dot org
  6 siblings, 0 replies; 8+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2024-02-27 16:56 UTC (permalink / raw)
  To: gdb-prs

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

--- Comment #4 from Sourceware Commits <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=a207f6b3a384897be1dab081a0a9a206593029de

commit a207f6b3a384897be1dab081a0a9a206593029de
Author: Tom Tromey <tromey@adacore.com>
Date:   Thu Feb 15 13:14:43 2024 -0700

    Rewrite "python" command exception handling

    The "python" command (and the Python implementation of the gdb
    "source" command) does not handle Python exceptions in the same way as
    other gdb-facing Python code.  In particular, exceptions are turned
    into a generic error rather than being routed through
    gdbpy_handle_exception, which takes care of converting to 'quit' as
    appropriate.

    I think this was done this way because PyRun_SimpleFile and friends do
    not propagate the Python exception -- they simply indicate that one
    occurred.

    This patch reimplements these functions to respect the general gdb
    convention here.  As a bonus, some Windows-specific code can be
    removed, as can the _execute_file function.

    The bulk of this change is tweaking the test suite to match the new
    way that exceptions are displayed.  These changes are largely
    uninteresting.  However, it's worth pointing out the py-error.exp
    change.  Here, the failure changes because the test changes the host
    charset to something that isn't supported by Python.  This then
    results in a weird error in the new setup.

    Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=31354
    Acked-By: Tom de Vries <tdevries@suse.de>
    Reviewed-By: Eli Zaretskii <eliz@gnu.org>

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

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

* [Bug dap/31354] [gdb/dap] FAIL: gdb.dap/pause.exp: python command failed
  2024-02-08  8:41 [Bug dap/31354] New: [gdb/dap] FAIL: gdb.dap/pause.exp: python command failed vries at gcc dot gnu.org
                   ` (4 preceding siblings ...)
  2024-02-27 16:56 ` cvs-commit at gcc dot gnu.org
@ 2024-02-27 16:56 ` cvs-commit at gcc dot gnu.org
  2024-02-27 16:57 ` tromey at sourceware dot org
  6 siblings, 0 replies; 8+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2024-02-27 16:56 UTC (permalink / raw)
  To: gdb-prs

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

--- Comment #5 from Sourceware Commits <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=cfe51255b892962c25166cc0afd8911caf9e1e56

commit cfe51255b892962c25166cc0afd8911caf9e1e56
Author: Tom Tromey <tromey@adacore.com>
Date:   Fri Feb 16 10:39:46 2024 -0700

    Use the .py file in gdb.dap/pause.exp

    Tom de Vries pointed out that the gdb.dap/pause.exp test writes a
    Python file but then does not use it.  This patch corrects the
    oversight.

    Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=31354
    Reviewed-By: Tom de Vries <tdevries@suse.de>

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

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

* [Bug dap/31354] [gdb/dap] FAIL: gdb.dap/pause.exp: python command failed
  2024-02-08  8:41 [Bug dap/31354] New: [gdb/dap] FAIL: gdb.dap/pause.exp: python command failed vries at gcc dot gnu.org
                   ` (5 preceding siblings ...)
  2024-02-27 16:56 ` cvs-commit at gcc dot gnu.org
@ 2024-02-27 16:57 ` tromey at sourceware dot org
  6 siblings, 0 replies; 8+ messages in thread
From: tromey at sourceware dot org @ 2024-02-27 16:57 UTC (permalink / raw)
  To: gdb-prs

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

Tom Tromey <tromey at sourceware dot org> changed:

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

--- Comment #6 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] 8+ messages in thread

end of thread, other threads:[~2024-02-27 16:57 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-02-08  8:41 [Bug dap/31354] New: [gdb/dap] FAIL: gdb.dap/pause.exp: python command failed vries at gcc dot gnu.org
2024-02-08 12:47 ` [Bug dap/31354] " vries at gcc dot gnu.org
2024-02-08 16:54 ` tromey at sourceware dot org
2024-02-15 18:55 ` tromey at sourceware dot org
2024-02-16 18:38 ` tromey at sourceware dot org
2024-02-27 16:56 ` cvs-commit at gcc dot gnu.org
2024-02-27 16:56 ` cvs-commit at gcc dot gnu.org
2024-02-27 16:57 ` 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).