[DTrace-devel] [PATCH] Add a disassembly listing mode 0 (-xdisasm=1) for code generation

Eugene Loh eugene.loh at oracle.com
Thu Jun 24 18:42:09 PDT 2021


On 6/14/21 9:59 AM, Kris Van Hees wrote:

> I don't think we should add this to the overall code base because it is a
> truly development-time only feature.

I do not understand what distinction you're making here.  Certainly, the 
code base is full of developer hooks.  At least TRACE_REGSET comes to 
mind.  I assume DTRACE_DEBUG also, although I'm not familiar with it.  
But the most germane example would be -S and certainly -xdisasm.  In 
what sense are those for users?  They're for developers.

> While it can be useful during dev work
> for some, it can easily be done on a case-by-case basis or as a patch in a
> development branch.  But it also invites adding debugging statements that are
> under this mode 0 control that are really only of use to the developer who
> added them, which is again not soemthing that belongs in the public tree.

Presumably, additional statements would be subject to code review and 
judgment on a case-by-case basis.  Some desirable, some not.

> I'd be open to a much more minimal patch that adds a dt_dis_insn() function
> that is not used in the public tree, but that can easily be used in personal
> dev branches.  That would make doing so a lot less invasive, and I do think
> there is value in offering that.  Having to carry this more complex patch as
> a personal one is more tricky, so if we can make that easier with low impact
> changes in the public tree, I supprot that.

Anyhow, I split the patch up into pieces.  Hopefully, that will make 
these changes easier to negotiate.

> On Wed, Apr 14, 2021 at 12:50:20PM -0400, eugene.loh at oracle.com wrote:
>> From: Eugene Loh <eugene.loh at oracle.com>
>>
>> For debugging BPF instructions emitted during code generation, it
>> is useful to print debugging messages that are interwoven with
>> disassembled instructions.  Therefore, add disassembly support,
>> including a listing mode 0:
>>
>> x)  Move BPF ops out of dt_dis_difo(), so that they can
>>      be used for other functions as well.
>>
>> x)  Add a dt_dis_insn() to disassemble a single instruction.
>>
>> x)  Add listing mode numbers to disassembly headers.  These
>>      simple numbers help remind readers of the ordering of phases.
>>      and improve the correspondence between printed headers and
>>      the numerical values specified with -xdisasm.
>>
>> x)  Add a listing mode 0 (-xdisasm=1) that disassembles instructions
>>      one by one as they are produced by the code generator.
>>
>> x)  Remove the long-orphaned DT_DISASM macro.
>>
>> x)  Add a test of disassembly modes that checks that:
>>
>>      x  disassembly of all modes in one run is the same
>>         as what the various modes report individually
>>
>>      x  the default mode is correct
>>
>> Developers can add more -xdisasm=1 diagnostic messages to the code
>> generator like this:
>>
>> 	if (DT_DISASM_CODEGEN_COND(pcb))
>> 		fprintf(stderr, "hello world\n");
>>
>> Signed-off-by: Eugene Loh <eugene.loh at oracle.com>



More information about the DTrace-devel mailing list