summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Byer <bbyer@bbyer.local>2007-11-15 02:25:50 -0800
committerJeremy Huddleston <jeremy@tifa.local>2007-11-21 23:18:46 -0800
commit8486f8af91b477c7bcb8438a0e9a72d0c11d1d63 (patch)
treeb34ed0b15d27c73f2f3ba650fb12dec3c4fa92a0
parent74214a9f42b931f99d83ddb4efb3720881a2de16 (diff)
Darwin: Added a lightweight debugging facility to support troubleshooting
(for example) the stuck modifier key issue (cherry picked from commit 0e0b452d10c0af55497c3299b5f3db45d5b381cb)
-rw-r--r--hw/darwin/darwin.c18
-rw-r--r--hw/darwin/darwin.h10
2 files changed, 28 insertions, 0 deletions
diff --git a/hw/darwin/darwin.c b/hw/darwin/darwin.c
index a4ec002e8..a772218fe 100644
--- a/hw/darwin/darwin.c
+++ b/hw/darwin/darwin.c
@@ -75,6 +75,10 @@
#include "darwin.h"
#include "darwinClut8.h"
+#ifdef ENABLE_DEBUG_LOG
+FILE *debug_log_fp = NULL;
+#endif
+
/*
* X server shared global variables
*/
@@ -652,6 +656,20 @@ void OsVendorInit(void)
{
if (serverGeneration == 1) {
DarwinPrintBanner();
+#ifdef ENABLE_DEBUG_LOG
+ {
+ char *home_dir=NULL, *log_file_path=NULL;
+ home_dir = getenv("HOME");
+ if (home_dir) asprintf(&log_file_path, "%s/%s", home_dir, DEBUG_LOG_NAME);
+ if (log_file_path) {
+ if (!access(log_file_path, F_OK)) {
+ debug_log_fp = fopen(log_file_path, "a");
+ if (debug_log_fp) ErrorF("Debug logging enabled to %s\n", log_file_path);
+ }
+ free(log_file_path);
+ }
+ }
+#endif
}
// Find the full path to the keymapping file.
diff --git a/hw/darwin/darwin.h b/hw/darwin/darwin.h
index 587ba1cc6..646bb2488 100644
--- a/hw/darwin/darwin.h
+++ b/hw/darwin/darwin.h
@@ -157,4 +157,14 @@ enum {
kXDarwinWindowMoved // window has moved on screen
};
+#define ENABLE_DEBUG_LOG 1
+
+#ifdef ENABLE_DEBUG_LOG
+extern FILE *debug_log_fp;
+#define DEBUG_LOG_NAME "x11-debug.txt"
+#define DEBUG_LOG(msg, args...) if (debug_log_fp) fprintf(debug_log_fp, "%s:%d: " msg, __FUNCTION__, __LINE__, ##args )
+#else
+#define DEBUG_LOG(msg, args...)
+#endif
+
#endif /* _DARWIN_H */