Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Debugger hangs when a breakpoint is hit in the presence of a frame-filter #13282

Open
TSonono opened this issue Feb 14, 2025 · 1 comment
Open
Labels
bug debugger help wanted Can be fixed in the public (open source) repo.

Comments

@TSonono
Copy link

TSonono commented Feb 14, 2025

Environment

  • OS and version: Windows 11 Enterprise 23H2
  • VS Code: 1.97.2
  • C/C++ extension: v1.23.6
  • OS and version of remote machine (if applicable): SUSE Linux Enterprise Server 15-SP4
  • GDB / LLDB version: GDB 14.1

Bug Summary and Steps to Reproduce

Bug Summary: The debugger hangs when a breakpoint is hit in the presence of a GDB frame-filter. This happens even if the frame filter is returning an untouched frame iterator. No such issues occur when running GDB directly from CLI.

Steps to reproduce:

  1. Place a breakpoint that will be hit during program execution.
  2. Run a program.
  3. Attach to it using the provided debugger configuration (I assume this bug is also applicable for launch requests)
  4. Have the program hit a breakpoint
  5. Observe that the debugger hangs when a breakpoint is hit.

I'm submitting this issue since I think it would be really nice to be able to use the cppdbg debugger while having a frame filter applied.

Debugger Configurations

launch.json:


{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "(gdb) Attach",
            "type": "cppdbg",
            "request": "attach",
            "program": "a.out",
            "MIMode": "gdb",
            "setupCommands": [
                {
                    "description": "Enable pretty-printing for gdb",
                    "text": "-enable-pretty-printing",
                    "ignoreFailures": true
                },
                {
                    "description": "Set Disassembly Flavor to Intel",
                    "text": "-gdb-set disassembly-flavor intel",
                    "ignoreFailures": true
                },
                {
                    "description": "Source frame-filter",
                    "text": "source <path-to-frame-filter-py>"
                    "ignoreFailures": true
                },
                {
                    "description": "Enable frame filters",
                    "text": "-enable-frame-filters",
                    "ignoreFailures": true
                }
            ],
            logging: {
                "engineLogging": true,
                "trace": true,
                "traceResponse": true
            }
        }
    ]
}

Debugger Logs

--> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (8566) ->(gdb)\n"},"seq":1302}
1: (8566) ->(gdb)
--> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (8567) 1035: elapsed time 26\n"},"seq":1304}
1: (8567) 1035: elapsed time 26
--> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (8573) Send Event AD7BreakpointEvent\n"},"seq":1306}
1: (8573) Send Event AD7BreakpointEvent
--> E (output): {"type":"event","event":"output","body":{"category":"console","output":"Execute debugger commands using \"-exec <command>\", for example \"-exec info registers\" will list registers in use (when GDB is the debugger)\n"},"seq":1308}
Execute debugger commands using "-exec <command>", for example "-exec info registers" will list registers in use (when GDB is the debugger)
--> E (stopped): {"type":"event","event":"stopped","body":{"reason":"breakpoint","threadId":135549,"allThreadsStopped":true,"source":{"name":"extended-capabilities.dml","path":"/disk2/tsonono/repos/simics-base/src/devices/dml-lib/pcie/extended-capabilities.dml","sources":[],"checksums":[]},"line":246,"column":1},"seq":1310}
<--   C (threads-15): {"command":"threads","type":"request","seq":15}
--> R (threads-15): {"type":"response","request_seq":15,"success":true,"command":"threads","body":{"threads":[{"id":135549,"name":"mini-python [135549]"},{"id":135566,"name":"mini-python [135566]"},{"id":135568,"name":"mini-python [135568]"},{"id":135570,"name":"mini-python [135570]"},{"id":135571,"name":"mini-python [135571]"},{"id":135580,"name":"mini-python [135580]"},{"id":136031,"name":"simics-poll [136031]"}]},"seq":1313}
<--   C (stackTrace-16): {"command":"stackTrace","arguments":{"threadId":135549,"startFrame":0,"levels":20},"type":"request","seq":16}
--> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (8749) <-1036-list-features\n"},"seq":1316}
1: (8749) <-1036-list-features
--> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (8749) ->1036^done,features=[\"frozen-varobjs\",\"pending-breakpoints\",\"thread-info\",\"data-read-memory-bytes\",\"breakpoint-notifications\",\"ada-task-info\",\"language-option\",\"info-gdb-mi-command\",\"undefined-command-error-code\",\"exec-run-start-option\",\"data-disassemble-a-option\",\"simple-values-ref-types\",\"python\"]\n"},"seq":1318}
1: (8749) ->1036^done,features=["frozen-varobjs","pending-breakpoints","thread-info","data-read-memory-bytes","breakpoint-notifications","ada-task-info","language-option","info-gdb-mi-command","undefined-command-error-code","exec-run-start-option","data-disassemble-a-option","simple-values-ref-types","python"]
--> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (8749) ->(gdb)\n"},"seq":1320}
1: (8749) ->(gdb)
--> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (8751) 1036: elapsed time 2\n"},"seq":1322}
1: (8751) 1036: elapsed time 2
--> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (8753) <-1037-stack-list-arguments --thread 1 2 0 84\n"},"seq":1324}
1: (8753) <-1037-stack-list-arguments --thread 1 2 0 84

Additional information

It's always the -stack-list-arguments that is the last command in the trace.

My frame_filter.py file:

import gdb

class FrameFilter():

    def __init__(self):
        # Frame filter attribute creation.
        #
        # 'name' is the name of the filter that GDB will display.
        #
        # 'priority' is the priority of the filter relative to other
        # filters.
        #
        # 'enabled' is a boolean that indicates whether this filter is
        # enabled and should be executed.

        self.name = "Foo"
        self.priority = 100
        self.enabled = True

        # Register this frame filter with the global frame_filters
        # dictionary.
        gdb.frame_filters[self.name] = self

    def filter(self, frame_iter):
        return frame_iter

FrameFilter()
Copy link

Thank you for reporting this issue. We’ll let you know if we need more information to investigate it. Additionally, if you're working with GDB/LLDB, please note that the code is open source at https://github.com/microsoft/MIEngine/wiki/Contributing-Code . Your contributions are always welcome and appreciated.

@github-actions github-actions bot added the help wanted Can be fixed in the public (open source) repo. label Feb 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug debugger help wanted Can be fixed in the public (open source) repo.
Projects
None yet
Development

No branches or pull requests

2 participants