From b31488a3449cd97297b0972c016016f1d4c60389 Mon Sep 17 00:00:00 2001 From: Kamil Rytarowski Date: Tue, 28 Jul 2020 17:29:35 +0200 Subject: gdb: Implement native dumpcore function Add new API for systems with native kernel support for dumping a process on demand. Wire it into the gdb's gcore functionality. gdb/ChangeLog: * target.h (supports_dumpcore, dumpcore): New function declarations. * target.c (supports_dumpcore, dumpcore): New functions. * target-delegates.c: Rebuild. * gcore.c (gcore_command): Use target_supports_dumpcore () and target_dumpcore (). --- gdb/gcore.c | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) (limited to 'gdb/gcore.c') diff --git a/gdb/gcore.c b/gdb/gcore.c index 7b653fb..d0e36b1 100644 --- a/gdb/gcore.c +++ b/gdb/gcore.c @@ -145,17 +145,22 @@ gcore_command (const char *args, int from_tty) "Opening corefile '%s' for output.\n", corefilename.get ()); - /* Open the output file. */ - gdb_bfd_ref_ptr obfd (create_gcore_bfd (corefilename.get ())); + if (target_supports_dumpcore ()) + target_dumpcore (corefilename.get ()); + else + { + /* Open the output file. */ + gdb_bfd_ref_ptr obfd (create_gcore_bfd (corefilename.get ())); - /* Arrange to unlink the file on failure. */ - gdb::unlinker unlink_file (corefilename.get ()); + /* Arrange to unlink the file on failure. */ + gdb::unlinker unlink_file (corefilename.get ()); - /* Call worker function. */ - write_gcore_file (obfd.get ()); + /* Call worker function. */ + write_gcore_file (obfd.get ()); - /* Succeeded. */ - unlink_file.keep (); + /* Succeeded. */ + unlink_file.keep (); + } fprintf_filtered (gdb_stdout, "Saved corefile %s\n", corefilename.get ()); } -- cgit v1.1