|
4 | 4 | importtypes |
5 | 5 | importcollections |
6 | 6 | importio |
| 7 | +fromfileinputimportlineno |
7 | 8 |
|
8 | 9 | fromopcodeimport* |
9 | 10 | fromopcodeimport ( |
@@ -436,6 +437,8 @@ def __init__(self, file=None, lineno_width=0, offset_width=0, positions_width=0, |
436 | 437 | *positions_width* sets the width of the instruction positions field (0 omits it) |
437 | 438 | *label_width* sets the width of the label field |
438 | 439 | *show_caches* is a boolean indicating whether to display cache lines |
| 440 | +
|
| 441 | + If *positions_width* is specified, *lineno_width* is ignored. |
439 | 442 | """ |
440 | 443 | self.file=file |
441 | 444 | self.lineno_width=lineno_width |
@@ -465,26 +468,28 @@ def print_instruction(self, instr, mark_as_current=False): |
465 | 468 | defprint_instruction_line(self,instr,mark_as_current): |
466 | 469 | """Format instruction details for inclusion in disassembly output.""" |
467 | 470 | lineno_width=self.lineno_width |
468 | | -positions_wdith=self.positions_width |
| 471 | +positions_width=self.positions_width |
469 | 472 | offset_width=self.offset_width |
470 | 473 | label_width=self.label_width |
471 | 474 |
|
472 | | -new_source_line= (lineno_width>0and |
| 475 | +new_source_line= ((lineno_width>0orpositions_width>0)and |
473 | 476 | instr.starts_lineand |
474 | 477 | instr.offset>0) |
475 | 478 | ifnew_source_line: |
476 | 479 | print(file=self.file) |
477 | 480 |
|
478 | 481 | fields= [] |
479 | 482 | # Column: Source code line number |
480 | | -iflineno_widthorpositions_wdith: |
481 | | -ifpositions_wdith: |
| 483 | +iflineno_widthorpositions_width: |
| 484 | +ifpositions_width: |
| 485 | +# reporting positions instead of just line numbers |
| 486 | +assertlineno_width>0 |
482 | 487 | ifinstr_positions:=instr.positions: |
483 | 488 | ps=tuple('?'ifpisNoneelsepforpininstr_positions) |
484 | 489 | positions_str="%s:%s-%s:%s"%ps |
485 | | -fields.append(f'{positions_str:{positions_wdith}}') |
| 490 | +fields.append(f'{positions_str:{positions_width}}') |
486 | 491 | else: |
487 | | -fields.append(' '*positions_wdith) |
| 492 | +fields.append(' '*positions_width) |
488 | 493 | else: |
489 | 494 | ifinstr.starts_line: |
490 | 495 | lineno_fmt="%%%dd"ifinstr.line_numberisnotNoneelse"%%%ds" |
@@ -831,7 +836,6 @@ def _make_labels_map(original_code, exception_entries=()): |
831 | 836 | returnlabels_map |
832 | 837 |
|
833 | 838 | _NO_LINENO=' --' |
834 | | -_NO_POSITION=' ?:?-?:?' |
835 | 839 |
|
836 | 840 | def_get_lineno_width(linestarts): |
837 | 841 | iflinestartsisNone: |
|