This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[RFA] Add optional sequence number to record log filename
- From: Michael Snyder <msnyder at vmware dot com>
- To: "gdb-patches at sourceware dot org" <gdb-patches at sourceware dot org>, Hui Zhu <teawater at gmail dot com>
- Date: Thu, 26 Nov 2009 13:35:59 -0800
- Subject: [RFA] Add optional sequence number to record log filename
Eli, IOU a docs change.
Hui, see parallel RFC thread.
2009-11-26 Michael Snyder <msnyder@vmware.com>
* record.c (cmd_record_save): Add new argument, treated as a
sequence number for save log file names.
Index: record.c
===================================================================
RCS file: /cvs/src/src/gdb/record.c,v
retrieving revision 1.40
diff -u -p -r1.40 record.c
--- record.c 24 Nov 2009 01:47:51 -0000 1.40
+++ record.c 26 Nov 2009 21:37:30 -0000
@@ -30,6 +30,7 @@
#include "record.h"
#include "elf-bfd.h"
#include "gcore.h"
+#include "cli/cli-dump.h"
#include <signal.h>
@@ -2330,7 +2331,7 @@ record_save_cleanups (void *data)
static void
cmd_record_save (char *args, int from_tty)
{
- char *recfilename, recfilename_buffer[40];
+ char *recfilename;
int recfd;
struct record_entry *cur_record_list;
uint32_t magic;
@@ -2342,19 +2343,33 @@ cmd_record_save (char *args, int from_tt
int save_size = 0;
asection *osec = NULL;
int bfd_offset = 0;
+ LONGEST tmp;
if (strcmp (current_target.to_shortname, "record") != 0)
error (_("This command can only be used with target 'record'.\n"
"Use 'target record' first.\n"));
if (args && *args)
- recfilename = args;
+ {
+ /* Reap the filename, leave args pointing to any following arg. */
+ recfilename = scan_filename_with_cleanup (&args, NULL);
+ }
else
{
/* Default recfile name is "gdb_record.PID". */
- snprintf (recfilename_buffer, sizeof (recfilename_buffer),
+#define DEFSIZE 80
+ recfilename = xmalloc (DEFSIZE);
+ snprintf (recfilename, DEFSIZE,
"gdb_record.%d", PIDGET (inferior_ptid));
- recfilename = recfilename_buffer;
+ make_cleanup (xfree, recfilename);
+ }
+
+ /* Look for optional sequence number. */
+ if (args && *args)
+ {
+ tmp = parse_and_eval_long (args);
+ strcat (recfilename, ".");
+ strcat (recfilename, plongest (tmp));
}
/* Open the save file. */