Re: [PATCHv9 0/3] new gdb.Style API

Andrew Burgess
2025-10-06T09:02:44Z

Tom de Vries <tdevries@suse.de> writes:

> On 10/5/25 20:03, Andrew Burgess wrote:
>> Tom de Vries <tdevries@suse.de> writes:
>>
>>> On 10/5/25 14:51, Andrew Burgess wrote:
>>>> Tom Tromey <tom@tromey.com> writes:
>>>>
>>>>>>>>>> "Andrew" == Andrew Burgess <aburgess@redhat.com> writes:
>>>>>
>>>>> [...]
>>>>> Andrew> In v9:
>>>>>
>>>>> Going for a record here.
>>>>>
>>>>> I think these are ok. Thanks for doing this.
>>>>> Approved-By: Tom Tromey <tom@tromey.com>
>>>>
>>>> Pushed.
>>>
>>> Hi,
>>>
>>> I'm running into pre-commit failures:
>>
>> I searched on the GDB wiki, and did a grep in gdb/ and gdb/doc/ but
>> could find nothing about "pre-commit" except for one comment in
>> check-include-guards.py, but that doesn't say what "pre-commit" is.
>>
>> Is this process documented somewhere else? Or have I just failed at
>> finding it?
>>
>
> Hi Andrew,
>
> AFAIK there's not really a process, that is, there's no formal agreement
> on a requirement to run it. [ See also this email thread (
> https://sourceware.org/pipermail/gdb-patches/2025-October/221320.html )
> on the status of tclint as pre-commit hook. ]
>
> There's a file called .pre-commit-config.yaml in the root dir of the
> repository. I have added some information in there on how to install
> pre-commit, and how to skip some/all checks.

Thanks for the pointer.

Out of interest, is there any reason why these tests couldn't be (also
be) added as actual tests to GDB's testsuite?

I haven't tried setting up the infrastructure needed to run these tests
using the pre-commit framework yet, but I'm guessing the time needed to
run these tests is insignificant compared to the existing GDB testsuite.

Thanks,
Andrew

>
> Thanks,
> - Tom
>
>>> ...
>>> flake8...................................................................Failed
>>> - hook id: flake8
>>> - duration: 0.25s
>>> - exit code: 1
>>>
>>> gdb/python/lib/gdb/__init__.py:557:31: F405 'Parameter' may be
>>> undefined, or defined from star imports: _gdb
>>> gdb/python/lib/gdb/__init__.py:579:21: F405 'COMMAND_NONE' may be
>>> undefined, or defined from star imports: _gdb
>>> gdb/python/lib/gdb/__init__.py:612:21: F405 'Color' may be undefined, or
>>> defined from star imports: _gdb
>>> gdb/python/lib/gdb/__init__.py:613:21: F405 'PARAM_COLOR' may be
>>> undefined, or defined from star imports: _gdb
>>> ...
>>
>> The patch below doesn't break GDB's Python support. And based on the
>> existing code comments, I suspect this is the required fix. But I
>> haven't run the "pre-commit" tests (see comments above), so you might
>> one to check this fixes the issue you reported.
>>
>> Thanks,
>> Andrew
>>
>> ---
>>
>> commit 5812afb15e8b7774984c238eb67adcf6eaa704a9
>> Author: Andrew Burgess <aburgess@redhat.com>
>> Date: Sun Oct 5 18:55:33 2025 +0100
>>
>> gdb/python: fix some flake8 warnings related to Python code
>>
>> After these commits:
>>
>> * 49e4d0cdca3 gdb/python: add gdb.Style class
>> * d5214580a5f gdb/python: new class gdb.StyleParameterSet
>> * 3c724596812 gdb/python: extend gdb.write to support styled output
>>
>> the following issues were pointed out on the mailing list:
>>
>> I'm running into pre-commit failures:
>> ...
>> flake8...................................................................Failed
>> - hook id: flake8
>> - duration: 0.25s
>> - exit code: 1
>>
>> gdb/python/lib/gdb/__init__.py:557:31: F405 'Parameter' may be undefined, or defined from star imports: _gdb
>> gdb/python/lib/gdb/__init__.py:579:21: F405 'COMMAND_NONE' may be undefined, or defined from star imports: _gdb
>> gdb/python/lib/gdb/__init__.py:612:21: F405 'Color' may be undefined, or defined from star imports: _gdb
>> gdb/python/lib/gdb/__init__.py:613:21: F405 'PARAM_COLOR' may be undefined, or defined from star imports: _gdb
>>
>> I believe this patch should resolve these issues.
>>
>> diff --git a/gdb/python/lib/gdb/__init__.py b/gdb/python/lib/gdb/__init__.py
>> index 0388c6a2c00..65f76988925 100644
>> --- a/gdb/python/lib/gdb/__init__.py
>> +++ b/gdb/python/lib/gdb/__init__.py
>> @@ -34,6 +34,10 @@ from _gdb import (
>> parameter,
>> selected_inferior,
>> write,
>> + Parameter,
>> + COMMAND_NONE,
>> + Color,
>> + PARAM_COLOR,
>> )
>>
>> # isort: split
>>