Skip to content

Commit 291d17c

Browse files
committed
Squelch traceback on break in unparsable file
1 parent 87823f4 commit 291d17c

1 file changed

Lines changed: 14 additions & 8 deletions

File tree

trepan/processor/cmdbreak.py

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# -*- coding: utf-8 -*-
22
#
3-
# Copyright (C) 2009-2010, 2013, 2015-2018, 2020 Rocky Bernstein
3+
# Copyright (C) 2009-2010, 2013, 2015-2018, 2020, 2022 Rocky Bernstein
44
# This program is free software: you can redistribute it and/or modify
55
# it under the terms of the GNU General Public License as published by
66
# the Free Software Foundation, either version 3 of the License, or
@@ -35,8 +35,9 @@ def set_break(
3535
offset=None,
3636
):
3737
if lineno is None and offset is None:
38-
part1 = "I don't understand '%s' as a line number, offset, or function name," % " ".join(
39-
args[1:]
38+
part1 = (
39+
"I don't understand '%s' as a line number, offset, or function name,"
40+
% " ".join(args[1:])
4041
)
4142
msg = wrapped_lines(
4243
part1, "or file/module plus line number.", cmd_obj.settings["width"]
@@ -82,7 +83,8 @@ def set_break(
8283
offset=offset,
8384
temporary=temporary,
8485
condition=condition,
85-
func=func)
86+
func=func,
87+
)
8688
if func and inspect.isfunction(func):
8789
cmd_obj.msg(
8890
"Breakpoint %d set on calling function %s()" % (bp.number, func.__name__)
@@ -93,8 +95,7 @@ def set_break(
9395
)
9496
cmd_obj.msg(msg)
9597
else:
96-
part1 = ("Breakpoint %d set at line %d of file" %
97-
(bp.number, lineno))
98+
part1 = "Breakpoint %d set at line %d of file" % (bp.number, lineno)
9899
msg = wrapped_lines(
99100
part1, cmd_obj.core.filename(filename), cmd_obj.settings["width"]
100101
)
@@ -104,7 +105,7 @@ def set_break(
104105
else:
105106
func_str = ""
106107
if offset is not None and offset >= 0:
107-
cmd_obj.msg("Breakpoint is at offset %d%s "% (offset, func_str))
108+
cmd_obj.msg("Breakpoint is at offset %d%s " % (offset, func_str))
108109
pass
109110
return True
110111

@@ -141,7 +142,12 @@ def parse_break_cmd(proc, args):
141142
location = bp_expr.location
142143
condition = bp_expr.condition
143144

144-
location = resolve_location(proc, location)
145+
try:
146+
location = resolve_location(proc, location)
147+
except ValueError as e:
148+
proc.errmsg(str(e))
149+
return INVALID_PARSE_BREAK
150+
145151
if location:
146152
return (
147153
location.method,

0 commit comments

Comments
 (0)