From: Tom Tromey <tromey@redhat.com>
To: Alfredo Ortega <ortegaalfredo@gmail.com>
Cc: gdb-patches@sourceware.org
Subject: Re: Use external editor in 'commands' command
Date: Mon, 02 Feb 2009 22:18:00 -0000 [thread overview]
Message-ID: <m38wooo54g.fsf@fleche.redhat.com> (raw)
In-Reply-To: <e598931c0901190345r449e9d0fpd0d6fc6f61f027d2@mail.gmail.com> (Alfredo Ortega's message of "Mon\, 19 Jan 2009 09\:45\:31 -0200")
>>>>> "Alfredo" == Alfredo Ortega <ortegaalfredo@gmail.com> writes:
Alfredo> 1) Following the suggestion of Tom Tromey, i made "commands"
Alfredo> a prefix command, and now it is "commands edit n".
Your patch does this using strncmp -- but gdb already has built-in
machinery for prefix commands. See add_prefix_cmd. So, the idea here
would be to change _initialize_breakpoint to use add_prefix_cmd,
instead of add_com, when creating the "commands" command. Then, you'd
have a separate function to implement "commands edit". Maybe this
means introducing a helper function to do some of the work, I don't
know.
Alfredo> This is a much better patch, but also is a much bigger one (I already
Alfredo> sent the FSF form that Tom suggested), so surely there are plenty of
Alfredo> errors. Corrections are welcomed.
A few nits inline.
Alfredo> +#define COMMANDS_EDCOMMAND "edit"
With the prefix change, you won't need this.
Alfredo> + /* Edit commands with external editor */
In the GNU style, comments are full sentences that start with a
capital letter and end with a period and two spaces. This one is
missing the period, but others are incorrect in other ways.
Alfredo> + /* discard the "edit" command */
E.g., this one...
Alfredo> + get_number (&p);
Alfredo> + bnum = get_number (&p);
Two calls to get_number seems suspect.
Alfredo> + /* vitmp = tempnam(NULL,".gdb"); this is more secure according to man mkstemp, but gcc complains... */
There's no need for this comment, IMO.
Alfredo> + if (!(vitmp = make_temp_file (NULL)))
GNU style prohibits assignments in conditionals.
Alfredo> + {
Alfredo> + error (_("Can't create temporary file for editing."));
Alfredo> + return;
Alfredo> + }
The "error" function never returns. It calls longjmp. So, this
return is not needed. This occurs in a few spots.
Alfredo> + l = b->commands;
Alfredo> + while (l)
Alfredo> + {
Alfredo> + fsize = 0;
Alfredo> + fsize += fwrite (l->line, 1, strlen (l->line), tmpstream);
I think you should probably use "print_command_lines" to print the
breakpoint commands to a file.
Alfredo> + sysret = system (cmdline);
Alfredo> + xfree (cmdline);
Alfredo> + if (sysret < 0)
I think this should also check "sysret" when it is >= 0, and fail if
the editor does not exit with status 0.
Thanks for working on this,
Tom
next prev parent reply other threads:[~2009-02-02 22:18 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <e598931c0901141343j79164cf6we2bc5307f41f41da@mail.gmail.com>
2009-01-14 21:48 ` Alfredo Ortega
2009-01-14 22:38 ` Eli Zaretskii
2009-01-15 1:55 ` Alfredo Ortega
2009-01-22 3:25 ` dgutson
[not found] ` <e598931c0901141632m4f124d85l2452f7e2870cad91@mail.gmail.com>
2009-01-15 4:21 ` Eli Zaretskii
2009-01-16 7:39 ` Alfredo Ortega
2009-01-16 9:07 ` Eli Zaretskii
2009-01-16 22:08 ` Alfredo Ortega
2009-01-16 23:38 ` Daniel Jacobowitz
2009-01-16 23:58 ` Tom Tromey
2009-01-17 9:27 ` Eli Zaretskii
2009-01-16 23:56 ` Tom Tromey
2009-01-17 9:29 ` Eli Zaretskii
2009-01-19 11:45 ` Alfredo Ortega
2009-02-02 22:18 ` Tom Tromey [this message]
2009-02-19 20:05 ` Alfredo Ortega
2009-02-19 20:26 ` Alfredo Ortega
2009-02-24 20:20 ` Tom Tromey
2009-08-28 23:17 ` Alfredo Ortega
2009-09-18 21:05 ` Tom Tromey
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=m38wooo54g.fsf@fleche.redhat.com \
--to=tromey@redhat.com \
--cc=gdb-patches@sourceware.org \
--cc=ortegaalfredo@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox