This makes gdbserver share gdb's savestring, instead of baking its own.
Tested on x86_64 Fedora 17.
gdb/
2013-02-14 Pedro Alves <palves@redhat.com>
* utils.c (savestring): Don't #undef it. Move function to
common/common-utils.c.
* common/common-utils.c: Include gdb_string.h.
(savestring): Move here from utils.c.
* common/common-utils.h (savestring): Declare.
gdb/gdbserver/
2013-02-14 Pedro Alves <palves@redhat.com>
* tracepoint.c (save_string): Delete.
(add_tracepoint_action): Use savestring instead of save_string.
+2013-02-14 Pedro Alves <palves@redhat.com>
+
+ * utils.c (savestring): Don't #undef it. Move function to
+ common/common-utils.c.
+ * common/common-utils.c: Include gdb_string.h.
+ (savestring): Move here from utils.c.
+ * common/common-utils.h (savestring): Declare.
+
2013-02-14 Pedro Alves <palves@redhat.com>
* utils.c (savestring): Rename parameter 'size' to 'len'.
#endif
#include "gdb_assert.h"
+#include "gdb_string.h"
#include <stdlib.h>
#include <stdio.h>
return ret;
}
+
+char *
+savestring (const char *ptr, size_t len)
+{
+ char *p = (char *) xmalloc (len + 1);
+
+ memcpy (p, ptr, len);
+ p[len] = 0;
+ return p;
+}
int xsnprintf (char *str, size_t size, const char *format, ...)
ATTRIBUTE_PRINTF (3, 4);
+/* Make a copy of the string at PTR with LEN characters
+ (and add a null character at the end in the copy).
+ Uses malloc to get the space. Returns the address of the copy. */
+
+char *savestring (const char *ptr, size_t len);
+
#endif
+2013-02-14 Pedro Alves <palves@redhat.com>
+
+ * tracepoint.c (save_string): Delete.
+ (add_tracepoint_action): Use savestring instead of save_string.
+
2013-02-12 Pedro Alves <palves@redhat.com>
* linux-xtensa-low.c: Ditto.
#endif
-static char *
-save_string (const char *str, size_t len)
-{
- char *s;
-
- s = xmalloc (len + 1);
- memcpy (s, str, len);
- s[len] = '\0';
-
- return s;
-}
-
/* Append another action to perform when the tracepoint triggers. */
static void
* tpoint->num_step_actions));
tpoint->step_actions[tpoint->num_step_actions - 1] = action;
tpoint->step_actions_str[tpoint->num_step_actions - 1]
- = save_string (act_start, act - act_start);
+ = savestring (act_start, act - act_start);
}
else
{
sizeof (*tpoint->actions_str) * tpoint->numactions);
tpoint->actions[tpoint->numactions - 1] = action;
tpoint->actions_str[tpoint->numactions - 1]
- = save_string (act_start, act - act_start);
+ = savestring (act_start, act - act_start);
}
}
}
extern void free ();
#endif
-/* readline defines this. */
-#undef savestring
-
void (*deprecated_error_begin_hook) (void);
/* Prototypes for local functions */
return orglen;
}
-/* Make a copy of the string at PTR with LEN characters
- (and add a null character at the end in the copy).
- Uses malloc to get the space. Returns the address of the copy. */
-
-char *
-savestring (const char *ptr, size_t len)
-{
- char *p = (char *) xmalloc (len + 1);
-
- memcpy (p, ptr, len);
- p[len] = 0;
- return p;
-}
-
void
print_spaces (int n, struct ui_file *file)
{