[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: GDB integration and lexical cuckholding
From: |
Jose E. Marchesi |
Subject: |
Re: GDB integration and lexical cuckholding |
Date: |
Wed, 25 Sep 2024 12:01:12 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) |
> Hi Jose.
>
> On Wed, Sep 25, 2024 at 09:54:38AM GMT, Jose E. Marchesi wrote:
>>
>> > Hi Jose.
>> >
>> > On Tue, Sep 24, 2024 at 12:02:03PM GMT, Jose E. Marchesi wrote:
>> >>
>> >> Hi Mohammad.
>> >>
>> >> Among my notes I found this:
>> >>
>> >> ** TODO poke: gdb: disable lexical cuckolding in case of error in
>> >> compile-buffer!
>> >> [2023-05-12 Fri]
>> >>
>> >> It may be still relevant in the current code. Can you please take a
>> >> look?
>> >
>> >
>> > Can you elaborate a little?
>> > Lexical cuckolding continues to work after giving invalid code to Poke
>> > compiler.
>>
>> I don't remember exactly what prompted me to write down that note.
>>
>> But I think it was the fact that in the poke application lexical
>> cuckolding is enabled only when code is executed from the prompt.
>> Therefore, if you have this in a foo.pk:
>>
>> $<foo>;
>>
>> And then do:
>>
>> $ poke -l foo.pk
>> foo.pk:1:1: error: syntax error: unexpected token
>>
>> i.e. the token is not recognized. But if you load it from the prompt:
>>
>> (p0:big:poke) load foo
>> foo.pk:1:1: error: invalid IO space
>> $<foo>;
>> ^~~~~~
>>
>> i.e. now the token is recognized.
>>
>> I know think I wrote that note about poke, not the GDB integration,
>> because I see pk-cmd.c:pk_cmd_exec doesn't properly disable the lexical
>> cuckolding in case on error. I am pushing a patch to fix that.
>>
>
>
> Thanks for the explanation.
>
>
>> As for the GDB integration, if it makes sense to never turn off lexical
>> cuckolding then this is not an issue. But it is difficult to reason
>> about it without seeing the code. Can you please push it into a
>> personal branch in binutils-gdb.git?
>>
>
> Pushed to users/mnabipoor/poke-gdb branch.
Well you see, my note was actually for the GDB integration:
static void
poke_command (const char *args, int from_tty)
{
[...]
pk_set_lexical_cuckolding_p (poke_compiler (), 1);
if (pk_compile_* (...) != PK_OK || exit_exception != PK_NULL)
goto error;
pk_set_lexical_cuckolding_p (poke_compiler (), 0);
error:
[...]
}
i.e. when there is an error in pk_{compile,execute}_ the lexical
cuckolding is not properly reset. Just move the call down:
static void
poke_command (const char *args, int from_tty)
{
[...]
pk_set_lexical_cuckolding_p (poke_compiler (), 1);
if (pk_compile_* (...) != PK_OK || exit_exception != PK_NULL)
goto error;
error:
pk_set_lexical_cuckolding_p (poke_compiler (), 0);
[...]
}
I would also rename that label from `error' to `done' or similar.