You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Change dis output to display labels instead of offsets #112137
Since a label can appear as a jump target and in the exception table, maybe just use l1, etc instead of j1 and h1?
Also, do we want labels to the left or right of line numbers, and do we want them on their own lines or on the same line?
If we have them on their own lines, it uses more vertical space, but less width, which is easier to read:
I still find it jarring to see the labels to the left of the line numbers. I'm so used to line numbers being the leftmost piece of information in any presentation where they are relevant. I think this would also make it easier to guess the difference between the two numbers (line and offset).
Finally. Is it time to switch to instruction indices, from byte offsets? This would halve the numbers, and make it easier to correlate them to things actually found in variables or other debug output (e.g. lltrace).
I think it would be nice to have -- instead of None for no line number.
None is the value you get from code.co_lines() for those instructions.
What is the advantage of --?
Is it time to switch to instruction indices, from byte offsets?
You mean code unit offsets, not instruction offsets?
Instructions are of differing lengths. They happen to all be a multiple of 2 at the moment, but they weren't in the past and might not be in the future.
Perhaps we should make the default what we have now (for backwards compatibility, not because it is the best or prettiest) and allow the user to choose the format.
For example, --format=JLIA would mean "Jump-targets Lines Instruction Arguments"
The default being LOIA (Line Offset Instruction Argument)
Activity
iritkatriel commentedon Nov 16, 2023
More ideas:
For example:
For this code:
markshannon commentedon Nov 17, 2023
In theory a disassembler should produce "assembly code" that is a human writable form of the underlying (virtual) machine code.
I don't think I would want to add those vertical bars by hand.
Would start and end labels work? Like this:
markshannon commentedon Nov 17, 2023
Since a label can appear as a jump target and in the exception table, maybe just use
l1, etc instead ofj1andh1?Also, do we want labels to the left or right of line numbers, and do we want them on their own lines or on the same line?
If we have them on their own lines, it uses more vertical space, but less width, which is easier to read:
iritkatriel commentedon Nov 17, 2023
I have this now:
iritkatriel commentedon Nov 21, 2023
New version with labels not on their own line, and an option to include offsets:
iritkatriel commentedon Nov 21, 2023
I think it would be nice to have
--instead ofNonefor no line number.gvanrossum commentedon Nov 21, 2023
I still find it jarring to see the labels to the left of the line numbers. I'm so used to line numbers being the leftmost piece of information in any presentation where they are relevant. I think this would also make it easier to guess the difference between the two numbers (line and offset).
Finally. Is it time to switch to instruction indices, from byte offsets? This would halve the numbers, and make it easier to correlate them to things actually found in variables or other debug output (e.g. lltrace).
markshannon commentedon Nov 21, 2023
Noneis the value you get fromcode.co_lines()for those instructions.What is the advantage of
--?You mean code unit offsets, not instruction offsets?
Instructions are of differing lengths. They happen to all be a multiple of 2 at the moment, but they weren't in the past and might not be in the future.
markshannon commentedon Nov 21, 2023
Perhaps we should make the default what we have now (for backwards compatibility, not because it is the best or prettiest) and allow the user to choose the format.
For example,
--format=JLIAwould mean "Jump-targets Lines Instruction Arguments"The default being
LOIA(Line Offset Instruction Argument)Or is that just getting too complicated?
iritkatriel commentedon Nov 22, 2023
I think it would be more pleasing visually in the output.
iritkatriel commentedon Nov 22, 2023
New version is:
iritkatriel commentedon Nov 22, 2023
With
--instead ofNoneit looks like this:gvanrossum commentedon Nov 22, 2023
Unsurprisingly I like the version best with '--' for unknown line numbers, labels, byte (or instr!) offsets. In fact I can't wait to use it. :-)
gh-112137: change dis output to display labels instead of offsets (#1…
pythongh-112137: change dis output to show no-lineno as -- instead of…
gh-112137: change dis output to show no-lineno as -- instead of None (#…
pythongh-112137: change dis output to display labels instead of offse…
pythongh-112137: change dis output to show no-lineno as -- instead of…
pythongh-112137: change dis output to display labels instead of offse…
pythongh-112137: change dis output to show no-lineno as -- instead of…