New pseudo instruction CodeBuilder.setDebugOption

- liangchenblue at gmail.com
Sat Mar 9 21:13:15 UTC 2024


Oh, so you want more debugging info in error messages from CodeBuilder or
StackMapGenerator. That usually goes to the overall ClassFile object in our
current model. So you want to dump the instructions for the whole code upon
code building failure, but dumping stack for each instruction is quite
unrealistic. Your better bet would be a debugger.

On Sat, Mar 9, 2024 at 2:09 PM Øystein Myhre Andersen <o.myhre at gmail.com>
wrote:

> Do you have other ideas. Have you ever written a code generator for a
> compiler ?
>
> I don't think you understood the question
>
> On Sat, Mar 9, 2024 at 7:42 PM - <liangchenblue at gmail.com> wrote:
>
>> Hi Øystein,
>> I think this debug option in particular is quite limited; it can carry
>> only 2 integers. For the purpose of interleaved debugging instructions, I
>> think maybe expanding pseudo instructions to allow custom pseudo
>> instructions (such as from user-defined attributes) may be more applicable.
>>
>> If you mean general Class-File generation options, we usually keep them
>> in the ClassFile object, stored as one of the ClassFile.Options.
>>
>> Chen
>>
>> On Sat, Mar 9, 2024 at 11:42 AM Øystein Myhre Andersen <o.myhre at gmail.com>
>> wrote:
>>
>>> *Proposal:*
>>>
>>> Add a new  pseudo instruction:
>>>      CodeBuilder.setDebugOption(int kind, int level)
>>>
>>> Meaning:
>>> kind == 1 // CodeListing
>>>              2 .. n  // Reserved
>>>
>>> when kind == 1
>>> level == 0 // Off
>>>               1 // code listing as when "stack size mismatch" error.
>>>               2 // with additional Thread.dumpstack();
>>>               3 .. n  // Reserved
>>>
>>> Or something like it.
>>>
>>> *Motivation:*
>>>
>>> I am building a code generator for the Open Source Simula
>>> <https://portablesimula.github.io/github.io/> compiler.
>>>
>>> During debugging, it would be nice to be able to see the code that is
>>> generated and possibly where the individual instructions were generated
>>> from.
>>>
>>> This is particularly interesting for errors such as: "stack size
>>> mismatch", "operand stack underflow", etc.
>>>
>>>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/classfile-api-dev/attachments/20240309/8c47f9d5/attachment-0001.htm>


More information about the classfile-api-dev mailing list