1616# along with this program. If not, see <http://www.gnu.org/licenses/>.
1717import inspect
1818import os
19+ from dis import findlinestarts
1920
20- from trepan .processor import cmdproc as Mcmdproc
21+ from trepan .processor . cmdproc import print_location
2122
2223# Our local modules
2324from trepan .processor .command .base_cmd import DebuggerCommand
@@ -81,6 +82,11 @@ def run(self, args):
8182
8283 if lineno is None :
8384 return False
85+
86+ linestarts = dict (findlinestarts (self .proc .curframe .f_code ))
87+ if lineno not in linestarts .values ():
88+ self .warnmsg (f"code for line { lineno } not found. Results may be unpredictable." )
89+
8490 try :
8591 # Set to change position, update our copy of the stack,
8692 # and display the new position
@@ -89,24 +95,25 @@ def run(self, args):
8995 self .proc .stack [self .proc .curindex ][0 ],
9096 lineno ,
9197 )
92- Mcmdproc . print_location (self .proc )
98+ print_location (self .proc )
9399 except ValueError as e :
94- self .errmsg ("jump failed: %s" % e )
100+ self .errmsg (f "jump failed: { e } " )
95101 return False
96102
97103 pass
98104
99105
100106if __name__ == "__main__" :
101107 from trepan .processor .command import mock
108+ from trepan .processor .cmdproc import get_stack
102109
103110 d , cp = mock .dbg_setup ()
104111 command = JumpCommand (cp )
105112 print ("jump when not running: " , command .run (["jump" , "1" ]))
106113 command .core .execution_status = "Running"
107114 cp .curframe = inspect .currentframe ()
108115 cp .curindex = 0
109- cp .stack = Mcmdproc . get_stack (cp .curframe , None , None )
116+ cp .stack = get_stack (cp .curframe , None , None )
110117 command .run (["jump" , "1" ])
111118 cp .curindex = len (cp .stack ) - 1
112119 command .run (["jump" , "1" ])
0 commit comments