hotspot/src/os/linux/vm/os_linux.cpp
changeset 38697 110bb528423b
parent 38290 6b194cfc1557
parent 38658 34f9c45625d8
child 39390 edf6a424a8b7
equal deleted inserted replaced
38303:1d0016127806 38697:110bb528423b
  1923   int fd = ::open(filename, O_RDONLY);
  1923   int fd = ::open(filename, O_RDONLY);
  1924   if (fd == -1) {
  1924   if (fd == -1) {
  1925     return false;
  1925     return false;
  1926   }
  1926   }
  1927 
  1927 
  1928   char buf[32];
  1928   char buf[33];
  1929   int bytes;
  1929   int bytes;
  1930   while ((bytes = ::read(fd, buf, sizeof(buf))) > 0) {
  1930   buf[32] = '\0';
       
  1931   while ((bytes = ::read(fd, buf, sizeof(buf)-1)) > 0) {
  1931     st->print_raw(buf, bytes);
  1932     st->print_raw(buf, bytes);
  1932   }
  1933   }
  1933 
  1934 
  1934   ::close(fd);
  1935   ::close(fd);
  1935 
  1936 
  6043       return -1;
  6044       return -1;
  6044     }
  6045     }
  6045 
  6046 
  6046     if (core_pattern[0] == '|') {
  6047     if (core_pattern[0] == '|') {
  6047       written = jio_snprintf(buffer, bufferSize,
  6048       written = jio_snprintf(buffer, bufferSize,
  6048                         "\"%s\" (or dumping to %s/core.%d)",
  6049                              "\"%s\" (or dumping to %s/core.%d)",
  6049                                      &core_pattern[1], p, current_process_id());
  6050                              &core_pattern[1], p, current_process_id());
  6050     } else {
  6051     } else {
  6051       written = jio_snprintf(buffer, bufferSize, "%s/%s", p, core_pattern);
  6052       written = jio_snprintf(buffer, bufferSize, "%s/%s", p, core_pattern);
  6052     }
  6053     }
  6053   }
  6054   }
  6054 
  6055 
  6077 bool os::start_debugging(char *buf, int buflen) {
  6078 bool os::start_debugging(char *buf, int buflen) {
  6078   int len = (int)strlen(buf);
  6079   int len = (int)strlen(buf);
  6079   char *p = &buf[len];
  6080   char *p = &buf[len];
  6080 
  6081 
  6081   jio_snprintf(p, buflen-len,
  6082   jio_snprintf(p, buflen-len,
  6082              "\n\n"
  6083                "\n\n"
  6083              "Do you want to debug the problem?\n\n"
  6084                "Do you want to debug the problem?\n\n"
  6084              "To debug, run 'gdb /proc/%d/exe %d'; then switch to thread " UINTX_FORMAT " (" INTPTR_FORMAT ")\n"
  6085                "To debug, run 'gdb /proc/%d/exe %d'; then switch to thread " UINTX_FORMAT " (" INTPTR_FORMAT ")\n"
  6085              "Enter 'yes' to launch gdb automatically (PATH must include gdb)\n"
  6086                "Enter 'yes' to launch gdb automatically (PATH must include gdb)\n"
  6086              "Otherwise, press RETURN to abort...",
  6087                "Otherwise, press RETURN to abort...",
  6087              os::current_process_id(), os::current_process_id(),
  6088                os::current_process_id(), os::current_process_id(),
  6088              os::current_thread_id(), os::current_thread_id());
  6089                os::current_thread_id(), os::current_thread_id());
  6089 
  6090 
  6090   bool yes = os::message_box("Unexpected Error", buf);
  6091   bool yes = os::message_box("Unexpected Error", buf);
  6091 
  6092 
  6092   if (yes) {
  6093   if (yes) {
  6093     // yes, user asked VM to launch debugger
  6094     // yes, user asked VM to launch debugger
  6094     jio_snprintf(buf, sizeof(buf), "gdb /proc/%d/exe %d",
  6095     jio_snprintf(buf, sizeof(char)*buflen, "gdb /proc/%d/exe %d",
  6095                      os::current_process_id(), os::current_process_id());
  6096                  os::current_process_id(), os::current_process_id());
  6096 
  6097 
  6097     os::fork_and_exec(buf);
  6098     os::fork_and_exec(buf);
  6098     yes = false;
  6099     yes = false;
  6099   }
  6100   }
  6100   return yes;
  6101   return yes;