From: Gary Benson <gbenson@redhat.com>
To: gdb-patches@sourceware.org
Cc: Andrew Burgess <aburgess@broadcom.com>,
Doug Evans <xdje42@gmail.com>,
Eli Zaretskii <eliz@gnu.org>,
Florian Weimer <fw@deneb.enyo.de>,
Mark Kettenis <mark.kettenis@xs4all.nl>,
Pedro Alves <palves@redhat.com>,
Tom Tromey <tromey@redhat.com>
Subject: [PATCH 2/3 v4] Refactor and expose core-dumping functionality
Date: Thu, 05 Jun 2014 13:03:00 -0000 [thread overview]
Message-ID: <20140605130322.GC20572@blade.nx> (raw)
In-Reply-To: <20140605130140.GA20572@blade.nx>
This patch exposes the functions that dump core outside utils.c.
The function can_dump_core has been split into two new functions,
check_can_dump_core and warn_cant_dump_core so that the check and
the printed warning can be separated. A new function
check_can_dump_core_warn replaces the original can_dump_core.
gdb/
2014-06-05 Gary Benson <gbenson@redhat.com>
* utils.h (check_can_dump_core): New declaration.
(warn_cant_dump_core): Likewise.
(dump_core): Likewise.
* utils.c (dump_core): Made nonstatic.
(can_dump_core): Removed function.
(check_can_dump_core): New function.
(warn_cant_dump_core): Likewise.
(check_can_dump_core_warn): Likewise.
(internal_vproblem): Replace calls to can_dump_core with
calls to check_can_dump_core_warn.
diff --git a/gdb/utils.h b/gdb/utils.h
index 0ba7879..a6115c1 100644
--- a/gdb/utils.h
+++ b/gdb/utils.h
@@ -374,4 +374,18 @@ extern ULONGEST align_down (ULONGEST v, int n);
extern LONGEST gdb_sign_extend (LONGEST value, int bit);
+/* Check whether GDB will be able to dump core using the dump_core
+ function. */
+
+extern int check_can_dump_core (void);
+
+/* Print a warning that we cannot dump core. */
+
+extern void warn_cant_dump_core (const char *reason);
+
+/* Dump core trying to increase the core soft limit to hard limit
+ first. */
+
+extern void dump_core (void);
+
#endif /* UTILS_H */
diff --git a/gdb/utils.c b/gdb/utils.c
index a72f3bd..0f25436 100644
--- a/gdb/utils.c
+++ b/gdb/utils.c
@@ -600,7 +600,7 @@ error_stream (struct ui_file *stream)
/* Dump core trying to increase the core soft limit to hard limit first. */
-static void
+void
dump_core (void)
{
#ifdef HAVE_SETRLIMIT
@@ -615,8 +615,8 @@ dump_core (void)
/* Check whether GDB will be able to dump core using the dump_core
function. */
-static int
-can_dump_core (const char *reason)
+int
+check_can_dump_core (void)
{
#ifdef HAVE_GETRLIMIT
struct rlimit rlim;
@@ -626,18 +626,37 @@ can_dump_core (const char *reason)
return 1;
if (rlim.rlim_max == 0)
- {
- fprintf_unfiltered (gdb_stderr,
- _("%s\nUnable to dump core, use `ulimit -c"
- " unlimited' before executing GDB next time.\n"),
- reason);
- return 0;
- }
+ return 0;
#endif /* HAVE_GETRLIMIT */
return 1;
}
+/* Print a warning that we cannot dump core. */
+
+void
+warn_cant_dump_core (const char *reason)
+{
+ fprintf_unfiltered (gdb_stderr,
+ _("%s\nUnable to dump core, use `ulimit -c"
+ " unlimited' before executing GDB next time.\n"),
+ reason);
+}
+
+/* Check whether GDB will be able to dump core using the dump_core
+ function, and print a warning if we cannot. */
+
+static int
+check_can_dump_core_warn (const char *reason)
+{
+ int can_dump_core = check_can_dump_core ();
+
+ if (!can_dump_core)
+ warn_cant_dump_core (reason);
+
+ return can_dump_core;
+}
+
/* Allow the user to configure the debugger behavior with respect to
what to do when an internal problem is detected. */
@@ -756,7 +775,7 @@ internal_vproblem (struct internal_problem *problem,
if (problem->should_dump_core == internal_problem_ask)
{
- if (!can_dump_core (reason))
+ if (!check_can_dump_core_warn (reason))
dump_core_p = 0;
else
{
@@ -767,7 +786,7 @@ internal_vproblem (struct internal_problem *problem,
}
}
else if (problem->should_dump_core == internal_problem_yes)
- dump_core_p = can_dump_core (reason);
+ dump_core_p = check_can_dump_core_warn (reason);
else if (problem->should_dump_core == internal_problem_no)
dump_core_p = 0;
else
next prev parent reply other threads:[~2014-06-05 13:03 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-06-05 13:01 [PATCH 0/3 v4] Demangler crash handler Gary Benson
2014-06-05 13:02 ` [PATCH 1/3 v4] Add new internal problem for demangler warnings Gary Benson
2014-06-05 13:03 ` Gary Benson [this message]
2014-06-05 16:28 ` [PATCH 2/3 v4] Refactor and expose core-dumping functionality Doug Evans
2014-06-06 9:09 ` Gary Benson
2014-06-05 13:04 ` [PATCH 3/3 v4] Demangler crash handler Gary Benson
2014-06-06 18:16 ` Florian Weimer
2014-06-06 19:27 ` Gary Benson
2014-06-06 19:42 ` Florian Weimer
2014-06-06 21:12 ` Andrew Burgess
2014-06-09 9:01 ` Gary Benson
2014-06-09 10:26 ` Andrew Burgess
2014-06-09 11:48 ` Gary Benson
2014-06-05 16:19 ` [PATCH 0/3 " Doug Evans
2014-06-06 9:19 ` Gary Benson
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=20140605130322.GC20572@blade.nx \
--to=gbenson@redhat.com \
--cc=aburgess@broadcom.com \
--cc=eliz@gnu.org \
--cc=fw@deneb.enyo.de \
--cc=gdb-patches@sourceware.org \
--cc=mark.kettenis@xs4all.nl \
--cc=palves@redhat.com \
--cc=tromey@redhat.com \
--cc=xdje42@gmail.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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).