[Lldb-commits] [PATCH] D16508: NetBSD: Define initial RegisterContextNetBSD_x86_64
Kamil Rytarowski via lldb-commits
lldb-commits at lists.llvm.org
Wed Jan 27 20:18:54 PST 2016
krytarowski added a comment.
1. I was trying to comment out `DBG` registers (as unsupported by NetBSD) from `RegisterInfos_x86_64.h` with the following patch:
diff --git a/lldb-git/patches/patch-lldb_source_Plugins_Process_Utility_RegisterInfos__x86__64.h b/lldb-git/patches/patch-lldb_source_Plugins_Process_Utility_RegisterInfos__x86__64.h
new file mode 100644
index 0000000..280330e
--- /dev/null
+++ b/lldb-git/patches/patch-lldb_source_Plugins_Process_Utility_RegisterInfos__x86__64.h
@@ -0,0 +1,74 @@
+$NetBSD$
+
+--- lldb/source/Plugins/Process/Utility/RegisterInfos_x86_64.h.orig 2015-12-06 02:57:30.000000000 +0000
++++ lldb/source/Plugins/Process/Utility/RegisterInfos_x86_64.h
+@@ -48,7 +48,9 @@
+ // Number of bytes needed to represent a YMM register.
+ #define YMM_SIZE sizeof(YMMReg)
+
++#ifndef NO_DEBUGREGS
+ #define DR_SIZE sizeof(((DBG*)NULL)->dr[0])
++#endif
+
+ // RegisterKind: EHFrame, DWARF, Generic, Process Plugin, LLDB
+
+@@ -85,10 +87,12 @@
+ { dwarf_##reg##i##h_x86_64, dwarf_##reg##i##h_x86_64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, lldb_##reg##i##_x86_64 }, \
+ NULL, NULL }
+
++#ifndef NO_DEBUGREGS
+ #define DEFINE_DR(reg, i) \
+ { #reg#i, NULL, DR_SIZE, DR_OFFSET(i), eEncodingUint, eFormatHex, \
+ { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, \
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM }, NULL, NULL }
++#endif
+
+ #define DEFINE_GPR_PSEUDO_32(reg32, reg64) \
+ { #reg32, NULL, 4, GPR_OFFSET(reg64), eEncodingUint, \
+@@ -251,6 +255,7 @@ g_register_infos_x86_64[] =
+ DEFINE_YMM(ymm, 14),
+ DEFINE_YMM(ymm, 15),
+
++#ifndef NO_DEBUGREGS
+ // Debug registers for lldb internal use
+ DEFINE_DR(dr, 0),
+ DEFINE_DR(dr, 1),
+@@ -259,7 +264,8 @@ g_register_infos_x86_64[] =
+ DEFINE_DR(dr, 4),
+ DEFINE_DR(dr, 5),
+ DEFINE_DR(dr, 6),
+- DEFINE_DR(dr, 7)
++ DEFINE_DR(dr, 7),
++#endif
+ };
+
+ static_assert((sizeof(g_register_infos_x86_64) / sizeof(g_register_infos_x86_64[0])) == k_num_registers_x86_64,
+@@ -314,10 +320,12 @@ do {
+ g_register_infos[lldb_##reg##i##_i386].byte_offset = YMM_OFFSET(i); \
+ } while(false);
+
++#ifndef NO_DEBUGREGS
+ #define UPDATE_DR_INFO(reg_index) \
+ do { \
+ g_register_infos[lldb_dr##reg_index##_i386].byte_offset = DR_OFFSET(reg_index); \
+ } while(false);
++#endif
+
+ // Update the register offsets
+ UPDATE_GPR_INFO(eax, rax);
+@@ -400,6 +408,7 @@ do {
+ UPDATE_YMM_INFO(ymm, 6);
+ UPDATE_YMM_INFO(ymm, 7);
+
++#ifndef NO_DEBUGREGS
+ UPDATE_DR_INFO(0);
+ UPDATE_DR_INFO(1);
+ UPDATE_DR_INFO(2);
+@@ -408,6 +417,7 @@ do {
+ UPDATE_DR_INFO(5);
+ UPDATE_DR_INFO(6);
+ UPDATE_DR_INFO(7);
++#endif
+
+ #undef UPDATE_GPR_INFO
+ #undef UPDATE_GPR_INFO_8H
But I get this assert being triggered:
In file included from /tmp/pkgsrc-tmp/wip/lldb-git/work/lldb/source/Plugins/Process/Utility/RegisterContextNetBSD_x86_64.cpp:59:0:
/tmp/pkgsrc-tmp/wip/lldb-git/work/lldb/source/Plugins/Process/Utility/RegisterInfos_x86_64.h:271:1: error: static assertion failed: g_register_infos_x86_64 has wrong number of register infos
static_assert((sizeof(g_register_infos_x86_64) / sizeof(g_register_infos_x86_64[0])) == k_num_registers_x86_64,
^
What's the correct approach to address it? Mirror modified `RegisterInfos_x86_64.h` in `RegisterContextNetBSD_x86_64.cpp` and removed/altered `static_assert`?
2. I don't understand "marking registers as valid". NetBSD offers `ptrace`(2) call to with a pair of accessors set or get, one for `REG` and the other for `FPREG`.
Thank you in advance.
Repository:
rL LLVM
http://reviews.llvm.org/D16508
More information about the lldb-commits
mailing list