From: Joel Brobecker <brobecker@adacore.com>
To: gdb-patches@sources.redhat.com
Subject: How to implement gcore on pa-hpux ?
Date: Wed, 04 Jan 2006 17:40:00 -0000 [thread overview]
Message-ID: <20060104174009.GC1868@adacore.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 1583 bytes --]
Hello,
I have implemented the gcore command on pa-hpux for one of our customers.
I would like to contribute this work, but I know that for sure the
approach is took is not acceptable.
The work is based on using the TT_PROC_CORE ttrace command:
TT_PROC_CORE This request causes the traced process to generate a
core file in the target process's current working
directory. The core file is named core.pid where pid is
the process ID of the target process. The process's
state is left unchanged. The lwpid, addr, data and
addr2 arguments must be zero.
So I created a new function in infttrace.c. In order to avoid re-writing
the part of gcore.c that add the command, and handles the arguments of this
command, I simply hooked the new infttrace directly into the gcore code.
A bit crude, but it works and it's pretty localized.
For the FSF tree, I'd like to implement this a little better, and it
seems to me that the core part of this command, the part that actually
creates the core file, should be a method of some vector. But which
vector?
The way the gcore command is currently written, it seems that it would
make sense for it to be part of the target vector. No?
However, in the case of HP/UX, there is a slight complication, because
the method is only good in the native case...
Any suggestion?
Attached is the infttrace function that creates the core dump. It is
largely inspired from the HP WDB debugger sources (contributed recently).
Thanks,
--
Joel
[-- Attachment #2: dcf.c --]
[-- Type: text/plain, Size: 1156 bytes --]
void
dump_core_file (int pid, const char *filename)
{
int tt_status;
char buf[64];
tt_status = call_ttrace (TT_PROC_CORE, pid, (TTRACE_ARG_TYPE) filename, 0, 0);
if (tt_status == -1)
{
/* With some versions of HP/UX, specifying the name of the core file
is not supported, so this may have been the cause for this failure.
Try again without the file name. */
tt_status = call_ttrace (TT_PROC_CORE, pid, 0, 0, 0);
if (tt_status != -1)
{
/* Success, so indeed the filename was the source of the problem.
Inform the user that the core file was named differently
(if indeed the filename is different from the default core
file name!) */
sprintf (buf, "core.%d", pid);
if (strcmp (filename, buf) != 0)
{
warning ("The Operating System does not allow the dump in %s",
filename);
filename = buf;
}
}
}
if (tt_status == -1)
perror_with_name ("ttrace:");
else
fprintf_filtered (gdb_stdout, "Saved corefile %s\n", filename);
}
next reply other threads:[~2006-01-04 17:40 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-01-04 17:40 Joel Brobecker [this message]
2006-01-04 18:40 ` Daniel Jacobowitz
2006-01-04 19:12 ` Michael Snyder
2006-01-05 3:24 ` Joel Brobecker
2006-01-06 4:40 ` Michael Snyder
2006-01-06 10:28 ` Joel Brobecker
2006-01-06 13:43 ` Daniel Jacobowitz
2006-01-09 5:59 ` Joel Brobecker
2006-01-22 20:43 ` Daniel Jacobowitz
2006-01-05 4:03 ` Joel Brobecker
2006-01-05 5:02 ` Daniel Jacobowitz
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=20060104174009.GC1868@adacore.com \
--to=brobecker@adacore.com \
--cc=gdb-patches@sources.redhat.com \
/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