--- ./gdb/gcore.c_orig	2017-01-21 07:48:42 -0600
+++ ./gdb/gcore.c	2017-05-22 07:52:30 -0500
@@ -34,6 +34,10 @@
 #include "regset.h"
 #include "gdb_bfd.h"
 #include "readline/tilde.h"
+#include <core.h>
+#include <pthread.h>
+#include <sys/stat.h>
+#include <libgen.h>
 
 /* The largest amount of memory to read from the target at once.  We
    must throttle it to limit the amount of memory used by GDB during
@@ -45,6 +49,12 @@
 static unsigned long default_gcore_mach (void);
 static int gcore_memory_sections (bfd *);
 
+struct gencore_args {
+    char *name;
+    pid_t pid; 
+};
+extern void step_1_ext (int, int, char *);
+
 /* create_gcore_bfd -- helper for gcore_command (exported).
    Open a new bfd core file for output, and return the handle.  */
 
@@ -144,6 +154,21 @@
   unlink (filename);
 }
 
+void issue_gencore_aix (struct gencore_args *args)
+{
+    struct coredumpinfo dumpinfo;
+    int rc = 0;
+
+    dumpinfo.length = strlen(args->name);
+    dumpinfo.name = args->name;
+    dumpinfo.flags = GENCORE_VERSION_1;
+    dumpinfo.pid = args->pid;
+    rc = gencore(&dumpinfo);
+    if (rc != 0)
+       /* fprintf(stdout, "gencore failed\n"); */
+        fprintf_filtered (gdb_stdout, "gencore failed\n");
+}
+
 /* gcore_command -- implements the 'gcore' command.
    Generate a core file from the inferior process.  */
 
@@ -155,6 +180,13 @@
   char *corefilename;
   bfd *obfd;
 
+   pthread_t gcore_t;
+  struct gencore_args g_args;
+  int rc = 0;
+  time64_t last_mod = 0;
+  char *dir;
+  struct stat64 st;
+
   /* No use generating a corefile without a target process.  */
   if (!target_has_execution)
     noprocess ();
@@ -172,6 +204,40 @@
     fprintf_filtered (gdb_stdout,
 		      "Opening corefile '%s' for output.\n", corefilename);
 
+  #if (GDB_OSABI_DEFAULT == GDB_OSABI_AIX)
+    g_args.name = corefilename;
+    g_args.pid = ptid_get_pid (inferior_ptid);
+
+    if (!access (corefilename, W_OK)) {
+        if (!stat (corefilename, &st))
+            last_mod = st.st_mtime;
+    }
+    dir = dirname (corefilename);
+    /* Check if directory has the write permission. */
+    if (dir && !access (dir, W_OK)) {
+      rc = pthread_create(&gcore_t, NULL, &issue_gencore_aix, &g_args);
+      if (!rc) {
+        step_1_ext (0, 1, "1");
+        if (!access (corefilename, R_OK) && !last_mod)
+           fprintf_filtered (gdb_stdout,
+                          "Saved corefile '%s' \n", corefilename);
+        else if (!access (corefilename, R_OK) && last_mod)  {
+           stat(corefilename, &st);
+           if (st.st_mtime > last_mod)
+             fprintf_filtered (gdb_stdout,
+                             "Saved corefile '%s' \n", corefilename);
+           else
+             fprintf_filtered (gdb_stdout,
+                             "Unable to generate core\n");
+        }
+      }
+    } else {
+       fprintf_filtered (gdb_stdout,
+                      "Can't open :%s for writing \n", corefilename);
+    }
+ do_cleanups (filename_chain);
+ #else
+
   /* Open the output file.  */
   obfd = create_gcore_bfd (corefilename);
 
@@ -187,6 +253,7 @@
 
   fprintf_filtered (gdb_stdout, "Saved corefile %s\n", corefilename);
   do_cleanups (filename_chain);
+  #endif
 }
 
 static unsigned long
--- ./gdb/infcmd.c_orig	2017-01-21 07:48:42 -0600
+++ ./gdb/infcmd.c	2017-05-22 07:52:42 -0500
@@ -141,6 +141,11 @@
 
 int startup_with_shell = 1;
 
+void step_1_ext (int skip, int inst, char *string)
+{
+    step_1 (skip, inst, string);
+}
+
 
 /* Accessor routines.  */
 
