@@ -5,7 +5,7 @@ using JuliaInterpreter: JuliaFrameCode, JuliaStackFrame, BreakpointState,
5
5
truecondition, falsecondition, prepare_framecode, get_framecode,
6
6
sparam_syms, linenumber, statementnumber
7
7
using Base. Meta: isexpr
8
- using InteractiveUtils
8
+ using CodeTracking, InteractiveUtils
9
9
10
10
export @breakpoint , breakpoint, enable, disable, remove
11
11
@@ -238,6 +238,33 @@ function breakpoint(f, condition::Condition=nothing)
238
238
return bps
239
239
end
240
240
241
+ """
242
+ breakpoint(filename, line)
243
+
244
+ Set a breakpoint at the specified file and line number.
245
+ """
246
+ function breakpoint (filename:: AbstractString , line:: Integer , args... )
247
+ sigs = signatures_at (filename, line)
248
+ if sigs === nothing
249
+ # TODO : build a Revise-free fallback. Note this won't work well for methods with keywords.
250
+ error (" no signatures found at $filename , $line . Restarting and `using Revise` may fix this problem." )
251
+ end
252
+ for sig in sigs
253
+ method = JuliaInterpreter. whichtt (sig)
254
+ method === nothing && continue
255
+ # Check to see if this method really contains that line. Methods that fill in a default positional argument,
256
+ # keyword arguments, and @generated sections may not contain the line.
257
+ _, line1 = whereis (method)
258
+ offset = line1 - method. line
259
+ src = JuliaInterpreter. get_source (method)
260
+ lastline = src. linetable[end ]
261
+ if lastline. line + offset >= line
262
+ return breakpoint (method, line, args... )
263
+ end
264
+ end
265
+ error (" no signatures found at $filename , $line among the signatures $sigs " )
266
+ end
267
+
241
268
"""
242
269
@breakpoint f(args...) condition=nothing
243
270
@breakpoint f(args...) line condition=nothing
0 commit comments