/* Target-dependent code for GNU/Linux, architecture independent.
- Copyright (C) 2009-2013 Free Software Foundation, Inc.
+ Copyright (C) 2009-2014 Free Software Foundation, Inc.
This file is part of GDB.
#include "cli/cli-utils.h"
#include "arch-utils.h"
#include "gdb_obstack.h"
-#include "cli/cli-utils.h"
#include <ctype.h>
/* Implement the "info proc" command. */
static void
-linux_info_proc (struct gdbarch *gdbarch, char *args,
+linux_info_proc (struct gdbarch *gdbarch, const char *args,
enum info_proc_what what)
{
/* A long is used for pid instead of an int to avoid a loss of precision
int target_errno;
if (args && isdigit (args[0]))
- pid = strtoul (args, &args, 10);
+ {
+ char *tem;
+
+ pid = strtoul (args, &tem, 10);
+ args = tem;
+ }
else
{
if (!target_has_execution)
pid = current_inferior ()->pid;
}
- args = skip_spaces (args);
+ args = skip_spaces_const (args);
if (args && args[0])
error (_("Too many parameters: %s"), args);
p = skip_spaces_const (p);
if (*p == '(')
{
- const char *ep = strchr (p, ')');
+ /* ps command also relies on no trailing fields
+ ever contain ')'. */
+ const char *ep = strrchr (p, ')');
if (ep != NULL)
{
printf_filtered ("Exec file: %.*s\n",
/* Implement "info proc mappings" for a corefile. */
static void
-linux_core_info_proc_mappings (struct gdbarch *gdbarch, char *args)
+linux_core_info_proc_mappings (struct gdbarch *gdbarch, const char *args)
{
asection *section;
ULONGEST count, page_size;
/* Implement "info proc" for a corefile. */
static void
-linux_core_info_proc (struct gdbarch *gdbarch, char *args,
+linux_core_info_proc (struct gdbarch *gdbarch, const char *args,
enum info_proc_what what)
{
int exe_f = (what == IP_MINIMAL || what == IP_EXE || what == IP_ALL);
struct cleanup *old_chain;
struct regcache *regcache;
gdb_byte *siginfo_data;
- LONGEST siginfo_size;
+ LONGEST siginfo_size = 0;
regcache = get_thread_arch_regcache (info->ptid, args->gdbarch);
proc_stat = skip_spaces (proc_stat);
- /* Getting rid of the executable name, since we already have it. We
- know that this name will be in parentheses, so we can safely look
- for the close-paren. */
- while (*proc_stat != ')')
- ++proc_stat;
- ++proc_stat;
+ /* ps command also relies on no trailing fields ever contain ')'. */
+ proc_stat = strrchr (proc_stat, ')');
+ if (proc_stat == NULL)
+ {
+ do_cleanups (c);
+ return 1;
+ }
+ proc_stat++;
proc_stat = skip_spaces (proc_stat);
note_data = linux_make_mappings_corefile_notes (gdbarch, obfd,
note_data, note_size);
- make_cleanup (xfree, note_data);
return note_data;
}