This is the mail archive of the
insight@sources.redhat.com
mailing list for the Insight project.
Patch: argument handling cleanup
- To: Insight List <insight at sourceware dot cygnus dot com>
- Subject: Patch: argument handling cleanup
- From: Tom Tromey <tromey at cygnus dot com>
- Date: 29 Nov 2000 15:05:27 -0700
- Reply-To: tromey at cygnus dot com
This patch fixes all the wrong-#-args processing in gdbtk-cmds.c.
It can be used without my hack to call_wrapper -- the results won't be
pretty but they also won't be worse than what already exists. This
patch makes things more maintainable, but also fixes some outright
bugs.
Ok?
2000-11-28 Tom Tromey <tromey@cygnus.com>
* gdbtk-cmds.c (gdb_clear_file): Use Tcl_WrongNumArgs.
(gdb_confirm_quit): Likewise.
(gdb_force_quit): Likewise.
(gdb_eval): Likewise.
(gdb_immediate_command): Likewise.
(gdb_get_vars_command): Likewise.
(gdb_get_line_command): Likewise.
(gdb_get_file_command): Likewise.
(gdb_get_function_command): Likewise.
(gdb_cmd): Likewise. Also, don't allow more than 2 arguments.
(gdb_listfiles): Corrected usage of Tcl_WrongNumArgs.
(gdb_listfuncs): Use Tcl_WrongNumArgs. Return error.
(gdb_fetch_registers): Likewise.
(gdb_tracepoint_exists_command): Use Tcl_WrongNumArgs.
(gdb_get_tracepoint_info): Likewise.
(gdb_get_trace_frame_num): Likewise.
(gdb_actions_command): Likewise.
(gdb_disassemble): Likewise. Also, return error.
(gdb_get_breakpoint_list): Likewise.
(gdb_path_conv): Likewise.
(gdb_load_disassembly): Use Tcl_WrongNumArgs.
(gdb_loc): Likewise.
(gdb_set_bp): Likewise.
(gdb_set_bp_addr): Likewise.
(gdb_get_breakpoint_info): Likewise.
Tom
Index: gdbtk-cmds.c
===================================================================
RCS file: /cvs/src/src/gdb/gdbtk/generic/gdbtk-cmds.c,v
retrieving revision 1.12
diff -u -r1.12 gdbtk-cmds.c
--- gdbtk-cmds.c 2000/07/25 20:41:07 1.12
+++ gdbtk-cmds.c 2000/11/29 21:46:36
@@ -580,8 +615,10 @@
Tcl_Obj *CONST objv[];
{
if (objc != 1)
- Tcl_SetStringObj (result_ptr->obj_ptr,
- "Wrong number of args, none are allowed.", -1);
+ {
+ Tcl_WrongNumArgs (interp, 1, objv, NULL);
+ return TCL_ERROR;
+ }
if (inferior_pid != 0 && target_has_execution)
{
@@ -621,8 +658,7 @@
if (objc != 1)
{
- Tcl_SetStringObj (result_ptr->obj_ptr,
- "Wrong number of args, should be none.", -1);
+ Tcl_WrongNumArgs (interp, 1, objv, NULL);
return TCL_ERROR;
}
@@ -649,8 +685,7 @@
{
if (objc != 1)
{
- Tcl_SetStringObj (result_ptr->obj_ptr,
- "Wrong number of args, should be none.", -1);
+ Tcl_WrongNumArgs (interp, 1, objv, NULL);
return TCL_ERROR;
}
@@ -746,8 +781,7 @@
if (objc != 2)
{
- Tcl_SetStringObj (result_ptr->obj_ptr,
- "wrong # args, should be \"gdb_eval expression\"", -1);
+ Tcl_WrongNumArgs (interp, 1, objv, "expression");
return TCL_ERROR;
}
@@ -796,9 +830,9 @@
{
int from_tty = 0;
- if (objc < 2)
+ if (objc < 2 || objc > 3)
{
- Tcl_SetStringObj (result_ptr->obj_ptr, "wrong # args", -1);
+ Tcl_WrongNumArgs (interp, 1, objv, "command ?from_tty?");
return TCL_ERROR;
}
@@ -866,9 +900,9 @@
int from_tty = 0;
- if (objc < 2)
+ if (objc < 2 || objc > 3)
{
- Tcl_SetStringObj (result_ptr->obj_ptr, "wrong # args", -1);
+ Tcl_WrongNumArgs (interp, 1, objv, "command ?from_tty?");
return TCL_ERROR;
}
@@ -1073,10 +1107,8 @@
if (objc > 2)
{
- Tcl_AppendStringsToObj (result_ptr->obj_ptr,
- "wrong # of args: should be \"",
- Tcl_GetStringFromObj (objv[0], NULL),
- " [function:line|function|line|*addr]\"", NULL);
+ Tcl_WrongNumArgs (interp, 1, objv,
+ "[function:line|function|line|*addr]");
return TCL_ERROR;
}
@@ -1181,10 +1213,7 @@
if (objc != 2)
{
- Tcl_AppendStringsToObj (result_ptr->obj_ptr,
- "wrong # of args: should be \"",
- Tcl_GetStringFromObj (objv[0], NULL),
- " linespec\"", NULL);
+ Tcl_WrongNumArgs (interp, 1, objv, "linespec");
return TCL_ERROR;
}
@@ -1223,10 +1252,7 @@
if (objc != 2)
{
- Tcl_AppendStringsToObj (result_ptr->obj_ptr,
- "wrong # of args: should be \"",
- Tcl_GetStringFromObj (objv[0], NULL),
- " linespec\"", NULL);
+ Tcl_WrongNumArgs (interp, 1, objv, "linespec");
return TCL_ERROR;
}
@@ -1265,10 +1291,7 @@
if (objc != 2)
{
- Tcl_AppendStringsToObj (result_ptr->obj_ptr,
- "wrong # of args: should be \"",
- Tcl_GetStringFromObj (objv[0], NULL),
- " linespec\"", NULL);
+ Tcl_WrongNumArgs (interp, 1, objv, "linespec");
return TCL_ERROR;
}
@@ -1363,7 +1386,7 @@
if (objc > 2)
{
- Tcl_WrongNumArgs (interp, 1, objv, "Usage: gdb_listfiles ?pathname?");
+ Tcl_WrongNumArgs (interp, 1, objv, "?pathname?");
return TCL_ERROR;
}
else if (objc == 2)
@@ -1669,7 +1692,8 @@
if (objc != 2)
{
- Tcl_SetStringObj (result_ptr->obj_ptr, "wrong # args", -1);
+ Tcl_WrongNumArgs (interp, 1, objv, "file");
+ return TCL_ERROR;
}
symtab = full_lookup_symtab (Tcl_GetStringFromObj (objv[1], NULL));
@@ -1909,8 +1933,8 @@
if (objc < 2)
{
- Tcl_SetStringObj (result_ptr->obj_ptr,
- "wrong # args, should be gdb_fetch_registers format ?register1 register2 ...?", -1);
+ Tcl_WrongNumArgs (interp, 1, objv, "format ?register1 register2 ...?");
+ return TCL_ERROR;
}
objc -= 2;
objv++;
@@ -2135,10 +2159,8 @@
if (objc != 2)
{
- Tcl_AppendStringsToObj (result_ptr->obj_ptr,
- "wrong # of args: should be \"",
- Tcl_GetStringFromObj (objv[0], NULL),
- " function:line|function|line|*addr\"", NULL);
+ Tcl_WrongNumArgs (interp, 1, objv,
+ "function:line|function|line|*addr");
return TCL_ERROR;
}
@@ -2164,7 +2186,7 @@
if (objc != 2)
{
- Tcl_SetStringObj (result_ptr->obj_ptr, "wrong # args", -1);
+ Tcl_WrongNumArgs (interp, 1, objv, "tpnum");
return TCL_ERROR;
}
@@ -2258,10 +2280,7 @@
{
if (objc != 1)
{
- Tcl_AppendStringsToObj (result_ptr->obj_ptr,
- "wrong # of args: should be \"",
- Tcl_GetStringFromObj (objv[0], NULL),
- " linespec\"", NULL);
+ Tcl_WrongNumArgs (interp, 1, objv, "linespec");
return TCL_ERROR;
}
@@ -2297,10 +2316,7 @@
if (objc != 3)
{
- Tcl_AppendStringsToObj (result_ptr->obj_ptr,
- "wrong # args: should be: \"",
- Tcl_GetStringFromObj (objv[0], NULL),
- " number actions\"", NULL);
+ Tcl_WrongNumArgs (interp, 1, objv, "number actions");
return TCL_ERROR;
}
@@ -2382,7 +2398,10 @@
int mixed_source_and_assembly;
if (objc != 3 && objc != 4)
- error ("wrong # args");
+ {
+ Tcl_WrongNumArgs (interp, 1, objv, "source lowaddr ?highaddr?");
+ return TCL_ERROR;
+ }
arg_ptr = Tcl_GetStringFromObj (objv[1], NULL);
if (*arg_ptr == 's' && strcmp (arg_ptr, "source") == 0)
@@ -2438,10 +2457,11 @@
char *arg_ptr;
char *map_name;
- if (objc != 6 && objc != 7) {
- Tcl_SetStringObj (result_ptr->obj_ptr, "wrong # args, should be: widget [source|nosource] map_arr index_prefix low_address ?hi_address", -1);
- return TCL_ERROR;
- }
+ if (objc != 6 && objc != 7)
+ {
+ Tcl_WrongNumArgs (interp, 1, objv, "[source|nosource] map_arr index_prefix low_address ?hi_address");
+ return TCL_ERROR;
+ }
client_data.widget = Tcl_GetStringFromObj (objv[1], NULL);
if ( Tk_NameToWindow (interp, client_data.widget,
@@ -3179,7 +3199,7 @@
}
else
{
- Tcl_SetStringObj (result_ptr->obj_ptr, "wrong # args", -1);
+ Tcl_WrongNumArgs (interp, 1, objv, "?symbol?");
return TCL_ERROR;
}
@@ -3690,8 +3710,7 @@
if (objc != 4 && objc != 5)
{
- Tcl_SetStringObj (result_ptr->obj_ptr,
- "wrong number of args, should be \"filename line type [thread]\"", -1);
+ Tcl_WrongNumArgs (interp, 1, objv, "filename line type ?thread?");
return TCL_ERROR;
}
@@ -3800,10 +3819,9 @@
Tcl_DString cmd;
enum bpdisp disp;
- if (objc != 4 && objc != 3)
+ if (objc != 3 && objc != 4)
{
- Tcl_SetStringObj (result_ptr->obj_ptr,
- "wrong number of args, should be \"address type [thread]\"", -1);
+ Tcl_WrongNumArgs (interp, 1, objv, "address type ?thread?");
return TCL_ERROR;
}
@@ -3996,8 +4014,7 @@
if (objc != 2)
{
- Tcl_SetStringObj (result_ptr->obj_ptr,
- "wrong number of args, should be \"breakpoint\"", -1);
+ Tcl_WrongNumArgs (interp, 1, objv, "breakpoint");
return TCL_ERROR;
}
@@ -4085,7 +4102,10 @@
Tcl_Obj *new_obj;
if (objc != 1)
- error ("wrong number of args, none are allowed");
+ {
+ Tcl_WrongNumArgs (interp, 1, objv, NULL);
+ return TCL_ERROR;
+ }
for (b = breakpoint_chain; b; b = b->next)
if (b->type == bp_breakpoint)
@@ -4559,7 +4579,10 @@
Tcl_Obj *CONST objv[];
{
if (objc != 2)
- error ("wrong # args");
+ {
+ Tcl_WrongNumArgs (interp, 1, objv, NULL);
+ return TCL_ERROR;
+ }
#ifdef __CYGWIN__
{