* Re: $argc variable [not found] ` <20051113173524.GC1945@nevyn.them.org> @ 2005-11-14 22:12 ` Andrew STUBBS 2005-11-15 12:35 ` Eli Zaretskii 0 siblings, 1 reply; 8+ messages in thread From: Andrew STUBBS @ 2005-11-14 22:12 UTC (permalink / raw) To: Daniel Jacobowitz; +Cc: Eli Zaretskii, gdb-patches [-- Attachment #1: Type: text/plain, Size: 676 bytes --] Daniel Jacobowitz wrote: > It looks OK to me. Could you post the revised documentation (to > gdb-patches, please) so that we can make sure that Eli and you did > converge? I couldn't quite follow your earlier conversation. Here is the full patch including both code and docs. In the end I have dropped the index altogether. Eli didn't like the kindex and the cindex would be so close to the cindex for the section, and so similar in content, that it would be pointless. I still think there is an argument for a kindex entry for both $argc and $arg0...$arg1 in case people don't know they are looking for 'user-defined', but I'm not really that bothered. OK? Andrew [-- Attachment #2: argc.patch --] [-- Type: text/plain, Size: 4178 bytes --] 2005-11-14 Andrew Stubbs <andrew.stubbs@st.com> * cli/cli-script.c: Include gdb_assert.h. (locate_arg): Detect $argc. (insert_args): Substitute $argc. * Makefile.in (cli-script.o): Add dependency on gdb_assert.h. doc/ * gdb.texinfo (User-defined commands): Add $argc. Add missing 'end'. Change @var{$arg0 to @code{$arg0. Index: src/gdb/cli/cli-script.c =================================================================== --- src.orig/gdb/cli/cli-script.c 2005-11-14 14:49:30.000000000 +0000 +++ src/gdb/cli/cli-script.c 2005-11-14 15:01:14.000000000 +0000 @@ -33,6 +33,7 @@ #include "cli/cli-cmds.h" #include "cli/cli-decode.h" #include "cli/cli-script.h" +#include "gdb_assert.h" /* Prototypes for local functions */ @@ -572,7 +573,8 @@ locate_arg (char *p) { while ((p = strchr (p, '$'))) { - if (strncmp (p, "$arg", 4) == 0 && isdigit (p[4])) + if (strncmp (p, "$arg", 4) == 0 + && (isdigit (p[4]) || p[4] == 'c')) return p; p++; } @@ -596,12 +598,20 @@ insert_args (char *line) len += p - line; i = p[4] - '0'; - if (i >= user_args->count) + if (p[4] == 'c') + { + /* $argc. Number will be <=10. */ + len += user_args->count == 10 ? 2 : 1; + } + else if (i >= user_args->count) { error (_("Missing argument %d in user function."), i); return NULL; } - len += user_args->a[i].len; + else + { + len += user_args->a[i].len; + } line = p + 5; } @@ -625,13 +635,27 @@ insert_args (char *line) memcpy (new_line, line, p - line); new_line += p - line; - i = p[4] - '0'; - len = user_args->a[i].len; - if (len) + if (p[4] == 'c') + { + gdb_assert (user_args->count >= 0 && user_args->count <= 10); + if (user_args->count == 10) + { + *(new_line++) = '1'; + *(new_line++) = '0'; + } + else + *(new_line++) = user_args->count + '0'; + } + else { - memcpy (new_line, user_args->a[i].arg, len); - new_line += len; + i = p[4] - '0'; + len = user_args->a[i].len; + if (len) + { + memcpy (new_line, user_args->a[i].arg, len); + new_line += len; + } } line = p + 5; } Index: src/gdb/doc/gdb.texinfo =================================================================== --- src.orig/gdb/doc/gdb.texinfo 2005-11-14 14:50:18.000000000 +0000 +++ src/gdb/doc/gdb.texinfo 2005-11-14 15:28:00.000000000 +0000 @@ -15708,11 +15708,12 @@ A @dfn{user-defined command} is a sequen which you assign a new name as a command. This is done with the @code{define} command. User commands may accept up to 10 arguments separated by whitespace. Arguments are accessed within the user command -via @var{$arg0@dots{}$arg9}. A trivial example: +via @code{$arg0@dots{}$arg9}. A trivial example: @smallexample define adder print $arg0 + $arg1 + $arg2 +end @end smallexample @noindent @@ -15728,6 +15729,20 @@ its three arguments. Note the arguments reference variables, use complex expressions, or even perform inferior functions calls. +In addition, @code{$argc} may be used to find out how many arguments have +been passed. This expands to a number in the range 0@dots{}10. + +@smallexample +define adder + if $argc == 2 + print $arg0 + $arg1 + end + if $argc == 3 + print $arg0 + $arg1 + $arg2 + end +end +@end smallexample + @table @code @kindex define Index: src/gdb/Makefile.in =================================================================== --- src.orig/gdb/Makefile.in 2005-11-14 14:49:30.000000000 +0000 +++ src/gdb/Makefile.in 2005-11-14 15:01:14.000000000 +0000 @@ -2807,7 +2807,7 @@ cli-logging.o: $(srcdir)/cli/cli-logging $(CC) -c $(INTERNAL_CFLAGS) $(srcdir)/cli/cli-logging.c cli-script.o: $(srcdir)/cli/cli-script.c $(defs_h) $(value_h) $(language_h) \ $(ui_out_h) $(gdb_string_h) $(exceptions_h) $(top_h) $(cli_cmds_h) \ - $(cli_decode_h) $(cli_script_h) + $(cli_decode_h) $(cli_script_h) $(gdb_assert_h) $(CC) -c $(INTERNAL_CFLAGS) $(srcdir)/cli/cli-script.c cli-setshow.o: $(srcdir)/cli/cli-setshow.c $(defs_h) $(readline_tilde_h) \ $(value_h) $(gdb_string_h) $(ui_out_h) $(cli_decode_h) $(cli_cmds_h) \ ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: $argc variable 2005-11-14 22:12 ` $argc variable Andrew STUBBS @ 2005-11-15 12:35 ` Eli Zaretskii 2005-11-15 12:39 ` Daniel Jacobowitz 0 siblings, 1 reply; 8+ messages in thread From: Eli Zaretskii @ 2005-11-15 12:35 UTC (permalink / raw) To: Andrew STUBBS; +Cc: drow, gdb-patches > Date: Mon, 14 Nov 2005 16:28:10 +0000 > From: Andrew STUBBS <andrew.stubbs@st.com> > Cc: Eli Zaretskii <eliz@gnu.org>, gdb-patches@sources.redhat.com > > Daniel Jacobowitz wrote: > > It looks OK to me. Could you post the revised documentation (to > > gdb-patches, please) so that we can make sure that Eli and you did > > converge? I couldn't quite follow your earlier conversation. > > Here is the full patch including both code and docs. > > In the end I have dropped the index altogether. Eli didn't like the > kindex and the cindex would be so close to the cindex for the section, > and so similar in content, that it would be pointless. > > I still think there is an argument for a kindex entry for both $argc and > $arg0...$arg1 in case people don't know they are looking for > 'user-defined', but I'm not really that bothered. > > OK? OK for the documentation patch. ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: $argc variable 2005-11-15 12:35 ` Eli Zaretskii @ 2005-11-15 12:39 ` Daniel Jacobowitz 2005-11-15 17:54 ` Andrew STUBBS 2005-11-16 4:01 ` Eli Zaretskii 0 siblings, 2 replies; 8+ messages in thread From: Daniel Jacobowitz @ 2005-11-15 12:39 UTC (permalink / raw) To: Eli Zaretskii; +Cc: Andrew STUBBS, gdb-patches On Tue, Nov 15, 2005 at 06:10:32AM +0200, Eli Zaretskii wrote: > > Date: Mon, 14 Nov 2005 16:28:10 +0000 > > From: Andrew STUBBS <andrew.stubbs@st.com> > > Cc: Eli Zaretskii <eliz@gnu.org>, gdb-patches@sources.redhat.com > > > > OK? > > OK for the documentation patch. The code is fine too. Should this go on the branch? Should it go in NEWS? My inclination is "both". -- Daniel Jacobowitz CodeSourcery, LLC ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: $argc variable 2005-11-15 12:39 ` Daniel Jacobowitz @ 2005-11-15 17:54 ` Andrew STUBBS 2005-11-16 5:52 ` Eli Zaretskii 2005-11-16 4:01 ` Eli Zaretskii 1 sibling, 1 reply; 8+ messages in thread From: Andrew STUBBS @ 2005-11-15 17:54 UTC (permalink / raw) To: Daniel Jacobowitz; +Cc: Eli Zaretskii, gdb-patches [-- Attachment #1: Type: text/plain, Size: 274 bytes --] Daniel Jacobowitz wrote: >>OK for the documentation patch. > > > The code is fine too. Thanks, commited. > Should this go on the branch? Should it go in NEWS? My inclination is > "both". I have no objection to putting it in. How about the attached for NEWS? Andrew [-- Attachment #2: 6.4-news-2.patch --] [-- Type: text/plain, Size: 700 bytes --] 2005-11-15 Andrew Stubbs <andrew.stubbs@st.com> * NEWS (6.4): Mention $argc. Index: src/gdb/NEWS =================================================================== --- src.orig/gdb/NEWS 2005-11-15 12:09:47.000000000 +0000 +++ src/gdb/NEWS 2005-11-15 12:15:45.000000000 +0000 @@ -70,6 +70,12 @@ behavior. GDB now supports the not-quite-ieee VAX F and D floating point formats. +* User-defined command support + +In addition to using $arg0..$arg9 for argument passing, it is now possible +to use $argc to determine now many arguments have been passed. See the +section on user-defined commands in the user manual for more information. + *** Changes in GDB 6.3: * New command line option ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: $argc variable 2005-11-15 17:54 ` Andrew STUBBS @ 2005-11-16 5:52 ` Eli Zaretskii 2005-11-16 14:43 ` Andrew STUBBS 0 siblings, 1 reply; 8+ messages in thread From: Eli Zaretskii @ 2005-11-16 5:52 UTC (permalink / raw) To: Andrew STUBBS; +Cc: drow, gdb-patches > Date: Tue, 15 Nov 2005 12:33:00 +0000 > From: Andrew STUBBS <andrew.stubbs@st.com> > Cc: Eli Zaretskii <eliz@gnu.org>, gdb-patches@sources.redhat.com > > How about the attached for NEWS? Fine, but please use two blanks after a period that ends a sentence > +to use $argc to determine now many arguments have been passed. See the ^^^ here ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: $argc variable 2005-11-16 5:52 ` Eli Zaretskii @ 2005-11-16 14:43 ` Andrew STUBBS 2005-11-16 16:19 ` Daniel Jacobowitz 0 siblings, 1 reply; 8+ messages in thread From: Andrew STUBBS @ 2005-11-16 14:43 UTC (permalink / raw) To: Eli Zaretskii; +Cc: drow, gdb-patches [-- Attachment #1: Type: text/plain, Size: 612 bytes --] Eli Zaretskii wrote: >>Date: Tue, 15 Nov 2005 12:33:00 +0000 >>From: Andrew STUBBS <andrew.stubbs@st.com> >>Cc: Eli Zaretskii <eliz@gnu.org>, gdb-patches@sources.redhat.com >> >>How about the attached for NEWS? > > > Fine, but please use two blanks after a period that ends a sentence > > >>+to use $argc to determine now many arguments have been passed. See the > > ^^^ here > I have commited the code to the 6.4 branch and the NEWS to both branches. The actual NEWS patch, with the modification above, is attached. Thanks Andrew Stubbs [-- Attachment #2: 6.4-news-2.patch --] [-- Type: text/plain, Size: 701 bytes --] 2005-11-16 Andrew Stubbs <andrew.stubbs@st.com> * NEWS (6.4): Mention $argc. Index: src/gdb/NEWS =================================================================== --- src.orig/gdb/NEWS 2005-11-15 12:09:47.000000000 +0000 +++ src/gdb/NEWS 2005-11-16 12:30:19.000000000 +0000 @@ -70,6 +70,12 @@ behavior. GDB now supports the not-quite-ieee VAX F and D floating point formats. +* User-defined command support + +In addition to using $arg0..$arg9 for argument passing, it is now possible +to use $argc to determine now many arguments have been passed. See the +section on user-defined commands in the user manual for more information. + *** Changes in GDB 6.3: * New command line option ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: $argc variable 2005-11-16 14:43 ` Andrew STUBBS @ 2005-11-16 16:19 ` Daniel Jacobowitz 0 siblings, 0 replies; 8+ messages in thread From: Daniel Jacobowitz @ 2005-11-16 16:19 UTC (permalink / raw) To: Andrew STUBBS; +Cc: Eli Zaretskii, gdb-patches On Wed, Nov 16, 2005 at 12:49:22PM +0000, Andrew STUBBS wrote: > I have commited the code to the 6.4 branch and the NEWS to both branches. Thanks, Andrew! It's great to have this old item checked off of todo lists :-) I'll try to review some more of your patches this week; thanks for posting them. -- Daniel Jacobowitz CodeSourcery, LLC ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: $argc variable 2005-11-15 12:39 ` Daniel Jacobowitz 2005-11-15 17:54 ` Andrew STUBBS @ 2005-11-16 4:01 ` Eli Zaretskii 1 sibling, 0 replies; 8+ messages in thread From: Eli Zaretskii @ 2005-11-16 4:01 UTC (permalink / raw) To: Andrew STUBBS; +Cc: gdb-patches > Date: Mon, 14 Nov 2005 23:40:45 -0500 > From: Daniel Jacobowitz <drow@false.org> > Cc: Andrew STUBBS <andrew.stubbs@st.com>, gdb-patches@sources.redhat.com > > The code is fine too. > > Should this go on the branch? Should it go in NEWS? My inclination is > "both". Same here. ^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2005-11-16 14:56 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <436A0BD2.5080505@st.com>
[not found] ` <20051107001800.GF19200@nevyn.them.org>
[not found] ` <436F35E9.4070808@st.com>
[not found] ` <20051107133538.GA2331@nevyn.them.org>
[not found] ` <43709E94.4070004@st.com>
[not found] ` <u7jbisp6n.fsf@gnu.org>
[not found] ` <4371D9A6.40109@st.com>
[not found] ` <u3bm5sk6i.fsf@gnu.org>
[not found] ` <43731C16.2040203@st.com>
[not found] ` <20051113173524.GC1945@nevyn.them.org>
2005-11-14 22:12 ` $argc variable Andrew STUBBS
2005-11-15 12:35 ` Eli Zaretskii
2005-11-15 12:39 ` Daniel Jacobowitz
2005-11-15 17:54 ` Andrew STUBBS
2005-11-16 5:52 ` Eli Zaretskii
2005-11-16 14:43 ` Andrew STUBBS
2005-11-16 16:19 ` Daniel Jacobowitz
2005-11-16 4:01 ` Eli Zaretskii
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox