From: Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE>
To: gdb-patches@sourceware.org
Subject: [PATCH] Provide pid_to_exec_file on Solaris (PR tdep/17903)
Date: Wed, 19 Sep 2018 14:19:00 -0000 [thread overview]
Message-ID: <ydd4lelh8q2.fsf@CeBiTec.Uni-Bielefeld.DE> (raw)
[-- Attachment #1: Type: text/plain, Size: 859 bytes --]
While looking through gdb.log, I found that two tests FAIL like this:
warning: No executable has been specified and target does not support
determining executable automatically. Try using the "file" command.
0x00400dc4 in ?? ()
(gdb) FAIL: gdb.base/attach.exp: attach2, with no file
The other is gdb.base/quit-live.exp. I've implemented the following
patch that fixes both failures, only then detecting that I'd previously
reported the issue as PR tdep/17903.
Tested on amd64-pc-solaris2.10 and amd64-pc-solaris2.11, ok for master?
Rainer
--
-----------------------------------------------------------------------------
Rainer Orth, Center for Biotechnology, Bielefeld University
2018-06-13 Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE>
PR tdep/17903
* procfs.c (procfs_target): Declare pid_to_exec_file.
(procfs_target::pid_to_exec_file): New.
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: sol2-procfs-pid_to_exec_file.patch --]
[-- Type: text/x-patch, Size: 1353 bytes --]
# HG changeset patch
# Parent a7848e82a4d1e81ba23d3a82820e881924b84fdd
Provide pid_to_exec_file on Solaris
diff --git a/gdb/procfs.c b/gdb/procfs.c
--- a/gdb/procfs.c
+++ b/gdb/procfs.c
@@ -128,6 +128,8 @@ public:
const char *pid_to_str (ptid_t) override;
+ char *pid_to_exec_file (int pid) override;
+
thread_control_capabilities get_thread_control_capabilities () override
{ return tc_schedlock; }
@@ -3135,6 +3137,35 @@ procfs_target::pid_to_str (ptid_t ptid)
return buf;
}
+/* Accepts an integer PID; Returns a string representing a file that
+ can be opened to get the symbols for the child process. */
+
+char *
+procfs_target::pid_to_exec_file (int pid)
+{
+ static char buf[PATH_MAX];
+ char name[PATH_MAX];
+
+ /* Solaris 11 introduced /proc/<proc-id>/execname. */
+ xsnprintf (name, PATH_MAX, "/proc/%d/execname", pid);
+ scoped_fd fd (open (name, O_RDONLY));
+ if (fd.get () < 0 || read (fd.get (), buf, PATH_MAX - 1) < 0)
+ {
+ /* If that fails, fall back to /proc/<proc-id>/path/a.out introduced in
+ Solaris 10. */
+ ssize_t len;
+
+ xsnprintf (name, PATH_MAX, "/proc/%d/path/a.out", pid);
+ len = readlink (name, buf, PATH_MAX - 1);
+ if (len <= 0)
+ strcpy (buf, name);
+ else
+ buf[len] = '\0';
+ }
+
+ return buf;
+}
+
/* Insert a watchpoint. */
static int
next reply other threads:[~2018-09-19 14:19 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-09-19 14:19 Rainer Orth [this message]
2018-09-19 14:36 ` Joel Brobecker
2018-09-19 17:44 ` Rainer Orth
2018-09-19 18:06 ` Joel Brobecker
2018-09-19 14:49 ` Tom Tromey
2018-09-19 14:53 ` Simon Marchi
2018-09-19 17:50 ` Rainer Orth
2018-09-19 17:47 ` Rainer Orth
2018-09-20 9:27 ` Rainer Orth
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ydd4lelh8q2.fsf@CeBiTec.Uni-Bielefeld.DE \
--to=ro@cebitec.uni-bielefeld.de \
--cc=gdb-patches@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox