This is the mail archive of the
archer@sourceware.org
mailing list for the Archer project.
[python] Trivial filename check in python/lib/gdb/command/save_breakpoints.py
- From: Phil Muldoon <pmuldoon at redhat dot com>
- To: Project Archer <archer at sourceware dot org>
- Date: Tue, 13 Jan 2009 17:36:07 +0000
- Subject: [python] Trivial filename check in python/lib/gdb/command/save_breakpoints.py
Right now if one does not specify a fiilename with "save breakpoints"
command, this error message is produced:
(gdb) save breakpoints
Traceback (most recent call last):
File
"/home/pmuldoon/python/archer/gdb/python/lib/gdb/command/save_breakpoints.py",
line 44, in invoke
with open (arg.strip (), 'w') as f:
AttributeError: 'NoneType' object has no attribute 'strip'
Error occurred in Python command: 'NoneType' object has no attribute 'strip'
Trivial change to check is args is None and if so, produce a slightly
better message:
(pg-gdb) save breakpoints
Traceback (most recent call last):
File
"/home/pmuldoon/python/archer/gdb/python/lib/gdb/command/save_breakpoints.py",
line 45, in invoke
raise RuntimeError, 'No filename specified'
RuntimeError: No filename specified
Error occurred in Python command.
I thought about adding write permissions checks too, but decided against
it. Can add if needed.
Regards
Phil
diff --git a/gdb/python/lib/gdb/command/save_breakpoints.py b/gdb/python/lib/gdb/command/save_breakpoints.py
index a2bed0d..14a27f7 100644
--- a/gdb/python/lib/gdb/command/save_breakpoints.py
+++ b/gdb/python/lib/gdb/command/save_breakpoints.py
@@ -1,6 +1,6 @@
# Save breakpoints.
-# Copyright (C) 2008 Free Software Foundation, Inc.
+# Copyright (C) 2008, 2009 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -41,6 +41,8 @@ The breakpoints can be restored using the 'source' command."""
bps = gdb.breakpoints ()
if bps is None:
raise RuntimeError, 'No breakpoints to save'
+ if arg is None:
+ raise RuntimeError, 'No filename specified'
with open (arg.strip (), 'w') as f:
for bp in bps:
print >> f, "break", bp.location,