diff agent/src/os/linux/LinuxDebuggerLocal.c @ 23475:d06b64fc150f

8145099: Better error message when SA can't attach to a process Reviewed-by: jbachorik, stuefe
author sla
date Thu, 10 Dec 2015 16:09:36 +0100
parents f2512d89ad0c
children
line wrap: on
line diff
--- a/agent/src/os/linux/LinuxDebuggerLocal.c	Thu Dec 10 14:51:53 2015 +0300
+++ b/agent/src/os/linux/LinuxDebuggerLocal.c	Thu Dec 10 16:09:36 2015 +0100
@@ -209,9 +209,12 @@
   verifyBitness(env, (char *) &buf);
   CHECK_EXCEPTION;
 
+  char err_buf[200];
   struct ps_prochandle* ph;
-  if ( (ph = Pgrab(jpid)) == NULL) {
-    THROW_NEW_DEBUGGER_EXCEPTION("Can't attach to the process");
+  if ( (ph = Pgrab(jpid, err_buf, sizeof(err_buf))) == NULL) {
+    char msg[230];
+    snprintf(msg, sizeof(msg), "Can't attach to the process: %s", err_buf);
+    THROW_NEW_DEBUGGER_EXCEPTION(msg);
   }
   (*env)->SetLongField(env, this_obj, p_ps_prochandle_ID, (jlong)(intptr_t)ph);
   fillThreadsAndLoadObjects(env, this_obj, ph);