summaryrefslogtreecommitdiff
path: root/src/gallium/drivers/llvmpipe/lp_bld_debug.c
diff options
context:
space:
mode:
authorJosé Fonseca <jfonseca@vmware.com>2009-08-16 11:50:17 +0100
committerJosé Fonseca <jfonseca@vmware.com>2009-08-29 09:21:32 +0100
commit818d444e12bb57568fbf3bf5f06ee24c6c73a61a (patch)
tree4abd55212b63a898e8e5d56d77f0a9959ce2ff84 /src/gallium/drivers/llvmpipe/lp_bld_debug.c
parenta7f9b915aeade96d8ca58d70a1f1d42cd6a16e3d (diff)
llvmpipe: Disassemble generated x86 code.
Diffstat (limited to 'src/gallium/drivers/llvmpipe/lp_bld_debug.c')
-rw-r--r--src/gallium/drivers/llvmpipe/lp_bld_debug.c70
1 files changed, 70 insertions, 0 deletions
diff --git a/src/gallium/drivers/llvmpipe/lp_bld_debug.c b/src/gallium/drivers/llvmpipe/lp_bld_debug.c
new file mode 100644
index 0000000000..49a6065a8c
--- /dev/null
+++ b/src/gallium/drivers/llvmpipe/lp_bld_debug.c
@@ -0,0 +1,70 @@
+/**************************************************************************
+ *
+ * Copyright 2009 VMware, Inc.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ **************************************************************************/
+
+
+#include <udis86.h>
+
+#include "util/u_debug.h"
+#include "lp_bld_debug.h"
+
+
+void
+lp_disassemble(const void* func)
+{
+ ud_t ud_obj;
+
+ ud_init(&ud_obj);
+
+ ud_set_input_buffer(&ud_obj, (void*)func, 0xffff);
+ ud_set_pc(&ud_obj, (uint64_t) (uintptr_t) func);
+
+#ifdef PIPE_ARCH_X86
+ ud_set_mode(&ud_obj, 32);
+#endif
+#ifdef PIPE_ARCH_X86_64
+ ud_set_mode(&ud_obj, 64);
+#endif
+
+ ud_set_syntax(&ud_obj, UD_SYN_ATT);
+
+ while (ud_disassemble(&ud_obj)) {
+#ifdef PIPE_ARCH_X86
+ debug_printf("%08lx:\t%s\n",
+ (unsigned long)ud_insn_off(&ud_obj),
+ ud_insn_asm(&ud_obj));
+#endif
+#ifdef PIPE_ARCH_X86_64
+ debug_printf("%016llx:\t%s\n",
+ (unsigned long long)ud_insn_off(&ud_obj),
+ ud_insn_asm(&ud_obj));
+#endif
+
+ if (ud_obj.mnemonic == UD_Iret)
+ break;
+ }
+ debug_printf("\n");
+}