This is the mail archive of the gdb@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]

info proc cmd


There seems to be a bug in "info proc".  The command line of the
process is produced like this (in linux-nat.c):

  if (cmdline_f || all)
    {
      sprintf (fname1, "/proc/%lld/cmdline", pid);
      if ((procfile = fopen (fname1, "r")) != NULL)
        {
          fgets (buffer, sizeof (buffer), procfile);
          printf_filtered ("cmdline = '%s'\n", buffer);

This seems to assume that the command line is stored in
/proc/PID/cmdline as a single newline-terminated character string.
But in fact the command-line arguments are stored there as a set of
null-terminated strings.  (Or at least that's what I see on two
GNU/Linux systems I have access to from where I'm writing this, and
the proc(5) man page says that as well.)  So what we wind up doing is
display only the first command-line argument.

This bug is easy enough to fix, but I wonder whether some older
versions of Linux did use the one-string format, in which case fixing
this to assume a set of null-terminated arguments would break those
old systems.

Does anyone has further insight into the history of this?  Should I
just go ahead and fix the code?


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