This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [RFA 2/4] Implement | (pipe) command.


>>>>> "Philippe" == Philippe Waroquiers <philippe.waroquiers@skynet.be> writes:

Philippe> +  while (*shell_command && *shell_command != '|')
Philippe> +    shell_command++;

I think using strchr would be preferable here.

Philippe> +  if (gdb_cmd.length () == 0)

Use .empty instead.

Philippe> +      if (gdb_cmd.length () == 0)

Likewise.

Philippe> +  to = popen (shell_command, "w");

I wonder if it's better to use libiberty's pexecute code?
This may avoid the WIFEXITED problems.

Philippe> +	/* In case GDB_CMD switches of inferior/thread/frame, the below
Philippe> +	   restores the inferior/thread/frame.  */
Philippe> +	scoped_restore_current_thread restore;

What's the rationale for this?

Philippe> +	gdb_cmd_result = execute_command_to_string (gdb_cmd.c_str (),
Philippe> +						    from_tty);
Philippe> +
Philippe> +	if (fwrite (gdb_cmd_result.c_str (), 1, gdb_cmd_result.length (), to)
Philippe> +	    != gdb_cmd_result.length ())
Philippe> +	  {
Philippe> +	    error (_("error writing \"%s\" result to \"%s\", errno %s"),
Philippe> +		   gdb_cmd.c_str (), shell_command, safe_strerror (errno));
Philippe> +	  }

Maybe it would be preferable to redirect gdb's actual output here
instead, using whatever mechanism it is that "set logging" uses.

Tom


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]