diff options
-rw-r--r-- | app/x11_util.cc | 47 | ||||
-rw-r--r-- | chrome/gpu/gpu_main.cc | 25 |
2 files changed, 62 insertions, 10 deletions
diff --git a/app/x11_util.cc b/app/x11_util.cc index e86c3ab..4c48187 100644 --- a/app/x11_util.cc +++ b/app/x11_util.cc @@ -21,6 +21,7 @@ #include "base/command_line.h" #include "base/logging.h" #include "base/stringprintf.h" +#include "base/string_number_conversions.h" #include "base/thread.h" #include "app/x11_util_internal.h" #include "gfx/rect.h" @@ -834,17 +835,43 @@ void SetX11ErrorHandlers(XErrorHandler error_handler, io_error_handler ? io_error_handler : DefaultX11IOErrorHandler); } -std::string GetErrorEventDescription(Display* dpy, XErrorEvent* error_event) { - char buf[255]; - XGetErrorText(dpy, error_event->error_code, buf, 254); +std::string GetErrorEventDescription(Display *dpy, + XErrorEvent *error_event) { + char error_str[256]; + char request_str[256]; + + XGetErrorText(dpy, error_event->error_code, error_str, sizeof(error_str)); + + strncpy(request_str, "Unknown", sizeof(request_str)); + if (error_event->request_code < 128) { + std::string num = base::UintToString(error_event->request_code); + XGetErrorDatabaseText( + dpy, "XRequest", num.c_str(), "Unknown", request_str, + sizeof(request_str)); + } else { + int num_ext; + char **ext_list = XListExtensions(dpy, &num_ext); + + for (int i = 0; i < num_ext; i++) { + int ext_code, first_event, first_error; + XQueryExtension(dpy, ext_list[i], &ext_code, &first_event, &first_error); + if (error_event->request_code == ext_code) { + std::string msg = StringPrintf( + "%s.%d", ext_list[i], error_event->minor_code); + XGetErrorDatabaseText( + dpy, "XRequest", msg.c_str(), "Unknown", request_str, + sizeof(request_str)); + break; + } + } + XFreeExtensionList(ext_list); + } + return base::StringPrintf( - "X Error detected: %s " - "(serial: %lu, error_code: %u, request_code: %u, minor_code: %u)", - buf, - error_event->serial, - error_event->error_code, - error_event->request_code, - error_event->minor_code); + "X Error detected: serial %lu, error_code %u (%s), " + "request_code %u minor_code %u (%s)", + error_event->serial, error_event->error_code, error_str, + error_event->request_code, error_event->minor_code, request_str); } // ---------------------------------------------------------------------------- // End of x11_util_internal.h diff --git a/chrome/gpu/gpu_main.cc b/chrome/gpu/gpu_main.cc index 2e248ab..5ffd39f 100644 --- a/chrome/gpu/gpu_main.cc +++ b/chrome/gpu/gpu_main.cc @@ -20,6 +20,27 @@ #include "app/win_util.h" #endif +#if defined(USE_X11) +#include "app/x11_util.h" +#include "app/x11_util_internal.h" +#endif + +#if defined(USE_X11) +namespace { + +int GpuX11ErrorHandler(Display* d, XErrorEvent* error) { + LOG(ERROR) << x11_util::GetErrorEventDescription(d, error); + return 0; +} + +void SetGpuX11ErrorHandlers() { + // Set up the error handlers so that only general errors aren't fatal. + x11_util::SetX11ErrorHandlers(GpuX11ErrorHandler, NULL); +} + +} +#endif + // Main function for starting the Gpu process. int GpuMain(const MainFunctionParams& parameters) { #if defined(USE_LINUX_BREAKPAD) @@ -44,6 +65,10 @@ int GpuMain(const MainFunctionParams& parameters) { GpuProcess gpu_process; gpu_process.set_main_thread(new GpuThread()); +#if defined(USE_X11) + SetGpuX11ErrorHandlers(); +#endif + main_message_loop.Run(); return 0; |