@@ -83,7 +83,7 @@ def print_source_line(msg, lineno, line, event_str=None, is_pyasm: bool = False)
8383 """Print out a source line of text , e.g. the second
8484 line in:
8585 (/tmp.py:2): <module>
86- L -- 2 import sys,os
86+ -- 2 import sys,os
8787 (trepan3k)
8888
8989 We define this method
@@ -106,16 +106,21 @@ def print_source_location_info(
106106 fn_name = None ,
107107 f_lasti = None ,
108108 remapped_file = None ,
109+ remapped_line_number : int = - 1 ,
110+ remapped_column_number : int = - 1 ,
109111):
110- """Print out a source location , e.g. the first line in
112+ """Print out a source location, e.g. the first line in
111113 line in:
112114 (/tmp.py:2:4 @21): <module>
113- L -- 2 import sys,os
115+ -- 2 import sys,os
114116 (trepan3k)
115117 """
116118 col_str = f":{ column_number } " if column_number >= 0 else ""
117119 if remapped_file and filename != remapped_file :
118- mess = f"({ remapped_file } :{ line_number } { col_str } remapped { filename } "
120+ if remapped_line_number != - 1 :
121+ mess = f"({ remapped_file } :{ remapped_line_number } remapped { filename } :{ line_number } "
122+ else :
123+ mess = f"({ remapped_file } :{ line_number } { col_str } remapped { filename } "
119124 else :
120125 mess = f"({ filename } :{ line_number } { col_str } "
121126 if f_lasti and f_lasti != - 1 :
@@ -202,6 +207,10 @@ def prefix_for_source_text(source_text: str, maxwidth: int) -> str:
202207 if "<string>" == filename :
203208 if remapped_file := pyficache .main .code2tempfile .get (frame .f_code ):
204209 filename = remapped_file
210+ _ , remapped_line_number = pyficache .unmap_file_line (
211+ remapped_file , line_number
212+ )
213+
205214 elif dbgr_obj .eval_string :
206215 remapped_file = filename
207216 filename = pyficache .unmap_file (filename )
@@ -238,7 +247,6 @@ def prefix_for_source_text(source_text: str, maxwidth: int) -> str:
238247 deparsed .text ,
239248 tempdir = proc_obj .settings ("tempdir" ),
240249 )
241- # FIXME: pyficache remaps seems backwards
242250 filename = remapped_file
243251
244252 else :
@@ -288,13 +296,13 @@ def prefix_for_source_text(source_text: str, maxwidth: int) -> str:
288296
289297 pyficache .update_cache (filename )
290298
291- is_pyasm = filename . endswith ( ".pyasm" )
299+ is_pyasm = pyficache . is_python_assembly_file ( remapped_file or filename )
292300 if is_pyasm :
293- opts = opts .copy ()
294- line , _ = pyficache .get_pyasm_line (
295- filename , line_number , is_source_line = True , opts = opts
301+ line , remapped_line_number = pyficache .get_pyasm_line (
302+ filename , line_number , is_source_line = True
296303 )
297304 else :
305+ remapped_line_number = - 1 # -1 means no remapping
298306 line = pyficache .getline (filename , line_number , opts )
299307
300308 if not line :
@@ -326,7 +334,7 @@ def prefix_for_source_text(source_text: str, maxwidth: int) -> str:
326334 # try with good ol linecache and consider fixing pyficache
327335 lines = linecache .getlines (filename )
328336 temp_name = filename
329- if lines and not filename . endswith ( ".pyasm" ):
337+ if lines and not pyficache . is_python_assembly_file ( filename ):
330338 # FIXME: DRY code with version in cmdproc.py print_location
331339 prefix = osp .basename (temp_name ).split ("." )[0 ] + "-"
332340 fd = NamedTemporaryFile (
@@ -397,8 +405,9 @@ def prefix_for_source_text(source_text: str, maxwidth: int) -> str:
397405 line_number ,
398406 column_number ,
399407 fn_name ,
400- remapped_file = remapped_file ,
401408 f_lasti = last_i ,
409+ remapped_file = remapped_file ,
410+ remapped_line_number = remapped_line_number ,
402411 )
403412 if line and len (line .strip ()) != 0 :
404413 if proc_obj .event :
0 commit comments