--pid and --core

Pedro Alves pedro@codesourcery.com
Thu Jan 3 16:56:00 GMT 2008


Hi all,

I was looking through --pid and attach mingw PRs in the GNATS,
and noticed an annoying issue.

If one specifies an explicit PID to attach to, failing to
attach, gdb will try to open a core file of the same name.

The attach fail -> open core is there to support
invoking gdb as:

      gdb program pid

or:

      gdb program core

Since, if the user specifies gdb program 3333, gdb can't
know if 3333 is a pid or a core file named "3333".

So for, so good.  Now,

If the user specifies,

      gdb program --pid=3333,

gdb has no business trying to look for a core file named 3333.

The patch avoids these confusing messages [1] when the user specifies
an invalid or non-existing pid:

Before:

     >./gdb --pid=3333
     Attaching to process 3333
     ptrace: No such process.
     /home/pedro/gdb/build/3333: No such file or directory.  <==== [1]
     (gdb)

After:

     >./gdb --pid=3333
     Attaching to process 3333
     ptrace: No such process.
     (gdb)

The patch also catches invalid simultaneous --pid,--core uses,

And these weirdnesses:

Before:

   >gdb/gdb gdb/gdb --pid=3333 4444 5555
   Excess command line arguments ignored. (5555)
   Attaching to program: /home/pedro/gdb/build/gdb/gdb, process 4444
   ptrace: No such process.
   /home/pedro/gdb/build/4444: No such file or directory.

After:

   >gdb/gdb gdb/gdb --pid=3333 4444 5555
   Excess command line arguments ignored. (4444 ...)
   Attaching to program: /home/pedro/gdb/build/gdb/gdb, process 3333
   ptrace: No such process.

Tested on i686-pc-linux-gnu, no regressions.

OK ?


-------------- next part --------------
A non-text attachment was scrubbed...
Name: pid_core_split.diff
Type: text/x-diff
Size: 4149 bytes
Desc: not available
URL: <http://sourceware.org/pipermail/gdb-patches/attachments/20080103/e772255a/attachment.bin>


More information about the Gdb-patches mailing list