[Lldb-commits] [lldb] r280751 - *** This commit represents a complete reformatting of the LLDB source code
Kate Stone via lldb-commits
lldb-commits at lists.llvm.org
Tue Sep 6 13:58:36 PDT 2016
Modified: lldb/trunk/source/Plugins/Process/Utility/RegisterInfos_mips.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Utility/RegisterInfos_mips.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/Utility/RegisterInfos_mips.h (original)
+++ lldb/trunk/source/Plugins/Process/Utility/RegisterInfos_mips.h Tue Sep 6 15:57:50 2016
@@ -12,175 +12,309 @@
// C++ Includes
// Other libraries and framework includes
-#include "llvm/Support/Compiler.h"
#include "lldb/Core/dwarf.h"
+#include "llvm/Support/Compiler.h"
// Project includes
#ifdef DECLARE_REGISTER_INFOS_MIPS_STRUCT
// Computes the offset of the given GPR in the user data area.
-#define GPR_OFFSET(regname) \
- (LLVM_EXTENSION offsetof(UserArea, gpr) + \
- LLVM_EXTENSION offsetof(GPR_linux_mips, regname))
+#define GPR_OFFSET(regname) \
+ (LLVM_EXTENSION offsetof(UserArea, gpr) + \
+ LLVM_EXTENSION offsetof(GPR_linux_mips, regname))
// Computes the offset of the given FPR in the extended data area.
-#define FPR_OFFSET(regname) \
- (LLVM_EXTENSION offsetof(UserArea, fpr) + \
- LLVM_EXTENSION offsetof(FPR_linux_mips, regname))
+#define FPR_OFFSET(regname) \
+ (LLVM_EXTENSION offsetof(UserArea, fpr) + \
+ LLVM_EXTENSION offsetof(FPR_linux_mips, regname))
// Computes the offset of the given MSA in the extended data area.
-#define MSA_OFFSET(regname) \
- (LLVM_EXTENSION offsetof(UserArea, msa) + \
- LLVM_EXTENSION offsetof(MSA_linux_mips, regname))
+#define MSA_OFFSET(regname) \
+ (LLVM_EXTENSION offsetof(UserArea, msa) + \
+ LLVM_EXTENSION offsetof(MSA_linux_mips, regname))
// Note that the size and offset will be updated by platform-specific classes.
-#define DEFINE_GPR(reg, alt, kind1, kind2, kind3, kind4) \
- { #reg, alt, sizeof(((GPR_linux_mips*)NULL)->reg) / 2, GPR_OFFSET(reg), eEncodingUint, \
- eFormatHex, { kind1, kind2, kind3, kind4, gpr_##reg##_mips }, NULL, NULL, NULL, 0}
-
-const uint8_t dwarf_opcode_mips [] = {
- llvm::dwarf::DW_OP_regx, dwarf_sr_mips, llvm::dwarf::DW_OP_lit1,
- llvm::dwarf::DW_OP_lit26, llvm::dwarf::DW_OP_shl, llvm::dwarf::DW_OP_and,
- llvm::dwarf::DW_OP_lit26, llvm::dwarf::DW_OP_shr
- };
-
-#define DEFINE_FPR(reg, alt, kind1, kind2, kind3, kind4) \
- { #reg, alt, sizeof(((FPR_linux_mips*)NULL)->reg), FPR_OFFSET(reg), eEncodingIEEE754, \
- eFormatFloat, { kind1, kind2, kind3, kind4, fpr_##reg##_mips }, NULL, NULL, dwarf_opcode_mips, sizeof(dwarf_opcode_mips)}
-
-#define DEFINE_FPR_INFO(reg, alt, kind1, kind2, kind3, kind4) \
- { #reg, alt, sizeof(((FPR_linux_mips*)NULL)->reg), FPR_OFFSET(reg), eEncodingUint, \
- eFormatHex, { kind1, kind2, kind3, kind4, fpr_##reg##_mips }, NULL, NULL, NULL, 0}
-
-#define DEFINE_MSA(reg, alt, kind1, kind2, kind3, kind4) \
- { #reg, alt, sizeof(((MSA_linux_mips*)0)->reg), MSA_OFFSET(reg), eEncodingVector, \
- eFormatVectorOfUInt8, { kind1, kind2, kind3, kind4, msa_##reg##_mips }, NULL, NULL, NULL, 0}
-
-#define DEFINE_MSA_INFO(reg, alt, kind1, kind2, kind3, kind4) \
- { #reg, alt, sizeof(((MSA_linux_mips*)0)->reg), MSA_OFFSET(reg), eEncodingUint, \
- eFormatHex, { kind1, kind2, kind3, kind4, msa_##reg##_mips }, NULL, NULL, NULL, 0}
+#define DEFINE_GPR(reg, alt, kind1, kind2, kind3, kind4) \
+ { \
+ #reg, alt, sizeof(((GPR_linux_mips *) NULL)->reg) / 2, \
+ GPR_OFFSET(reg), eEncodingUint, eFormatHex, \
+ {kind1, kind2, kind3, kind4, \
+ gpr_##reg##_mips }, \
+ NULL, NULL, NULL, 0 \
+ }
+
+const uint8_t dwarf_opcode_mips[] = {
+ llvm::dwarf::DW_OP_regx, dwarf_sr_mips, llvm::dwarf::DW_OP_lit1,
+ llvm::dwarf::DW_OP_lit26, llvm::dwarf::DW_OP_shl, llvm::dwarf::DW_OP_and,
+ llvm::dwarf::DW_OP_lit26, llvm::dwarf::DW_OP_shr};
+
+#define DEFINE_FPR(reg, alt, kind1, kind2, kind3, kind4) \
+ { \
+ #reg, alt, sizeof(((FPR_linux_mips *) NULL)->reg), \
+ FPR_OFFSET(reg), eEncodingIEEE754, eFormatFloat, \
+ {kind1, kind2, kind3, kind4, \
+ fpr_##reg##_mips }, \
+ NULL, NULL, dwarf_opcode_mips, \
+ sizeof(dwarf_opcode_mips) \
+ }
+
+#define DEFINE_FPR_INFO(reg, alt, kind1, kind2, kind3, kind4) \
+ { \
+ #reg, alt, sizeof(((FPR_linux_mips *) NULL)->reg), \
+ FPR_OFFSET(reg), eEncodingUint, eFormatHex, \
+ {kind1, kind2, kind3, kind4, \
+ fpr_##reg##_mips }, \
+ NULL, NULL, NULL, 0 \
+ }
+
+#define DEFINE_MSA(reg, alt, kind1, kind2, kind3, kind4) \
+ { \
+ #reg, alt, sizeof(((MSA_linux_mips *) 0)->reg), \
+ MSA_OFFSET(reg), eEncodingVector, eFormatVectorOfUInt8, \
+ {kind1, kind2, kind3, kind4, \
+ msa_##reg##_mips }, \
+ NULL, NULL, NULL, 0 \
+ }
+
+#define DEFINE_MSA_INFO(reg, alt, kind1, kind2, kind3, kind4) \
+ { \
+ #reg, alt, sizeof(((MSA_linux_mips *) 0)->reg), \
+ MSA_OFFSET(reg), eEncodingUint, eFormatHex, \
+ {kind1, kind2, kind3, kind4, \
+ msa_##reg##_mips }, \
+ NULL, NULL, NULL, 0 \
+ }
// RegisterKind: EH_Frame, DWARF, Generic, Procss Plugin, LLDB
-static RegisterInfo
-g_register_infos_mips[] =
-{
- DEFINE_GPR (zero, "zero", dwarf_zero_mips, dwarf_zero_mips, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_GPR (r1, "at", dwarf_r1_mips, dwarf_r1_mips, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_GPR (r2, nullptr, dwarf_r2_mips, dwarf_r2_mips, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_GPR (r3, nullptr, dwarf_r3_mips, dwarf_r3_mips, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_GPR (r4, nullptr, dwarf_r4_mips, dwarf_r4_mips, LLDB_REGNUM_GENERIC_ARG1, LLDB_INVALID_REGNUM),
- DEFINE_GPR (r5, nullptr, dwarf_r5_mips, dwarf_r5_mips, LLDB_REGNUM_GENERIC_ARG2, LLDB_INVALID_REGNUM),
- DEFINE_GPR (r6, nullptr, dwarf_r6_mips, dwarf_r6_mips, LLDB_REGNUM_GENERIC_ARG3, LLDB_INVALID_REGNUM),
- DEFINE_GPR (r7, nullptr, dwarf_r7_mips, dwarf_r7_mips, LLDB_REGNUM_GENERIC_ARG4, LLDB_INVALID_REGNUM),
- DEFINE_GPR (r8, nullptr, dwarf_r8_mips, dwarf_r8_mips, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_GPR (r9, nullptr, dwarf_r9_mips, dwarf_r9_mips, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_GPR (r10, nullptr, dwarf_r10_mips, dwarf_r10_mips, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_GPR (r11, nullptr, dwarf_r11_mips, dwarf_r11_mips, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_GPR (r12, nullptr, dwarf_r12_mips, dwarf_r12_mips, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_GPR (r13, nullptr, dwarf_r13_mips, dwarf_r13_mips, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_GPR (r14, nullptr, dwarf_r14_mips, dwarf_r14_mips, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_GPR (r15, nullptr, dwarf_r15_mips, dwarf_r15_mips, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_GPR (r16, nullptr, dwarf_r16_mips, dwarf_r16_mips, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_GPR (r17, nullptr, dwarf_r17_mips, dwarf_r17_mips, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_GPR (r18, nullptr, dwarf_r18_mips, dwarf_r18_mips, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_GPR (r19, nullptr, dwarf_r19_mips, dwarf_r19_mips, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_GPR (r20, nullptr, dwarf_r20_mips, dwarf_r20_mips, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_GPR (r21, nullptr, dwarf_r21_mips, dwarf_r21_mips, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_GPR (r22, nullptr, dwarf_r22_mips, dwarf_r22_mips, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_GPR (r23, nullptr, dwarf_r23_mips, dwarf_r23_mips, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_GPR (r24, nullptr, dwarf_r24_mips, dwarf_r24_mips, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_GPR (r25, nullptr, dwarf_r25_mips, dwarf_r25_mips, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_GPR (r26, nullptr, dwarf_r26_mips, dwarf_r26_mips, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_GPR (r27, nullptr, dwarf_r27_mips, dwarf_r27_mips, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_GPR (gp, "gp", dwarf_gp_mips, dwarf_gp_mips, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_GPR (sp, "sp", dwarf_sp_mips, dwarf_sp_mips, LLDB_REGNUM_GENERIC_SP, LLDB_INVALID_REGNUM),
- DEFINE_GPR (r30, "fp", dwarf_r30_mips, dwarf_r30_mips, LLDB_REGNUM_GENERIC_FP, LLDB_INVALID_REGNUM),
- DEFINE_GPR (ra, "ra", dwarf_ra_mips, dwarf_ra_mips, LLDB_REGNUM_GENERIC_RA, LLDB_INVALID_REGNUM),
- DEFINE_GPR (sr, "status", dwarf_sr_mips, dwarf_sr_mips, LLDB_REGNUM_GENERIC_FLAGS, LLDB_INVALID_REGNUM),
- DEFINE_GPR (mullo, nullptr, dwarf_lo_mips, dwarf_lo_mips, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_GPR (mulhi, nullptr, dwarf_hi_mips, dwarf_hi_mips, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_GPR (badvaddr, nullptr, dwarf_bad_mips, dwarf_bad_mips, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_GPR (cause, nullptr, dwarf_cause_mips, dwarf_cause_mips, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_GPR (pc, nullptr, dwarf_pc_mips, dwarf_pc_mips, LLDB_REGNUM_GENERIC_PC, LLDB_INVALID_REGNUM),
- DEFINE_GPR (config5, nullptr, dwarf_config5_mips, dwarf_config5_mips, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_FPR (f0, nullptr, dwarf_f0_mips, dwarf_f0_mips, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_FPR (f1, nullptr, dwarf_f1_mips, dwarf_f1_mips, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_FPR (f2, nullptr, dwarf_f2_mips, dwarf_f2_mips, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_FPR (f3, nullptr, dwarf_f3_mips, dwarf_f3_mips, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_FPR (f4, nullptr, dwarf_f4_mips, dwarf_f4_mips, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_FPR (f5, nullptr, dwarf_f5_mips, dwarf_f5_mips, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_FPR (f6, nullptr, dwarf_f6_mips, dwarf_f6_mips, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_FPR (f7, nullptr, dwarf_f7_mips, dwarf_f7_mips, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_FPR (f8, nullptr, dwarf_f8_mips, dwarf_f8_mips, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_FPR (f9, nullptr, dwarf_f9_mips, dwarf_f9_mips, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_FPR (f10, nullptr, dwarf_f10_mips, dwarf_f10_mips, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_FPR (f11, nullptr, dwarf_f11_mips, dwarf_f11_mips, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_FPR (f12, nullptr, dwarf_f12_mips, dwarf_f12_mips, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_FPR (f13, nullptr, dwarf_f13_mips, dwarf_f13_mips, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_FPR (f14, nullptr, dwarf_f14_mips, dwarf_f14_mips, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_FPR (f15, nullptr, dwarf_f15_mips, dwarf_f15_mips, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_FPR (f16, nullptr, dwarf_f16_mips, dwarf_f16_mips, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_FPR (f17, nullptr, dwarf_f17_mips, dwarf_f17_mips, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_FPR (f18, nullptr, dwarf_f18_mips, dwarf_f18_mips, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_FPR (f19, nullptr, dwarf_f19_mips, dwarf_f19_mips, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_FPR (f20, nullptr, dwarf_f20_mips, dwarf_f20_mips, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_FPR (f21, nullptr, dwarf_f21_mips, dwarf_f21_mips, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_FPR (f22, nullptr, dwarf_f22_mips, dwarf_f22_mips, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_FPR (f23, nullptr, dwarf_f23_mips, dwarf_f23_mips, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_FPR (f24, nullptr, dwarf_f24_mips, dwarf_f24_mips, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_FPR (f25, nullptr, dwarf_f25_mips, dwarf_f25_mips, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_FPR (f26, nullptr, dwarf_f26_mips, dwarf_f26_mips, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_FPR (f27, nullptr, dwarf_f27_mips, dwarf_f27_mips, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_FPR (f28, nullptr, dwarf_f28_mips, dwarf_f28_mips, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_FPR (f29, nullptr, dwarf_f29_mips, dwarf_f29_mips, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_FPR (f30, nullptr, dwarf_f30_mips, dwarf_f30_mips, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_FPR (f31, nullptr, dwarf_f31_mips, dwarf_f31_mips, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_FPR_INFO (fcsr, nullptr, dwarf_fcsr_mips, dwarf_fcsr_mips, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_FPR_INFO (fir, nullptr, dwarf_fir_mips, dwarf_fir_mips, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_FPR_INFO (config5, nullptr, dwarf_config5_mips, dwarf_config5_mips, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_MSA (w0, nullptr, dwarf_w0_mips, dwarf_w0_mips, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_MSA (w1, nullptr, dwarf_w1_mips, dwarf_w1_mips, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_MSA (w2, nullptr, dwarf_w2_mips, dwarf_w2_mips, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_MSA (w3, nullptr, dwarf_w3_mips, dwarf_w3_mips, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_MSA (w4, nullptr, dwarf_w4_mips, dwarf_w4_mips, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_MSA (w5, nullptr, dwarf_w5_mips, dwarf_w5_mips, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_MSA (w6, nullptr, dwarf_w6_mips, dwarf_w6_mips, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_MSA (w7, nullptr, dwarf_w7_mips, dwarf_w7_mips, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_MSA (w8, nullptr, dwarf_w8_mips, dwarf_w8_mips, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_MSA (w9, nullptr, dwarf_w9_mips, dwarf_w9_mips, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_MSA (w10, nullptr, dwarf_w10_mips, dwarf_w10_mips, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_MSA (w11, nullptr, dwarf_w11_mips, dwarf_w11_mips, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_MSA (w12, nullptr, dwarf_w12_mips, dwarf_w12_mips, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_MSA (w13, nullptr, dwarf_w13_mips, dwarf_w13_mips, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_MSA (w14, nullptr, dwarf_w14_mips, dwarf_w14_mips, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_MSA (w15, nullptr, dwarf_w15_mips, dwarf_w15_mips, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_MSA (w16, nullptr, dwarf_w16_mips, dwarf_w16_mips, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_MSA (w17, nullptr, dwarf_w17_mips, dwarf_w17_mips, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_MSA (w18, nullptr, dwarf_w18_mips, dwarf_w18_mips, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_MSA (w19, nullptr, dwarf_w19_mips, dwarf_w19_mips, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_MSA (w20, nullptr, dwarf_w10_mips, dwarf_w20_mips, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_MSA (w21, nullptr, dwarf_w21_mips, dwarf_w21_mips, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_MSA (w22, nullptr, dwarf_w22_mips, dwarf_w22_mips, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_MSA (w23, nullptr, dwarf_w23_mips, dwarf_w23_mips, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_MSA (w24, nullptr, dwarf_w24_mips, dwarf_w24_mips, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_MSA (w25, nullptr, dwarf_w25_mips, dwarf_w25_mips, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_MSA (w26, nullptr, dwarf_w26_mips, dwarf_w26_mips, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_MSA (w27, nullptr, dwarf_w27_mips, dwarf_w27_mips, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_MSA (w28, nullptr, dwarf_w28_mips, dwarf_w28_mips, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_MSA (w29, nullptr, dwarf_w29_mips, dwarf_w29_mips, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_MSA (w30, nullptr, dwarf_w30_mips, dwarf_w30_mips, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_MSA (w31, nullptr, dwarf_w31_mips, dwarf_w31_mips, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_MSA_INFO (mcsr, nullptr, dwarf_mcsr_mips, dwarf_mcsr_mips, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_MSA_INFO (mir, nullptr, dwarf_mir_mips, dwarf_mir_mips, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_MSA_INFO (fcsr, nullptr, dwarf_fcsr_mips, dwarf_fcsr_mips, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_MSA_INFO (fir, nullptr, dwarf_fir_mips, dwarf_fir_mips, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_MSA_INFO (config5, nullptr, dwarf_config5_mips, dwarf_config5_mips, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM)
-};
-
-static_assert((sizeof(g_register_infos_mips) / sizeof(g_register_infos_mips[0])) == k_num_registers_mips,
- "g_register_infos_mips has wrong number of register infos");
+static RegisterInfo g_register_infos_mips[] = {
+ DEFINE_GPR(zero, "zero", dwarf_zero_mips, dwarf_zero_mips,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(r1, "at", dwarf_r1_mips, dwarf_r1_mips, LLDB_INVALID_REGNUM,
+ LLDB_INVALID_REGNUM),
+ DEFINE_GPR(r2, nullptr, dwarf_r2_mips, dwarf_r2_mips, LLDB_INVALID_REGNUM,
+ LLDB_INVALID_REGNUM),
+ DEFINE_GPR(r3, nullptr, dwarf_r3_mips, dwarf_r3_mips, LLDB_INVALID_REGNUM,
+ LLDB_INVALID_REGNUM),
+ DEFINE_GPR(r4, nullptr, dwarf_r4_mips, dwarf_r4_mips,
+ LLDB_REGNUM_GENERIC_ARG1, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(r5, nullptr, dwarf_r5_mips, dwarf_r5_mips,
+ LLDB_REGNUM_GENERIC_ARG2, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(r6, nullptr, dwarf_r6_mips, dwarf_r6_mips,
+ LLDB_REGNUM_GENERIC_ARG3, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(r7, nullptr, dwarf_r7_mips, dwarf_r7_mips,
+ LLDB_REGNUM_GENERIC_ARG4, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(r8, nullptr, dwarf_r8_mips, dwarf_r8_mips, LLDB_INVALID_REGNUM,
+ LLDB_INVALID_REGNUM),
+ DEFINE_GPR(r9, nullptr, dwarf_r9_mips, dwarf_r9_mips, LLDB_INVALID_REGNUM,
+ LLDB_INVALID_REGNUM),
+ DEFINE_GPR(r10, nullptr, dwarf_r10_mips, dwarf_r10_mips,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(r11, nullptr, dwarf_r11_mips, dwarf_r11_mips,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(r12, nullptr, dwarf_r12_mips, dwarf_r12_mips,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(r13, nullptr, dwarf_r13_mips, dwarf_r13_mips,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(r14, nullptr, dwarf_r14_mips, dwarf_r14_mips,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(r15, nullptr, dwarf_r15_mips, dwarf_r15_mips,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(r16, nullptr, dwarf_r16_mips, dwarf_r16_mips,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(r17, nullptr, dwarf_r17_mips, dwarf_r17_mips,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(r18, nullptr, dwarf_r18_mips, dwarf_r18_mips,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(r19, nullptr, dwarf_r19_mips, dwarf_r19_mips,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(r20, nullptr, dwarf_r20_mips, dwarf_r20_mips,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(r21, nullptr, dwarf_r21_mips, dwarf_r21_mips,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(r22, nullptr, dwarf_r22_mips, dwarf_r22_mips,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(r23, nullptr, dwarf_r23_mips, dwarf_r23_mips,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(r24, nullptr, dwarf_r24_mips, dwarf_r24_mips,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(r25, nullptr, dwarf_r25_mips, dwarf_r25_mips,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(r26, nullptr, dwarf_r26_mips, dwarf_r26_mips,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(r27, nullptr, dwarf_r27_mips, dwarf_r27_mips,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(gp, "gp", dwarf_gp_mips, dwarf_gp_mips, LLDB_INVALID_REGNUM,
+ LLDB_INVALID_REGNUM),
+ DEFINE_GPR(sp, "sp", dwarf_sp_mips, dwarf_sp_mips, LLDB_REGNUM_GENERIC_SP,
+ LLDB_INVALID_REGNUM),
+ DEFINE_GPR(r30, "fp", dwarf_r30_mips, dwarf_r30_mips,
+ LLDB_REGNUM_GENERIC_FP, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(ra, "ra", dwarf_ra_mips, dwarf_ra_mips, LLDB_REGNUM_GENERIC_RA,
+ LLDB_INVALID_REGNUM),
+ DEFINE_GPR(sr, "status", dwarf_sr_mips, dwarf_sr_mips,
+ LLDB_REGNUM_GENERIC_FLAGS, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(mullo, nullptr, dwarf_lo_mips, dwarf_lo_mips,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(mulhi, nullptr, dwarf_hi_mips, dwarf_hi_mips,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(badvaddr, nullptr, dwarf_bad_mips, dwarf_bad_mips,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(cause, nullptr, dwarf_cause_mips, dwarf_cause_mips,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(pc, nullptr, dwarf_pc_mips, dwarf_pc_mips,
+ LLDB_REGNUM_GENERIC_PC, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(config5, nullptr, dwarf_config5_mips, dwarf_config5_mips,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_FPR(f0, nullptr, dwarf_f0_mips, dwarf_f0_mips, LLDB_INVALID_REGNUM,
+ LLDB_INVALID_REGNUM),
+ DEFINE_FPR(f1, nullptr, dwarf_f1_mips, dwarf_f1_mips, LLDB_INVALID_REGNUM,
+ LLDB_INVALID_REGNUM),
+ DEFINE_FPR(f2, nullptr, dwarf_f2_mips, dwarf_f2_mips, LLDB_INVALID_REGNUM,
+ LLDB_INVALID_REGNUM),
+ DEFINE_FPR(f3, nullptr, dwarf_f3_mips, dwarf_f3_mips, LLDB_INVALID_REGNUM,
+ LLDB_INVALID_REGNUM),
+ DEFINE_FPR(f4, nullptr, dwarf_f4_mips, dwarf_f4_mips, LLDB_INVALID_REGNUM,
+ LLDB_INVALID_REGNUM),
+ DEFINE_FPR(f5, nullptr, dwarf_f5_mips, dwarf_f5_mips, LLDB_INVALID_REGNUM,
+ LLDB_INVALID_REGNUM),
+ DEFINE_FPR(f6, nullptr, dwarf_f6_mips, dwarf_f6_mips, LLDB_INVALID_REGNUM,
+ LLDB_INVALID_REGNUM),
+ DEFINE_FPR(f7, nullptr, dwarf_f7_mips, dwarf_f7_mips, LLDB_INVALID_REGNUM,
+ LLDB_INVALID_REGNUM),
+ DEFINE_FPR(f8, nullptr, dwarf_f8_mips, dwarf_f8_mips, LLDB_INVALID_REGNUM,
+ LLDB_INVALID_REGNUM),
+ DEFINE_FPR(f9, nullptr, dwarf_f9_mips, dwarf_f9_mips, LLDB_INVALID_REGNUM,
+ LLDB_INVALID_REGNUM),
+ DEFINE_FPR(f10, nullptr, dwarf_f10_mips, dwarf_f10_mips,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_FPR(f11, nullptr, dwarf_f11_mips, dwarf_f11_mips,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_FPR(f12, nullptr, dwarf_f12_mips, dwarf_f12_mips,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_FPR(f13, nullptr, dwarf_f13_mips, dwarf_f13_mips,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_FPR(f14, nullptr, dwarf_f14_mips, dwarf_f14_mips,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_FPR(f15, nullptr, dwarf_f15_mips, dwarf_f15_mips,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_FPR(f16, nullptr, dwarf_f16_mips, dwarf_f16_mips,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_FPR(f17, nullptr, dwarf_f17_mips, dwarf_f17_mips,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_FPR(f18, nullptr, dwarf_f18_mips, dwarf_f18_mips,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_FPR(f19, nullptr, dwarf_f19_mips, dwarf_f19_mips,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_FPR(f20, nullptr, dwarf_f20_mips, dwarf_f20_mips,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_FPR(f21, nullptr, dwarf_f21_mips, dwarf_f21_mips,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_FPR(f22, nullptr, dwarf_f22_mips, dwarf_f22_mips,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_FPR(f23, nullptr, dwarf_f23_mips, dwarf_f23_mips,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_FPR(f24, nullptr, dwarf_f24_mips, dwarf_f24_mips,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_FPR(f25, nullptr, dwarf_f25_mips, dwarf_f25_mips,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_FPR(f26, nullptr, dwarf_f26_mips, dwarf_f26_mips,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_FPR(f27, nullptr, dwarf_f27_mips, dwarf_f27_mips,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_FPR(f28, nullptr, dwarf_f28_mips, dwarf_f28_mips,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_FPR(f29, nullptr, dwarf_f29_mips, dwarf_f29_mips,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_FPR(f30, nullptr, dwarf_f30_mips, dwarf_f30_mips,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_FPR(f31, nullptr, dwarf_f31_mips, dwarf_f31_mips,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_FPR_INFO(fcsr, nullptr, dwarf_fcsr_mips, dwarf_fcsr_mips,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_FPR_INFO(fir, nullptr, dwarf_fir_mips, dwarf_fir_mips,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_FPR_INFO(config5, nullptr, dwarf_config5_mips, dwarf_config5_mips,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_MSA(w0, nullptr, dwarf_w0_mips, dwarf_w0_mips, LLDB_INVALID_REGNUM,
+ LLDB_INVALID_REGNUM),
+ DEFINE_MSA(w1, nullptr, dwarf_w1_mips, dwarf_w1_mips, LLDB_INVALID_REGNUM,
+ LLDB_INVALID_REGNUM),
+ DEFINE_MSA(w2, nullptr, dwarf_w2_mips, dwarf_w2_mips, LLDB_INVALID_REGNUM,
+ LLDB_INVALID_REGNUM),
+ DEFINE_MSA(w3, nullptr, dwarf_w3_mips, dwarf_w3_mips, LLDB_INVALID_REGNUM,
+ LLDB_INVALID_REGNUM),
+ DEFINE_MSA(w4, nullptr, dwarf_w4_mips, dwarf_w4_mips, LLDB_INVALID_REGNUM,
+ LLDB_INVALID_REGNUM),
+ DEFINE_MSA(w5, nullptr, dwarf_w5_mips, dwarf_w5_mips, LLDB_INVALID_REGNUM,
+ LLDB_INVALID_REGNUM),
+ DEFINE_MSA(w6, nullptr, dwarf_w6_mips, dwarf_w6_mips, LLDB_INVALID_REGNUM,
+ LLDB_INVALID_REGNUM),
+ DEFINE_MSA(w7, nullptr, dwarf_w7_mips, dwarf_w7_mips, LLDB_INVALID_REGNUM,
+ LLDB_INVALID_REGNUM),
+ DEFINE_MSA(w8, nullptr, dwarf_w8_mips, dwarf_w8_mips, LLDB_INVALID_REGNUM,
+ LLDB_INVALID_REGNUM),
+ DEFINE_MSA(w9, nullptr, dwarf_w9_mips, dwarf_w9_mips, LLDB_INVALID_REGNUM,
+ LLDB_INVALID_REGNUM),
+ DEFINE_MSA(w10, nullptr, dwarf_w10_mips, dwarf_w10_mips,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_MSA(w11, nullptr, dwarf_w11_mips, dwarf_w11_mips,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_MSA(w12, nullptr, dwarf_w12_mips, dwarf_w12_mips,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_MSA(w13, nullptr, dwarf_w13_mips, dwarf_w13_mips,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_MSA(w14, nullptr, dwarf_w14_mips, dwarf_w14_mips,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_MSA(w15, nullptr, dwarf_w15_mips, dwarf_w15_mips,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_MSA(w16, nullptr, dwarf_w16_mips, dwarf_w16_mips,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_MSA(w17, nullptr, dwarf_w17_mips, dwarf_w17_mips,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_MSA(w18, nullptr, dwarf_w18_mips, dwarf_w18_mips,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_MSA(w19, nullptr, dwarf_w19_mips, dwarf_w19_mips,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_MSA(w20, nullptr, dwarf_w10_mips, dwarf_w20_mips,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_MSA(w21, nullptr, dwarf_w21_mips, dwarf_w21_mips,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_MSA(w22, nullptr, dwarf_w22_mips, dwarf_w22_mips,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_MSA(w23, nullptr, dwarf_w23_mips, dwarf_w23_mips,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_MSA(w24, nullptr, dwarf_w24_mips, dwarf_w24_mips,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_MSA(w25, nullptr, dwarf_w25_mips, dwarf_w25_mips,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_MSA(w26, nullptr, dwarf_w26_mips, dwarf_w26_mips,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_MSA(w27, nullptr, dwarf_w27_mips, dwarf_w27_mips,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_MSA(w28, nullptr, dwarf_w28_mips, dwarf_w28_mips,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_MSA(w29, nullptr, dwarf_w29_mips, dwarf_w29_mips,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_MSA(w30, nullptr, dwarf_w30_mips, dwarf_w30_mips,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_MSA(w31, nullptr, dwarf_w31_mips, dwarf_w31_mips,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_MSA_INFO(mcsr, nullptr, dwarf_mcsr_mips, dwarf_mcsr_mips,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_MSA_INFO(mir, nullptr, dwarf_mir_mips, dwarf_mir_mips,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_MSA_INFO(fcsr, nullptr, dwarf_fcsr_mips, dwarf_fcsr_mips,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_MSA_INFO(fir, nullptr, dwarf_fir_mips, dwarf_fir_mips,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_MSA_INFO(config5, nullptr, dwarf_config5_mips, dwarf_config5_mips,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM)};
+
+static_assert((sizeof(g_register_infos_mips) /
+ sizeof(g_register_infos_mips[0])) == k_num_registers_mips,
+ "g_register_infos_mips has wrong number of register infos");
#undef GPR_OFFSET
#undef FPR_OFFSET
Modified: lldb/trunk/source/Plugins/Process/Utility/RegisterInfos_mips64.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Utility/RegisterInfos_mips64.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/Utility/RegisterInfos_mips64.h (original)
+++ lldb/trunk/source/Plugins/Process/Utility/RegisterInfos_mips64.h Tue Sep 6 15:57:50 2016
@@ -12,8 +12,8 @@
// C++ Includes
// Other libraries and framework includes
-#include "llvm/Support/Compiler.h"
#include "lldb/Core/dwarf.h"
+#include "llvm/Support/Compiler.h"
// Project includes
@@ -21,226 +21,413 @@
// Computes the offset of the given GPR in the user data area.
#ifdef LINUX_MIPS64
- #define GPR_OFFSET(regname) \
- (LLVM_EXTENSION offsetof(UserArea, gpr) + \
- LLVM_EXTENSION offsetof(GPR_linux_mips, regname))
+#define GPR_OFFSET(regname) \
+ (LLVM_EXTENSION offsetof(UserArea, gpr) + \
+ LLVM_EXTENSION offsetof(GPR_linux_mips, regname))
#else
- #define GPR_OFFSET(regname) \
- (LLVM_EXTENSION offsetof(GPR_freebsd_mips, regname))
+#define GPR_OFFSET(regname) (LLVM_EXTENSION offsetof(GPR_freebsd_mips, regname))
#endif
// Computes the offset of the given FPR in the extended data area.
-#define FPR_OFFSET(regname) \
- (LLVM_EXTENSION offsetof(UserArea, fpr) + \
- LLVM_EXTENSION offsetof(FPR_linux_mips, regname))
+#define FPR_OFFSET(regname) \
+ (LLVM_EXTENSION offsetof(UserArea, fpr) + \
+ LLVM_EXTENSION offsetof(FPR_linux_mips, regname))
// Computes the offset of the given MSA in the extended data area.
-#define MSA_OFFSET(regname) \
- (LLVM_EXTENSION offsetof(UserArea, msa) + \
- LLVM_EXTENSION offsetof(MSA_linux_mips, regname))
+#define MSA_OFFSET(regname) \
+ (LLVM_EXTENSION offsetof(UserArea, msa) + \
+ LLVM_EXTENSION offsetof(MSA_linux_mips, regname))
// RegisterKind: EHFrame, DWARF, Generic, Process Plugin, LLDB
// Note that the size and offset will be updated by platform-specific classes.
#ifdef LINUX_MIPS64
- #define DEFINE_GPR(reg, alt, kind1, kind2, kind3, kind4) \
- { #reg, alt, sizeof(((GPR_linux_mips*)0)->reg), GPR_OFFSET(reg), eEncodingUint, \
- eFormatHex, { kind1, kind2, kind3, kind4, gpr_##reg##_mips64 }, NULL, NULL, NULL, 0}
+#define DEFINE_GPR(reg, alt, kind1, kind2, kind3, kind4) \
+ { \
+ #reg, alt, sizeof(((GPR_linux_mips *) 0)->reg), \
+ GPR_OFFSET(reg), eEncodingUint, eFormatHex, \
+ {kind1, kind2, kind3, kind4, \
+ gpr_##reg##_mips64 }, \
+ NULL, NULL, NULL, 0 \
+ }
#else
- #define DEFINE_GPR(reg, alt, kind1, kind2, kind3, kind4) \
- { #reg, alt, sizeof(((GPR_freebsd_mips*)0)->reg), GPR_OFFSET(reg), eEncodingUint, \
- eFormatHex, { kind1, kind2, kind3, kind4, gpr_##reg##_mips64 }, NULL, NULL, NULL, 0}
+#define DEFINE_GPR(reg, alt, kind1, kind2, kind3, kind4) \
+ { \
+ #reg, alt, sizeof(((GPR_freebsd_mips *) 0)->reg), \
+ GPR_OFFSET(reg), eEncodingUint, eFormatHex, \
+ {kind1, kind2, kind3, kind4, \
+ gpr_##reg##_mips64 }, \
+ NULL, NULL, NULL, 0 \
+ }
#endif
-#define DEFINE_GPR_INFO(reg, alt, kind1, kind2, kind3, kind4) \
- { #reg, alt, sizeof(((GPR_linux_mips*)0)->reg) / 2, GPR_OFFSET(reg), eEncodingUint, \
- eFormatHex, { kind1, kind2, kind3, kind4, gpr_##reg##_mips64 }, NULL, NULL, NULL, 0}
-
-const uint8_t dwarf_opcode_mips64 [] = {
- llvm::dwarf::DW_OP_regx, dwarf_sr_mips64, llvm::dwarf::DW_OP_lit1,
- llvm::dwarf::DW_OP_lit26, llvm::dwarf::DW_OP_shl, llvm::dwarf::DW_OP_and,
- llvm::dwarf::DW_OP_lit26, llvm::dwarf::DW_OP_shr
- };
-
-
-#define DEFINE_FPR(reg, alt, kind1, kind2, kind3, kind4) \
- { #reg, alt, sizeof(((FPR_linux_mips*)0)->reg), FPR_OFFSET(reg), eEncodingIEEE754, \
- eFormatFloat, { kind1, kind2, kind3, kind4, fpr_##reg##_mips64 }, NULL, NULL, dwarf_opcode_mips64, sizeof(dwarf_opcode_mips64)}
-
-#define DEFINE_FPR_INFO(reg, alt, kind1, kind2, kind3, kind4) \
- { #reg, alt, sizeof(((FPR_linux_mips*)0)->reg), FPR_OFFSET(reg), eEncodingUint, \
- eFormatHex, { kind1, kind2, kind3, kind4, fpr_##reg##_mips64 }, NULL, NULL, NULL, 0}
-
-#define DEFINE_MSA(reg, alt, kind1, kind2, kind3, kind4) \
- { #reg, alt, sizeof(((MSA_linux_mips*)0)->reg), MSA_OFFSET(reg), eEncodingVector, \
- eFormatVectorOfUInt8, { kind1, kind2, kind3, kind4, msa_##reg##_mips64 }, NULL, NULL, NULL, 0}
-
-#define DEFINE_MSA_INFO(reg, alt, kind1, kind2, kind3, kind4) \
- { #reg, alt, sizeof(((MSA_linux_mips*)0)->reg), MSA_OFFSET(reg), eEncodingUint, \
- eFormatHex, { kind1, kind2, kind3, kind4, msa_##reg##_mips64 }, NULL, NULL, NULL, 0}
-
-static RegisterInfo
-g_register_infos_mips64[] =
-{
- // General purpose registers. EH_Frame, DWARF, Generic, Process Plugin
+#define DEFINE_GPR_INFO(reg, alt, kind1, kind2, kind3, kind4) \
+ { \
+ #reg, alt, sizeof(((GPR_linux_mips *) 0)->reg) / 2, \
+ GPR_OFFSET(reg), eEncodingUint, eFormatHex, \
+ {kind1, kind2, kind3, kind4, \
+ gpr_##reg##_mips64 }, \
+ NULL, NULL, NULL, 0 \
+ }
+
+const uint8_t dwarf_opcode_mips64[] = {
+ llvm::dwarf::DW_OP_regx, dwarf_sr_mips64, llvm::dwarf::DW_OP_lit1,
+ llvm::dwarf::DW_OP_lit26, llvm::dwarf::DW_OP_shl, llvm::dwarf::DW_OP_and,
+ llvm::dwarf::DW_OP_lit26, llvm::dwarf::DW_OP_shr};
+
+#define DEFINE_FPR(reg, alt, kind1, kind2, kind3, kind4) \
+ { \
+ #reg, alt, sizeof(((FPR_linux_mips *) 0)->reg), \
+ FPR_OFFSET(reg), eEncodingIEEE754, eFormatFloat, \
+ {kind1, kind2, kind3, kind4, \
+ fpr_##reg##_mips64 }, \
+ NULL, NULL, dwarf_opcode_mips64, \
+ sizeof(dwarf_opcode_mips64) \
+ }
+
+#define DEFINE_FPR_INFO(reg, alt, kind1, kind2, kind3, kind4) \
+ { \
+ #reg, alt, sizeof(((FPR_linux_mips *) 0)->reg), \
+ FPR_OFFSET(reg), eEncodingUint, eFormatHex, \
+ {kind1, kind2, kind3, kind4, \
+ fpr_##reg##_mips64 }, \
+ NULL, NULL, NULL, 0 \
+ }
+
+#define DEFINE_MSA(reg, alt, kind1, kind2, kind3, kind4) \
+ { \
+ #reg, alt, sizeof(((MSA_linux_mips *) 0)->reg), \
+ MSA_OFFSET(reg), eEncodingVector, eFormatVectorOfUInt8, \
+ {kind1, kind2, kind3, kind4, \
+ msa_##reg##_mips64 }, \
+ NULL, NULL, NULL, 0 \
+ }
+
+#define DEFINE_MSA_INFO(reg, alt, kind1, kind2, kind3, kind4) \
+ { \
+ #reg, alt, sizeof(((MSA_linux_mips *) 0)->reg), \
+ MSA_OFFSET(reg), eEncodingUint, eFormatHex, \
+ {kind1, kind2, kind3, kind4, \
+ msa_##reg##_mips64 }, \
+ NULL, NULL, NULL, 0 \
+ }
+
+static RegisterInfo g_register_infos_mips64[] = {
+// General purpose registers. EH_Frame, DWARF,
+// Generic, Process Plugin
#ifndef LINUX_MIPS64
- DEFINE_GPR(zero, "r0", dwarf_zero_mips64, dwarf_zero_mips64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_GPR(r1, nullptr, dwarf_r1_mips64, dwarf_r1_mips64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_GPR(r2, nullptr, dwarf_r2_mips64, dwarf_r2_mips64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_GPR(r3, nullptr, dwarf_r3_mips64, dwarf_r3_mips64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_GPR(r4, nullptr, dwarf_r4_mips64, dwarf_r4_mips64, LLDB_REGNUM_GENERIC_ARG1, LLDB_INVALID_REGNUM),
- DEFINE_GPR(r5, nullptr, dwarf_r5_mips64, dwarf_r5_mips64, LLDB_REGNUM_GENERIC_ARG2, LLDB_INVALID_REGNUM),
- DEFINE_GPR(r6, nullptr, dwarf_r6_mips64, dwarf_r6_mips64, LLDB_REGNUM_GENERIC_ARG3, LLDB_INVALID_REGNUM),
- DEFINE_GPR(r7, nullptr, dwarf_r7_mips64, dwarf_r7_mips64, LLDB_REGNUM_GENERIC_ARG4, LLDB_INVALID_REGNUM),
- DEFINE_GPR(r8, nullptr, dwarf_r8_mips64, dwarf_r8_mips64, LLDB_REGNUM_GENERIC_ARG5, LLDB_INVALID_REGNUM),
- DEFINE_GPR(r9, nullptr, dwarf_r9_mips64, dwarf_r9_mips64, LLDB_REGNUM_GENERIC_ARG6, LLDB_INVALID_REGNUM),
- DEFINE_GPR(r10, nullptr, dwarf_r10_mips64, dwarf_r10_mips64, LLDB_REGNUM_GENERIC_ARG7, LLDB_INVALID_REGNUM),
- DEFINE_GPR(r11, nullptr, dwarf_r11_mips64, dwarf_r11_mips64, LLDB_REGNUM_GENERIC_ARG8, LLDB_INVALID_REGNUM),
- DEFINE_GPR(r12, nullptr, dwarf_r12_mips64, dwarf_r12_mips64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_GPR(r13, nullptr, dwarf_r13_mips64, dwarf_r13_mips64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_GPR(r14, nullptr, dwarf_r14_mips64, dwarf_r14_mips64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_GPR(r15, nullptr, dwarf_r15_mips64, dwarf_r15_mips64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_GPR(r16, nullptr, dwarf_r16_mips64, dwarf_r16_mips64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_GPR(r17, nullptr, dwarf_r17_mips64, dwarf_r17_mips64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_GPR(r18, nullptr, dwarf_r18_mips64, dwarf_r18_mips64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_GPR(r19, nullptr, dwarf_r19_mips64, dwarf_r19_mips64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_GPR(r20, nullptr, dwarf_r20_mips64, dwarf_r20_mips64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_GPR(r21, nullptr, dwarf_r21_mips64, dwarf_r21_mips64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_GPR(r22, nullptr, dwarf_r22_mips64, dwarf_r22_mips64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_GPR(r23, nullptr, dwarf_r23_mips64, dwarf_r23_mips64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_GPR(r24, nullptr, dwarf_r24_mips64, dwarf_r24_mips64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_GPR(r25, nullptr, dwarf_r25_mips64, dwarf_r25_mips64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_GPR(r26, nullptr, dwarf_r26_mips64, dwarf_r26_mips64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_GPR(r27, nullptr, dwarf_r27_mips64, dwarf_r27_mips64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_GPR(gp, "r28", dwarf_gp_mips64, dwarf_gp_mips64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_GPR(sp, "r29", dwarf_sp_mips64, dwarf_sp_mips64, LLDB_REGNUM_GENERIC_SP, LLDB_INVALID_REGNUM),
- DEFINE_GPR(r30, nullptr, dwarf_r30_mips64, dwarf_r30_mips64, LLDB_REGNUM_GENERIC_FP, LLDB_INVALID_REGNUM),
- DEFINE_GPR(ra, "r31", dwarf_ra_mips64, dwarf_ra_mips64, LLDB_REGNUM_GENERIC_RA, LLDB_INVALID_REGNUM),
- DEFINE_GPR(sr, nullptr, dwarf_sr_mips64, dwarf_sr_mips64, LLDB_REGNUM_GENERIC_FLAGS, LLDB_INVALID_REGNUM),
- DEFINE_GPR(mullo, nullptr, dwarf_lo_mips64, dwarf_lo_mips64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_GPR(mulhi, nullptr, dwarf_hi_mips64, dwarf_hi_mips64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_GPR(badvaddr, nullptr, dwarf_bad_mips64, dwarf_bad_mips64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_GPR(cause, nullptr, dwarf_cause_mips64, dwarf_cause_mips64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_GPR(pc, "pc", dwarf_pc_mips64, dwarf_pc_mips64, LLDB_REGNUM_GENERIC_PC, LLDB_INVALID_REGNUM),
- DEFINE_GPR(ic, nullptr, dwarf_ic_mips64, dwarf_ic_mips64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_GPR(dummy, nullptr, dwarf_dummy_mips64, dwarf_dummy_mips64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(zero, "r0", dwarf_zero_mips64, dwarf_zero_mips64,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(r1, nullptr, dwarf_r1_mips64, dwarf_r1_mips64,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(r2, nullptr, dwarf_r2_mips64, dwarf_r2_mips64,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(r3, nullptr, dwarf_r3_mips64, dwarf_r3_mips64,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(r4, nullptr, dwarf_r4_mips64, dwarf_r4_mips64,
+ LLDB_REGNUM_GENERIC_ARG1, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(r5, nullptr, dwarf_r5_mips64, dwarf_r5_mips64,
+ LLDB_REGNUM_GENERIC_ARG2, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(r6, nullptr, dwarf_r6_mips64, dwarf_r6_mips64,
+ LLDB_REGNUM_GENERIC_ARG3, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(r7, nullptr, dwarf_r7_mips64, dwarf_r7_mips64,
+ LLDB_REGNUM_GENERIC_ARG4, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(r8, nullptr, dwarf_r8_mips64, dwarf_r8_mips64,
+ LLDB_REGNUM_GENERIC_ARG5, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(r9, nullptr, dwarf_r9_mips64, dwarf_r9_mips64,
+ LLDB_REGNUM_GENERIC_ARG6, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(r10, nullptr, dwarf_r10_mips64, dwarf_r10_mips64,
+ LLDB_REGNUM_GENERIC_ARG7, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(r11, nullptr, dwarf_r11_mips64, dwarf_r11_mips64,
+ LLDB_REGNUM_GENERIC_ARG8, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(r12, nullptr, dwarf_r12_mips64, dwarf_r12_mips64,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(r13, nullptr, dwarf_r13_mips64, dwarf_r13_mips64,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(r14, nullptr, dwarf_r14_mips64, dwarf_r14_mips64,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(r15, nullptr, dwarf_r15_mips64, dwarf_r15_mips64,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(r16, nullptr, dwarf_r16_mips64, dwarf_r16_mips64,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(r17, nullptr, dwarf_r17_mips64, dwarf_r17_mips64,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(r18, nullptr, dwarf_r18_mips64, dwarf_r18_mips64,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(r19, nullptr, dwarf_r19_mips64, dwarf_r19_mips64,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(r20, nullptr, dwarf_r20_mips64, dwarf_r20_mips64,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(r21, nullptr, dwarf_r21_mips64, dwarf_r21_mips64,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(r22, nullptr, dwarf_r22_mips64, dwarf_r22_mips64,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(r23, nullptr, dwarf_r23_mips64, dwarf_r23_mips64,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(r24, nullptr, dwarf_r24_mips64, dwarf_r24_mips64,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(r25, nullptr, dwarf_r25_mips64, dwarf_r25_mips64,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(r26, nullptr, dwarf_r26_mips64, dwarf_r26_mips64,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(r27, nullptr, dwarf_r27_mips64, dwarf_r27_mips64,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(gp, "r28", dwarf_gp_mips64, dwarf_gp_mips64, LLDB_INVALID_REGNUM,
+ LLDB_INVALID_REGNUM),
+ DEFINE_GPR(sp, "r29", dwarf_sp_mips64, dwarf_sp_mips64,
+ LLDB_REGNUM_GENERIC_SP, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(r30, nullptr, dwarf_r30_mips64, dwarf_r30_mips64,
+ LLDB_REGNUM_GENERIC_FP, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(ra, "r31", dwarf_ra_mips64, dwarf_ra_mips64,
+ LLDB_REGNUM_GENERIC_RA, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(sr, nullptr, dwarf_sr_mips64, dwarf_sr_mips64,
+ LLDB_REGNUM_GENERIC_FLAGS, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(mullo, nullptr, dwarf_lo_mips64, dwarf_lo_mips64,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(mulhi, nullptr, dwarf_hi_mips64, dwarf_hi_mips64,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(badvaddr, nullptr, dwarf_bad_mips64, dwarf_bad_mips64,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(cause, nullptr, dwarf_cause_mips64, dwarf_cause_mips64,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(pc, "pc", dwarf_pc_mips64, dwarf_pc_mips64,
+ LLDB_REGNUM_GENERIC_PC, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(ic, nullptr, dwarf_ic_mips64, dwarf_ic_mips64,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(dummy, nullptr, dwarf_dummy_mips64, dwarf_dummy_mips64,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
#else
- DEFINE_GPR(zero, "r0", dwarf_zero_mips64, dwarf_zero_mips64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_GPR(r1, nullptr, dwarf_r1_mips64, dwarf_r1_mips64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_GPR(r2, nullptr, dwarf_r2_mips64, dwarf_r2_mips64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_GPR(r3, nullptr, dwarf_r3_mips64, dwarf_r3_mips64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_GPR(r4, nullptr, dwarf_r4_mips64, dwarf_r4_mips64, LLDB_REGNUM_GENERIC_ARG1, LLDB_INVALID_REGNUM),
- DEFINE_GPR(r5, nullptr, dwarf_r5_mips64, dwarf_r5_mips64, LLDB_REGNUM_GENERIC_ARG2, LLDB_INVALID_REGNUM),
- DEFINE_GPR(r6, nullptr, dwarf_r6_mips64, dwarf_r6_mips64, LLDB_REGNUM_GENERIC_ARG3, LLDB_INVALID_REGNUM),
- DEFINE_GPR(r7, nullptr, dwarf_r7_mips64, dwarf_r7_mips64, LLDB_REGNUM_GENERIC_ARG4, LLDB_INVALID_REGNUM),
- DEFINE_GPR(r8, nullptr, dwarf_r8_mips64, dwarf_r8_mips64, LLDB_REGNUM_GENERIC_ARG5, LLDB_INVALID_REGNUM),
- DEFINE_GPR(r9, nullptr, dwarf_r9_mips64, dwarf_r9_mips64, LLDB_REGNUM_GENERIC_ARG6, LLDB_INVALID_REGNUM),
- DEFINE_GPR(r10, nullptr, dwarf_r10_mips64, dwarf_r10_mips64, LLDB_REGNUM_GENERIC_ARG7, LLDB_INVALID_REGNUM),
- DEFINE_GPR(r11, nullptr, dwarf_r11_mips64, dwarf_r11_mips64, LLDB_REGNUM_GENERIC_ARG8, LLDB_INVALID_REGNUM),
- DEFINE_GPR(r12, nullptr, dwarf_r12_mips64, dwarf_r12_mips64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_GPR(r13, nullptr, dwarf_r13_mips64, dwarf_r13_mips64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_GPR(r14, nullptr, dwarf_r14_mips64, dwarf_r14_mips64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_GPR(r15, nullptr, dwarf_r15_mips64, dwarf_r15_mips64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_GPR(r16, nullptr, dwarf_r16_mips64, dwarf_r16_mips64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_GPR(r17, nullptr, dwarf_r17_mips64, dwarf_r17_mips64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_GPR(r18, nullptr, dwarf_r18_mips64, dwarf_r18_mips64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_GPR(r19, nullptr, dwarf_r19_mips64, dwarf_r19_mips64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_GPR(r20, nullptr, dwarf_r20_mips64, dwarf_r20_mips64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_GPR(r21, nullptr, dwarf_r21_mips64, dwarf_r21_mips64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_GPR(r22, nullptr, dwarf_r22_mips64, dwarf_r22_mips64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_GPR(r23, nullptr, dwarf_r23_mips64, dwarf_r23_mips64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_GPR(r24, nullptr, dwarf_r24_mips64, dwarf_r24_mips64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_GPR(r25, nullptr, dwarf_r25_mips64, dwarf_r25_mips64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_GPR(r26, nullptr, dwarf_r26_mips64, dwarf_r26_mips64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_GPR(r27, nullptr, dwarf_r27_mips64, dwarf_r27_mips64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_GPR(gp, "r28", dwarf_gp_mips64, dwarf_gp_mips64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_GPR(sp, "r29", dwarf_sp_mips64, dwarf_sp_mips64, LLDB_REGNUM_GENERIC_SP, LLDB_INVALID_REGNUM),
- DEFINE_GPR(r30, nullptr, dwarf_r30_mips64, dwarf_r30_mips64, LLDB_REGNUM_GENERIC_FP, LLDB_INVALID_REGNUM),
- DEFINE_GPR(ra, "r31", dwarf_ra_mips64, dwarf_ra_mips64, LLDB_REGNUM_GENERIC_RA, LLDB_INVALID_REGNUM),
- DEFINE_GPR_INFO(sr, nullptr, dwarf_sr_mips64, dwarf_sr_mips64, LLDB_REGNUM_GENERIC_FLAGS, LLDB_INVALID_REGNUM),
- DEFINE_GPR(mullo, nullptr, dwarf_lo_mips64, dwarf_lo_mips64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_GPR(mulhi, nullptr, dwarf_hi_mips64, dwarf_hi_mips64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_GPR(badvaddr, nullptr, dwarf_bad_mips64, dwarf_bad_mips64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_GPR_INFO(cause, nullptr, dwarf_cause_mips64, dwarf_cause_mips64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_GPR(pc, "pc", dwarf_pc_mips64, dwarf_pc_mips64, LLDB_REGNUM_GENERIC_PC, LLDB_INVALID_REGNUM),
- DEFINE_GPR_INFO(config5, nullptr, dwarf_config5_mips64, dwarf_config5_mips64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_FPR (f0, nullptr, dwarf_f0_mips64, dwarf_f0_mips64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_FPR (f1, nullptr, dwarf_f1_mips64, dwarf_f1_mips64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_FPR (f2, nullptr, dwarf_f2_mips64, dwarf_f2_mips64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_FPR (f3, nullptr, dwarf_f3_mips64, dwarf_f3_mips64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_FPR (f4, nullptr, dwarf_f4_mips64, dwarf_f4_mips64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_FPR (f5, nullptr, dwarf_f5_mips64, dwarf_f5_mips64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_FPR (f6, nullptr, dwarf_f6_mips64, dwarf_f6_mips64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_FPR (f7, nullptr, dwarf_f7_mips64, dwarf_f7_mips64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_FPR (f8, nullptr, dwarf_f8_mips64, dwarf_f8_mips64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_FPR (f9, nullptr, dwarf_f9_mips64, dwarf_f9_mips64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_FPR (f10, nullptr, dwarf_f10_mips64, dwarf_f10_mips64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_FPR (f11, nullptr, dwarf_f11_mips64, dwarf_f11_mips64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_FPR (f12, nullptr, dwarf_f12_mips64, dwarf_f12_mips64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_FPR (f13, nullptr, dwarf_f13_mips64, dwarf_f13_mips64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_FPR (f14, nullptr, dwarf_f14_mips64, dwarf_f14_mips64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_FPR (f15, nullptr, dwarf_f15_mips64, dwarf_f15_mips64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_FPR (f16, nullptr, dwarf_f16_mips64, dwarf_f16_mips64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_FPR (f17, nullptr, dwarf_f17_mips64, dwarf_f17_mips64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_FPR (f18, nullptr, dwarf_f18_mips64, dwarf_f18_mips64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_FPR (f19, nullptr, dwarf_f19_mips64, dwarf_f19_mips64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_FPR (f20, nullptr, dwarf_f20_mips64, dwarf_f20_mips64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_FPR (f21, nullptr, dwarf_f21_mips64, dwarf_f21_mips64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_FPR (f22, nullptr, dwarf_f22_mips64, dwarf_f22_mips64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_FPR (f23, nullptr, dwarf_f23_mips64, dwarf_f23_mips64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_FPR (f24, nullptr, dwarf_f24_mips64, dwarf_f24_mips64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_FPR (f25, nullptr, dwarf_f25_mips64, dwarf_f25_mips64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_FPR (f26, nullptr, dwarf_f26_mips64, dwarf_f26_mips64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_FPR (f27, nullptr, dwarf_f27_mips64, dwarf_f27_mips64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_FPR (f28, nullptr, dwarf_f28_mips64, dwarf_f28_mips64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_FPR (f29, nullptr, dwarf_f29_mips64, dwarf_f29_mips64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_FPR (f30, nullptr, dwarf_f30_mips64, dwarf_f30_mips64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_FPR (f31, nullptr, dwarf_f31_mips64, dwarf_f31_mips64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_FPR_INFO (fcsr, nullptr, dwarf_fcsr_mips64, dwarf_fcsr_mips64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_FPR_INFO (fir, nullptr, dwarf_fir_mips64, dwarf_fir_mips64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_FPR_INFO (config5, nullptr, dwarf_config5_mips64, dwarf_config5_mips64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_MSA (w0, nullptr, dwarf_w0_mips64, dwarf_w0_mips64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_MSA (w1, nullptr, dwarf_w1_mips64, dwarf_w1_mips64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_MSA (w2, nullptr, dwarf_w2_mips64, dwarf_w2_mips64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_MSA (w3, nullptr, dwarf_w3_mips64, dwarf_w3_mips64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_MSA (w4, nullptr, dwarf_w4_mips64, dwarf_w4_mips64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_MSA (w5, nullptr, dwarf_w5_mips64, dwarf_w5_mips64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_MSA (w6, nullptr, dwarf_w6_mips64, dwarf_w6_mips64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_MSA (w7, nullptr, dwarf_w7_mips64, dwarf_w7_mips64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_MSA (w8, nullptr, dwarf_w8_mips64, dwarf_w8_mips64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_MSA (w9, nullptr, dwarf_w9_mips64, dwarf_w9_mips64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_MSA (w10, nullptr, dwarf_w10_mips64, dwarf_w10_mips64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_MSA (w11, nullptr, dwarf_w11_mips64, dwarf_w11_mips64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_MSA (w12, nullptr, dwarf_w12_mips64, dwarf_w12_mips64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_MSA (w13, nullptr, dwarf_w13_mips64, dwarf_w13_mips64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_MSA (w14, nullptr, dwarf_w14_mips64, dwarf_w14_mips64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_MSA (w15, nullptr, dwarf_w15_mips64, dwarf_w15_mips64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_MSA (w16, nullptr, dwarf_w16_mips64, dwarf_w16_mips64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_MSA (w17, nullptr, dwarf_w17_mips64, dwarf_w17_mips64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_MSA (w18, nullptr, dwarf_w18_mips64, dwarf_w18_mips64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_MSA (w19, nullptr, dwarf_w19_mips64, dwarf_w19_mips64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_MSA (w20, nullptr, dwarf_w10_mips64, dwarf_w20_mips64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_MSA (w21, nullptr, dwarf_w21_mips64, dwarf_w21_mips64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_MSA (w22, nullptr, dwarf_w22_mips64, dwarf_w22_mips64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_MSA (w23, nullptr, dwarf_w23_mips64, dwarf_w23_mips64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_MSA (w24, nullptr, dwarf_w24_mips64, dwarf_w24_mips64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_MSA (w25, nullptr, dwarf_w25_mips64, dwarf_w25_mips64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_MSA (w26, nullptr, dwarf_w26_mips64, dwarf_w26_mips64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_MSA (w27, nullptr, dwarf_w27_mips64, dwarf_w27_mips64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_MSA (w28, nullptr, dwarf_w28_mips64, dwarf_w28_mips64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_MSA (w29, nullptr, dwarf_w29_mips64, dwarf_w29_mips64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_MSA (w30, nullptr, dwarf_w30_mips64, dwarf_w30_mips64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_MSA (w31, nullptr, dwarf_w31_mips64, dwarf_w31_mips64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_MSA_INFO (mcsr, nullptr, dwarf_mcsr_mips64, dwarf_mcsr_mips64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_MSA_INFO (mir, nullptr, dwarf_mir_mips64, dwarf_mir_mips64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_MSA_INFO (fcsr, nullptr, dwarf_fcsr_mips64, dwarf_fcsr_mips64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_MSA_INFO (fir, nullptr, dwarf_fir_mips64, dwarf_fir_mips64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_MSA_INFO (config5, nullptr, dwarf_config5_mips64, dwarf_config5_mips64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM)
+ DEFINE_GPR(zero, "r0", dwarf_zero_mips64, dwarf_zero_mips64,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(r1, nullptr, dwarf_r1_mips64, dwarf_r1_mips64,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(r2, nullptr, dwarf_r2_mips64, dwarf_r2_mips64,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(r3, nullptr, dwarf_r3_mips64, dwarf_r3_mips64,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(r4, nullptr, dwarf_r4_mips64, dwarf_r4_mips64,
+ LLDB_REGNUM_GENERIC_ARG1, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(r5, nullptr, dwarf_r5_mips64, dwarf_r5_mips64,
+ LLDB_REGNUM_GENERIC_ARG2, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(r6, nullptr, dwarf_r6_mips64, dwarf_r6_mips64,
+ LLDB_REGNUM_GENERIC_ARG3, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(r7, nullptr, dwarf_r7_mips64, dwarf_r7_mips64,
+ LLDB_REGNUM_GENERIC_ARG4, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(r8, nullptr, dwarf_r8_mips64, dwarf_r8_mips64,
+ LLDB_REGNUM_GENERIC_ARG5, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(r9, nullptr, dwarf_r9_mips64, dwarf_r9_mips64,
+ LLDB_REGNUM_GENERIC_ARG6, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(r10, nullptr, dwarf_r10_mips64, dwarf_r10_mips64,
+ LLDB_REGNUM_GENERIC_ARG7, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(r11, nullptr, dwarf_r11_mips64, dwarf_r11_mips64,
+ LLDB_REGNUM_GENERIC_ARG8, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(r12, nullptr, dwarf_r12_mips64, dwarf_r12_mips64,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(r13, nullptr, dwarf_r13_mips64, dwarf_r13_mips64,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(r14, nullptr, dwarf_r14_mips64, dwarf_r14_mips64,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(r15, nullptr, dwarf_r15_mips64, dwarf_r15_mips64,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(r16, nullptr, dwarf_r16_mips64, dwarf_r16_mips64,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(r17, nullptr, dwarf_r17_mips64, dwarf_r17_mips64,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(r18, nullptr, dwarf_r18_mips64, dwarf_r18_mips64,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(r19, nullptr, dwarf_r19_mips64, dwarf_r19_mips64,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(r20, nullptr, dwarf_r20_mips64, dwarf_r20_mips64,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(r21, nullptr, dwarf_r21_mips64, dwarf_r21_mips64,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(r22, nullptr, dwarf_r22_mips64, dwarf_r22_mips64,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(r23, nullptr, dwarf_r23_mips64, dwarf_r23_mips64,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(r24, nullptr, dwarf_r24_mips64, dwarf_r24_mips64,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(r25, nullptr, dwarf_r25_mips64, dwarf_r25_mips64,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(r26, nullptr, dwarf_r26_mips64, dwarf_r26_mips64,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(r27, nullptr, dwarf_r27_mips64, dwarf_r27_mips64,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(gp, "r28", dwarf_gp_mips64, dwarf_gp_mips64, LLDB_INVALID_REGNUM,
+ LLDB_INVALID_REGNUM),
+ DEFINE_GPR(sp, "r29", dwarf_sp_mips64, dwarf_sp_mips64,
+ LLDB_REGNUM_GENERIC_SP, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(r30, nullptr, dwarf_r30_mips64, dwarf_r30_mips64,
+ LLDB_REGNUM_GENERIC_FP, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(ra, "r31", dwarf_ra_mips64, dwarf_ra_mips64,
+ LLDB_REGNUM_GENERIC_RA, LLDB_INVALID_REGNUM),
+ DEFINE_GPR_INFO(sr, nullptr, dwarf_sr_mips64, dwarf_sr_mips64,
+ LLDB_REGNUM_GENERIC_FLAGS, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(mullo, nullptr, dwarf_lo_mips64, dwarf_lo_mips64,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(mulhi, nullptr, dwarf_hi_mips64, dwarf_hi_mips64,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(badvaddr, nullptr, dwarf_bad_mips64, dwarf_bad_mips64,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_GPR_INFO(cause, nullptr, dwarf_cause_mips64, dwarf_cause_mips64,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(pc, "pc", dwarf_pc_mips64, dwarf_pc_mips64,
+ LLDB_REGNUM_GENERIC_PC, LLDB_INVALID_REGNUM),
+ DEFINE_GPR_INFO(config5, nullptr, dwarf_config5_mips64,
+ dwarf_config5_mips64, LLDB_INVALID_REGNUM,
+ LLDB_INVALID_REGNUM),
+ DEFINE_FPR(f0, nullptr, dwarf_f0_mips64, dwarf_f0_mips64,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_FPR(f1, nullptr, dwarf_f1_mips64, dwarf_f1_mips64,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_FPR(f2, nullptr, dwarf_f2_mips64, dwarf_f2_mips64,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_FPR(f3, nullptr, dwarf_f3_mips64, dwarf_f3_mips64,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_FPR(f4, nullptr, dwarf_f4_mips64, dwarf_f4_mips64,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_FPR(f5, nullptr, dwarf_f5_mips64, dwarf_f5_mips64,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_FPR(f6, nullptr, dwarf_f6_mips64, dwarf_f6_mips64,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_FPR(f7, nullptr, dwarf_f7_mips64, dwarf_f7_mips64,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_FPR(f8, nullptr, dwarf_f8_mips64, dwarf_f8_mips64,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_FPR(f9, nullptr, dwarf_f9_mips64, dwarf_f9_mips64,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_FPR(f10, nullptr, dwarf_f10_mips64, dwarf_f10_mips64,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_FPR(f11, nullptr, dwarf_f11_mips64, dwarf_f11_mips64,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_FPR(f12, nullptr, dwarf_f12_mips64, dwarf_f12_mips64,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_FPR(f13, nullptr, dwarf_f13_mips64, dwarf_f13_mips64,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_FPR(f14, nullptr, dwarf_f14_mips64, dwarf_f14_mips64,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_FPR(f15, nullptr, dwarf_f15_mips64, dwarf_f15_mips64,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_FPR(f16, nullptr, dwarf_f16_mips64, dwarf_f16_mips64,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_FPR(f17, nullptr, dwarf_f17_mips64, dwarf_f17_mips64,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_FPR(f18, nullptr, dwarf_f18_mips64, dwarf_f18_mips64,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_FPR(f19, nullptr, dwarf_f19_mips64, dwarf_f19_mips64,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_FPR(f20, nullptr, dwarf_f20_mips64, dwarf_f20_mips64,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_FPR(f21, nullptr, dwarf_f21_mips64, dwarf_f21_mips64,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_FPR(f22, nullptr, dwarf_f22_mips64, dwarf_f22_mips64,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_FPR(f23, nullptr, dwarf_f23_mips64, dwarf_f23_mips64,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_FPR(f24, nullptr, dwarf_f24_mips64, dwarf_f24_mips64,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_FPR(f25, nullptr, dwarf_f25_mips64, dwarf_f25_mips64,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_FPR(f26, nullptr, dwarf_f26_mips64, dwarf_f26_mips64,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_FPR(f27, nullptr, dwarf_f27_mips64, dwarf_f27_mips64,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_FPR(f28, nullptr, dwarf_f28_mips64, dwarf_f28_mips64,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_FPR(f29, nullptr, dwarf_f29_mips64, dwarf_f29_mips64,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_FPR(f30, nullptr, dwarf_f30_mips64, dwarf_f30_mips64,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_FPR(f31, nullptr, dwarf_f31_mips64, dwarf_f31_mips64,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_FPR_INFO(fcsr, nullptr, dwarf_fcsr_mips64, dwarf_fcsr_mips64,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_FPR_INFO(fir, nullptr, dwarf_fir_mips64, dwarf_fir_mips64,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_FPR_INFO(config5, nullptr, dwarf_config5_mips64,
+ dwarf_config5_mips64, LLDB_INVALID_REGNUM,
+ LLDB_INVALID_REGNUM),
+ DEFINE_MSA(w0, nullptr, dwarf_w0_mips64, dwarf_w0_mips64,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_MSA(w1, nullptr, dwarf_w1_mips64, dwarf_w1_mips64,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_MSA(w2, nullptr, dwarf_w2_mips64, dwarf_w2_mips64,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_MSA(w3, nullptr, dwarf_w3_mips64, dwarf_w3_mips64,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_MSA(w4, nullptr, dwarf_w4_mips64, dwarf_w4_mips64,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_MSA(w5, nullptr, dwarf_w5_mips64, dwarf_w5_mips64,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_MSA(w6, nullptr, dwarf_w6_mips64, dwarf_w6_mips64,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_MSA(w7, nullptr, dwarf_w7_mips64, dwarf_w7_mips64,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_MSA(w8, nullptr, dwarf_w8_mips64, dwarf_w8_mips64,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_MSA(w9, nullptr, dwarf_w9_mips64, dwarf_w9_mips64,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_MSA(w10, nullptr, dwarf_w10_mips64, dwarf_w10_mips64,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_MSA(w11, nullptr, dwarf_w11_mips64, dwarf_w11_mips64,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_MSA(w12, nullptr, dwarf_w12_mips64, dwarf_w12_mips64,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_MSA(w13, nullptr, dwarf_w13_mips64, dwarf_w13_mips64,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_MSA(w14, nullptr, dwarf_w14_mips64, dwarf_w14_mips64,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_MSA(w15, nullptr, dwarf_w15_mips64, dwarf_w15_mips64,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_MSA(w16, nullptr, dwarf_w16_mips64, dwarf_w16_mips64,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_MSA(w17, nullptr, dwarf_w17_mips64, dwarf_w17_mips64,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_MSA(w18, nullptr, dwarf_w18_mips64, dwarf_w18_mips64,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_MSA(w19, nullptr, dwarf_w19_mips64, dwarf_w19_mips64,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_MSA(w20, nullptr, dwarf_w10_mips64, dwarf_w20_mips64,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_MSA(w21, nullptr, dwarf_w21_mips64, dwarf_w21_mips64,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_MSA(w22, nullptr, dwarf_w22_mips64, dwarf_w22_mips64,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_MSA(w23, nullptr, dwarf_w23_mips64, dwarf_w23_mips64,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_MSA(w24, nullptr, dwarf_w24_mips64, dwarf_w24_mips64,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_MSA(w25, nullptr, dwarf_w25_mips64, dwarf_w25_mips64,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_MSA(w26, nullptr, dwarf_w26_mips64, dwarf_w26_mips64,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_MSA(w27, nullptr, dwarf_w27_mips64, dwarf_w27_mips64,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_MSA(w28, nullptr, dwarf_w28_mips64, dwarf_w28_mips64,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_MSA(w29, nullptr, dwarf_w29_mips64, dwarf_w29_mips64,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_MSA(w30, nullptr, dwarf_w30_mips64, dwarf_w30_mips64,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_MSA(w31, nullptr, dwarf_w31_mips64, dwarf_w31_mips64,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_MSA_INFO(mcsr, nullptr, dwarf_mcsr_mips64, dwarf_mcsr_mips64,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_MSA_INFO(mir, nullptr, dwarf_mir_mips64, dwarf_mir_mips64,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_MSA_INFO(fcsr, nullptr, dwarf_fcsr_mips64, dwarf_fcsr_mips64,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_MSA_INFO(fir, nullptr, dwarf_fir_mips64, dwarf_fir_mips64,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_MSA_INFO(config5, nullptr, dwarf_config5_mips64,
+ dwarf_config5_mips64, LLDB_INVALID_REGNUM,
+ LLDB_INVALID_REGNUM)
#endif
};
-static_assert((sizeof(g_register_infos_mips64) / sizeof(g_register_infos_mips64[0])) == k_num_registers_mips64,
- "g_register_infos_mips64 has wrong number of register infos");
+static_assert((sizeof(g_register_infos_mips64) /
+ sizeof(g_register_infos_mips64[0])) == k_num_registers_mips64,
+ "g_register_infos_mips64 has wrong number of register infos");
#undef DEFINE_GPR
#undef DEFINE_GPR_INFO
Modified: lldb/trunk/source/Plugins/Process/Utility/RegisterInfos_powerpc.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Utility/RegisterInfos_powerpc.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/Utility/RegisterInfos_powerpc.h (original)
+++ lldb/trunk/source/Plugins/Process/Utility/RegisterInfos_powerpc.h Tue Sep 6 15:57:50 2016
@@ -10,170 +10,216 @@
#include <stddef.h>
// Computes the offset of the given GPR in the user data area.
-#define GPR_OFFSET(regname) \
- (offsetof(GPR, regname))
-#define FPR_OFFSET(regname) \
- (offsetof(FPR, regname))
-#define VMX_OFFSET(regname) \
- (offsetof(VMX, regname))
-#define GPR_SIZE(regname) \
- (sizeof(((GPR*)NULL)->regname))
+#define GPR_OFFSET(regname) (offsetof(GPR, regname))
+#define FPR_OFFSET(regname) (offsetof(FPR, regname))
+#define VMX_OFFSET(regname) (offsetof(VMX, regname))
+#define GPR_SIZE(regname) (sizeof(((GPR *)NULL)->regname))
#ifdef DECLARE_REGISTER_INFOS_POWERPC_STRUCT
// Note that the size and offset will be updated by platform-specific classes.
-#define DEFINE_GPR(reg, alt, lldb_kind) \
- { #reg, alt, GPR_SIZE(reg), GPR_OFFSET(reg), eEncodingUint, \
- eFormatHex, { dwarf_##reg##_powerpc, dwarf_##reg##_powerpc, lldb_kind, LLDB_INVALID_REGNUM, gpr_##reg##_powerpc }, NULL, NULL, NULL, 0}
-#define DEFINE_FPR(reg, lldb_kind) \
- { #reg, NULL, 8, FPR_OFFSET(reg), eEncodingIEEE754, \
- eFormatFloat, { dwarf_##reg##_powerpc, dwarf_##reg##_powerpc, lldb_kind, LLDB_INVALID_REGNUM, fpr_##reg##_powerpc }, NULL, NULL, NULL, 0}
-#define DEFINE_VMX(reg, lldb_kind) \
- { #reg, NULL, 16, VMX_OFFSET(reg), eEncodingVector, \
- eFormatVectorOfUInt32, { dwarf_##reg##_powerpc, dwarf_##reg##_powerpc, lldb_kind, LLDB_INVALID_REGNUM, vmx_##reg##_powerpc }, NULL, NULL, NULL, 0}
-
- // General purpose registers. EH_Frame, DWARF, Generic, Process Plugin
-#define POWERPC_REGS \
- DEFINE_GPR(r0, NULL, LLDB_INVALID_REGNUM), \
- DEFINE_GPR(r1, "sp", LLDB_REGNUM_GENERIC_SP), \
- DEFINE_GPR(r2, NULL, LLDB_INVALID_REGNUM), \
- DEFINE_GPR(r3, "arg1",LLDB_REGNUM_GENERIC_ARG1), \
- DEFINE_GPR(r4, "arg2",LLDB_REGNUM_GENERIC_ARG2), \
- DEFINE_GPR(r5, "arg3",LLDB_REGNUM_GENERIC_ARG3), \
- DEFINE_GPR(r6, "arg4",LLDB_REGNUM_GENERIC_ARG4), \
- DEFINE_GPR(r7, "arg5",LLDB_REGNUM_GENERIC_ARG5), \
- DEFINE_GPR(r8, "arg6",LLDB_REGNUM_GENERIC_ARG6), \
- DEFINE_GPR(r9, "arg7",LLDB_REGNUM_GENERIC_ARG7), \
- DEFINE_GPR(r10, "arg8",LLDB_REGNUM_GENERIC_ARG8), \
- DEFINE_GPR(r11, NULL, LLDB_INVALID_REGNUM), \
- DEFINE_GPR(r12, NULL, LLDB_INVALID_REGNUM), \
- DEFINE_GPR(r13, NULL, LLDB_INVALID_REGNUM), \
- DEFINE_GPR(r14, NULL, LLDB_INVALID_REGNUM), \
- DEFINE_GPR(r15, NULL, LLDB_INVALID_REGNUM), \
- DEFINE_GPR(r16, NULL, LLDB_INVALID_REGNUM), \
- DEFINE_GPR(r17, NULL, LLDB_INVALID_REGNUM), \
- DEFINE_GPR(r18, NULL, LLDB_INVALID_REGNUM), \
- DEFINE_GPR(r19, NULL, LLDB_INVALID_REGNUM), \
- DEFINE_GPR(r20, NULL, LLDB_INVALID_REGNUM), \
- DEFINE_GPR(r21, NULL, LLDB_INVALID_REGNUM), \
- DEFINE_GPR(r22, NULL, LLDB_INVALID_REGNUM), \
- DEFINE_GPR(r23, NULL, LLDB_INVALID_REGNUM), \
- DEFINE_GPR(r24, NULL, LLDB_INVALID_REGNUM), \
- DEFINE_GPR(r25, NULL, LLDB_INVALID_REGNUM), \
- DEFINE_GPR(r26, NULL, LLDB_INVALID_REGNUM), \
- DEFINE_GPR(r27, NULL, LLDB_INVALID_REGNUM), \
- DEFINE_GPR(r28, NULL, LLDB_INVALID_REGNUM), \
- DEFINE_GPR(r29, NULL, LLDB_INVALID_REGNUM), \
- DEFINE_GPR(r30, NULL, LLDB_INVALID_REGNUM), \
- DEFINE_GPR(r31, NULL, LLDB_INVALID_REGNUM), \
- DEFINE_GPR(lr, "lr", LLDB_REGNUM_GENERIC_RA), \
- DEFINE_GPR(cr, "cr", LLDB_REGNUM_GENERIC_FLAGS), \
- DEFINE_GPR(xer, "xer", LLDB_INVALID_REGNUM), \
- DEFINE_GPR(ctr, "ctr", LLDB_INVALID_REGNUM), \
- DEFINE_GPR(pc, "pc", LLDB_REGNUM_GENERIC_PC), \
- DEFINE_FPR(f0, LLDB_INVALID_REGNUM), \
- DEFINE_FPR(f1, LLDB_INVALID_REGNUM), \
- DEFINE_FPR(f2, LLDB_INVALID_REGNUM), \
- DEFINE_FPR(f3, LLDB_INVALID_REGNUM), \
- DEFINE_FPR(f4, LLDB_INVALID_REGNUM), \
- DEFINE_FPR(f5, LLDB_INVALID_REGNUM), \
- DEFINE_FPR(f6, LLDB_INVALID_REGNUM), \
- DEFINE_FPR(f7, LLDB_INVALID_REGNUM), \
- DEFINE_FPR(f8, LLDB_INVALID_REGNUM), \
- DEFINE_FPR(f9, LLDB_INVALID_REGNUM), \
- DEFINE_FPR(f10, LLDB_INVALID_REGNUM), \
- DEFINE_FPR(f11, LLDB_INVALID_REGNUM), \
- DEFINE_FPR(f12, LLDB_INVALID_REGNUM), \
- DEFINE_FPR(f13, LLDB_INVALID_REGNUM), \
- DEFINE_FPR(f14, LLDB_INVALID_REGNUM), \
- DEFINE_FPR(f15, LLDB_INVALID_REGNUM), \
- DEFINE_FPR(f16, LLDB_INVALID_REGNUM), \
- DEFINE_FPR(f17, LLDB_INVALID_REGNUM), \
- DEFINE_FPR(f18, LLDB_INVALID_REGNUM), \
- DEFINE_FPR(f19, LLDB_INVALID_REGNUM), \
- DEFINE_FPR(f20, LLDB_INVALID_REGNUM), \
- DEFINE_FPR(f21, LLDB_INVALID_REGNUM), \
- DEFINE_FPR(f22, LLDB_INVALID_REGNUM), \
- DEFINE_FPR(f23, LLDB_INVALID_REGNUM), \
- DEFINE_FPR(f24, LLDB_INVALID_REGNUM), \
- DEFINE_FPR(f25, LLDB_INVALID_REGNUM), \
- DEFINE_FPR(f26, LLDB_INVALID_REGNUM), \
- DEFINE_FPR(f27, LLDB_INVALID_REGNUM), \
- DEFINE_FPR(f28, LLDB_INVALID_REGNUM), \
- DEFINE_FPR(f29, LLDB_INVALID_REGNUM), \
- DEFINE_FPR(f30, LLDB_INVALID_REGNUM), \
- DEFINE_FPR(f31, LLDB_INVALID_REGNUM), \
- { "fpscr", NULL, 8, FPR_OFFSET(fpscr), eEncodingUint, eFormatHex, { dwarf_fpscr_powerpc, dwarf_fpscr_powerpc, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, fpr_fpscr_powerpc }, NULL, NULL, NULL, 0 }, \
- DEFINE_VMX(v0, LLDB_INVALID_REGNUM), \
- DEFINE_VMX(v1, LLDB_INVALID_REGNUM), \
- DEFINE_VMX(v2, LLDB_INVALID_REGNUM), \
- DEFINE_VMX(v3, LLDB_INVALID_REGNUM), \
- DEFINE_VMX(v4, LLDB_INVALID_REGNUM), \
- DEFINE_VMX(v5, LLDB_INVALID_REGNUM), \
- DEFINE_VMX(v6, LLDB_INVALID_REGNUM), \
- DEFINE_VMX(v7, LLDB_INVALID_REGNUM), \
- DEFINE_VMX(v8, LLDB_INVALID_REGNUM), \
- DEFINE_VMX(v9, LLDB_INVALID_REGNUM), \
- DEFINE_VMX(v10, LLDB_INVALID_REGNUM), \
- DEFINE_VMX(v11, LLDB_INVALID_REGNUM), \
- DEFINE_VMX(v12, LLDB_INVALID_REGNUM), \
- DEFINE_VMX(v13, LLDB_INVALID_REGNUM), \
- DEFINE_VMX(v14, LLDB_INVALID_REGNUM), \
- DEFINE_VMX(v15, LLDB_INVALID_REGNUM), \
- DEFINE_VMX(v16, LLDB_INVALID_REGNUM), \
- DEFINE_VMX(v17, LLDB_INVALID_REGNUM), \
- DEFINE_VMX(v18, LLDB_INVALID_REGNUM), \
- DEFINE_VMX(v19, LLDB_INVALID_REGNUM), \
- DEFINE_VMX(v20, LLDB_INVALID_REGNUM), \
- DEFINE_VMX(v21, LLDB_INVALID_REGNUM), \
- DEFINE_VMX(v22, LLDB_INVALID_REGNUM), \
- DEFINE_VMX(v23, LLDB_INVALID_REGNUM), \
- DEFINE_VMX(v24, LLDB_INVALID_REGNUM), \
- DEFINE_VMX(v25, LLDB_INVALID_REGNUM), \
- DEFINE_VMX(v26, LLDB_INVALID_REGNUM), \
- DEFINE_VMX(v27, LLDB_INVALID_REGNUM), \
- DEFINE_VMX(v28, LLDB_INVALID_REGNUM), \
- DEFINE_VMX(v29, LLDB_INVALID_REGNUM), \
- DEFINE_VMX(v30, LLDB_INVALID_REGNUM), \
- DEFINE_VMX(v31, LLDB_INVALID_REGNUM), \
- { "vrsave", NULL, 4, VMX_OFFSET(vrsave), eEncodingUint, eFormatHex, { dwarf_vrsave_powerpc, dwarf_vrsave_powerpc, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, vmx_vrsave_powerpc }, NULL, NULL, NULL, 0}, \
- { "vscr", NULL, 4, VMX_OFFSET(vscr), eEncodingUint, eFormatHex, { dwarf_vscr_powerpc, dwarf_vscr_powerpc, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, vmx_vscr_powerpc }, NULL, NULL, NULL, 0},
-
-static RegisterInfo
-g_register_infos_powerpc64[] =
-{
+#define DEFINE_GPR(reg, alt, lldb_kind) \
+ { \
+ #reg, alt, GPR_SIZE(reg), GPR_OFFSET(reg), eEncodingUint, eFormatHex, \
+ {dwarf_##reg##_powerpc, \
+ dwarf_##reg##_powerpc, lldb_kind, \
+ LLDB_INVALID_REGNUM, \
+ gpr_##reg##_powerpc }, \
+ NULL, NULL, NULL, 0 \
+ }
+#define DEFINE_FPR(reg, lldb_kind) \
+ { \
+ #reg, NULL, 8, FPR_OFFSET(reg), eEncodingIEEE754, eFormatFloat, \
+ {dwarf_##reg##_powerpc, dwarf_##reg##_powerpc, \
+ lldb_kind, LLDB_INVALID_REGNUM, \
+ fpr_##reg##_powerpc }, \
+ NULL, NULL, NULL, 0 \
+ }
+#define DEFINE_VMX(reg, lldb_kind) \
+ { \
+ #reg, NULL, 16, VMX_OFFSET(reg), eEncodingVector, eFormatVectorOfUInt32, \
+ {dwarf_##reg##_powerpc, dwarf_##reg##_powerpc, \
+ lldb_kind, LLDB_INVALID_REGNUM, \
+ vmx_##reg##_powerpc }, \
+ NULL, NULL, NULL, 0 \
+ }
+
+// General purpose registers. EH_Frame, DWARF,
+// Generic, Process Plugin
+#define POWERPC_REGS \
+ DEFINE_GPR(r0, NULL, LLDB_INVALID_REGNUM) \
+ , DEFINE_GPR(r1, "sp", LLDB_REGNUM_GENERIC_SP), \
+ DEFINE_GPR(r2, NULL, LLDB_INVALID_REGNUM), \
+ DEFINE_GPR(r3, "arg1", LLDB_REGNUM_GENERIC_ARG1), \
+ DEFINE_GPR(r4, "arg2", LLDB_REGNUM_GENERIC_ARG2), \
+ DEFINE_GPR(r5, "arg3", LLDB_REGNUM_GENERIC_ARG3), \
+ DEFINE_GPR(r6, "arg4", LLDB_REGNUM_GENERIC_ARG4), \
+ DEFINE_GPR(r7, "arg5", LLDB_REGNUM_GENERIC_ARG5), \
+ DEFINE_GPR(r8, "arg6", LLDB_REGNUM_GENERIC_ARG6), \
+ DEFINE_GPR(r9, "arg7", LLDB_REGNUM_GENERIC_ARG7), \
+ DEFINE_GPR(r10, "arg8", LLDB_REGNUM_GENERIC_ARG8), \
+ DEFINE_GPR(r11, NULL, LLDB_INVALID_REGNUM), \
+ DEFINE_GPR(r12, NULL, LLDB_INVALID_REGNUM), \
+ DEFINE_GPR(r13, NULL, LLDB_INVALID_REGNUM), \
+ DEFINE_GPR(r14, NULL, LLDB_INVALID_REGNUM), \
+ DEFINE_GPR(r15, NULL, LLDB_INVALID_REGNUM), \
+ DEFINE_GPR(r16, NULL, LLDB_INVALID_REGNUM), \
+ DEFINE_GPR(r17, NULL, LLDB_INVALID_REGNUM), \
+ DEFINE_GPR(r18, NULL, LLDB_INVALID_REGNUM), \
+ DEFINE_GPR(r19, NULL, LLDB_INVALID_REGNUM), \
+ DEFINE_GPR(r20, NULL, LLDB_INVALID_REGNUM), \
+ DEFINE_GPR(r21, NULL, LLDB_INVALID_REGNUM), \
+ DEFINE_GPR(r22, NULL, LLDB_INVALID_REGNUM), \
+ DEFINE_GPR(r23, NULL, LLDB_INVALID_REGNUM), \
+ DEFINE_GPR(r24, NULL, LLDB_INVALID_REGNUM), \
+ DEFINE_GPR(r25, NULL, LLDB_INVALID_REGNUM), \
+ DEFINE_GPR(r26, NULL, LLDB_INVALID_REGNUM), \
+ DEFINE_GPR(r27, NULL, LLDB_INVALID_REGNUM), \
+ DEFINE_GPR(r28, NULL, LLDB_INVALID_REGNUM), \
+ DEFINE_GPR(r29, NULL, LLDB_INVALID_REGNUM), \
+ DEFINE_GPR(r30, NULL, LLDB_INVALID_REGNUM), \
+ DEFINE_GPR(r31, NULL, LLDB_INVALID_REGNUM), \
+ DEFINE_GPR(lr, "lr", LLDB_REGNUM_GENERIC_RA), \
+ DEFINE_GPR(cr, "cr", LLDB_REGNUM_GENERIC_FLAGS), \
+ DEFINE_GPR(xer, "xer", LLDB_INVALID_REGNUM), \
+ DEFINE_GPR(ctr, "ctr", LLDB_INVALID_REGNUM), \
+ DEFINE_GPR(pc, "pc", LLDB_REGNUM_GENERIC_PC), \
+ DEFINE_FPR(f0, LLDB_INVALID_REGNUM), \
+ DEFINE_FPR(f1, LLDB_INVALID_REGNUM), \
+ DEFINE_FPR(f2, LLDB_INVALID_REGNUM), \
+ DEFINE_FPR(f3, LLDB_INVALID_REGNUM), \
+ DEFINE_FPR(f4, LLDB_INVALID_REGNUM), \
+ DEFINE_FPR(f5, LLDB_INVALID_REGNUM), \
+ DEFINE_FPR(f6, LLDB_INVALID_REGNUM), \
+ DEFINE_FPR(f7, LLDB_INVALID_REGNUM), \
+ DEFINE_FPR(f8, LLDB_INVALID_REGNUM), \
+ DEFINE_FPR(f9, LLDB_INVALID_REGNUM), \
+ DEFINE_FPR(f10, LLDB_INVALID_REGNUM), \
+ DEFINE_FPR(f11, LLDB_INVALID_REGNUM), \
+ DEFINE_FPR(f12, LLDB_INVALID_REGNUM), \
+ DEFINE_FPR(f13, LLDB_INVALID_REGNUM), \
+ DEFINE_FPR(f14, LLDB_INVALID_REGNUM), \
+ DEFINE_FPR(f15, LLDB_INVALID_REGNUM), \
+ DEFINE_FPR(f16, LLDB_INVALID_REGNUM), \
+ DEFINE_FPR(f17, LLDB_INVALID_REGNUM), \
+ DEFINE_FPR(f18, LLDB_INVALID_REGNUM), \
+ DEFINE_FPR(f19, LLDB_INVALID_REGNUM), \
+ DEFINE_FPR(f20, LLDB_INVALID_REGNUM), \
+ DEFINE_FPR(f21, LLDB_INVALID_REGNUM), \
+ DEFINE_FPR(f22, LLDB_INVALID_REGNUM), \
+ DEFINE_FPR(f23, LLDB_INVALID_REGNUM), \
+ DEFINE_FPR(f24, LLDB_INVALID_REGNUM), \
+ DEFINE_FPR(f25, LLDB_INVALID_REGNUM), \
+ DEFINE_FPR(f26, LLDB_INVALID_REGNUM), \
+ DEFINE_FPR(f27, LLDB_INVALID_REGNUM), \
+ DEFINE_FPR(f28, LLDB_INVALID_REGNUM), \
+ DEFINE_FPR(f29, LLDB_INVALID_REGNUM), \
+ DEFINE_FPR(f30, LLDB_INVALID_REGNUM), \
+ DEFINE_FPR(f31, LLDB_INVALID_REGNUM), \
+ {"fpscr", \
+ NULL, \
+ 8, \
+ FPR_OFFSET(fpscr), \
+ eEncodingUint, \
+ eFormatHex, \
+ {dwarf_fpscr_powerpc, dwarf_fpscr_powerpc, LLDB_INVALID_REGNUM, \
+ LLDB_INVALID_REGNUM, fpr_fpscr_powerpc}, \
+ NULL, \
+ NULL, \
+ NULL, \
+ 0}, \
+ DEFINE_VMX(v0, LLDB_INVALID_REGNUM), \
+ DEFINE_VMX(v1, LLDB_INVALID_REGNUM), \
+ DEFINE_VMX(v2, LLDB_INVALID_REGNUM), \
+ DEFINE_VMX(v3, LLDB_INVALID_REGNUM), \
+ DEFINE_VMX(v4, LLDB_INVALID_REGNUM), \
+ DEFINE_VMX(v5, LLDB_INVALID_REGNUM), \
+ DEFINE_VMX(v6, LLDB_INVALID_REGNUM), \
+ DEFINE_VMX(v7, LLDB_INVALID_REGNUM), \
+ DEFINE_VMX(v8, LLDB_INVALID_REGNUM), \
+ DEFINE_VMX(v9, LLDB_INVALID_REGNUM), \
+ DEFINE_VMX(v10, LLDB_INVALID_REGNUM), \
+ DEFINE_VMX(v11, LLDB_INVALID_REGNUM), \
+ DEFINE_VMX(v12, LLDB_INVALID_REGNUM), \
+ DEFINE_VMX(v13, LLDB_INVALID_REGNUM), \
+ DEFINE_VMX(v14, LLDB_INVALID_REGNUM), \
+ DEFINE_VMX(v15, LLDB_INVALID_REGNUM), \
+ DEFINE_VMX(v16, LLDB_INVALID_REGNUM), \
+ DEFINE_VMX(v17, LLDB_INVALID_REGNUM), \
+ DEFINE_VMX(v18, LLDB_INVALID_REGNUM), \
+ DEFINE_VMX(v19, LLDB_INVALID_REGNUM), \
+ DEFINE_VMX(v20, LLDB_INVALID_REGNUM), \
+ DEFINE_VMX(v21, LLDB_INVALID_REGNUM), \
+ DEFINE_VMX(v22, LLDB_INVALID_REGNUM), \
+ DEFINE_VMX(v23, LLDB_INVALID_REGNUM), \
+ DEFINE_VMX(v24, LLDB_INVALID_REGNUM), \
+ DEFINE_VMX(v25, LLDB_INVALID_REGNUM), \
+ DEFINE_VMX(v26, LLDB_INVALID_REGNUM), \
+ DEFINE_VMX(v27, LLDB_INVALID_REGNUM), \
+ DEFINE_VMX(v28, LLDB_INVALID_REGNUM), \
+ DEFINE_VMX(v29, LLDB_INVALID_REGNUM), \
+ DEFINE_VMX(v30, LLDB_INVALID_REGNUM), \
+ DEFINE_VMX(v31, LLDB_INVALID_REGNUM), \
+ {"vrsave", \
+ NULL, \
+ 4, \
+ VMX_OFFSET(vrsave), \
+ eEncodingUint, \
+ eFormatHex, \
+ {dwarf_vrsave_powerpc, dwarf_vrsave_powerpc, LLDB_INVALID_REGNUM, \
+ LLDB_INVALID_REGNUM, vmx_vrsave_powerpc}, \
+ NULL, \
+ NULL, \
+ NULL, \
+ 0}, \
+ {"vscr", \
+ NULL, \
+ 4, \
+ VMX_OFFSET(vscr), \
+ eEncodingUint, \
+ eFormatHex, \
+ {dwarf_vscr_powerpc, dwarf_vscr_powerpc, LLDB_INVALID_REGNUM, \
+ LLDB_INVALID_REGNUM, vmx_vscr_powerpc}, \
+ NULL, \
+ NULL, \
+ NULL, \
+ 0},
+
+static RegisterInfo g_register_infos_powerpc64[] = {
#define GPR GPR64
POWERPC_REGS
#undef GPR
};
-static RegisterInfo
-g_register_infos_powerpc32[] =
-{
+static RegisterInfo g_register_infos_powerpc32[] = {
#define GPR GPR32
POWERPC_REGS
#undef GPR
};
-static RegisterInfo
-g_register_infos_powerpc64_32[] =
-{
+static RegisterInfo g_register_infos_powerpc64_32[] = {
#define GPR GPR64
#undef GPR_SIZE
-#define GPR_SIZE(reg) (sizeof(uint32_t))
+#define GPR_SIZE(reg) (sizeof(uint32_t))
#undef GPR_OFFSET
-#define GPR_OFFSET(regname) \
- (offsetof(GPR, regname) + (sizeof(((GPR *)NULL)->regname) - GPR_SIZE(reg)))
+#define GPR_OFFSET(regname) \
+ (offsetof(GPR, regname) + (sizeof(((GPR *)NULL)->regname) - GPR_SIZE(reg)))
POWERPC_REGS
#undef GPR
};
-static_assert((sizeof(g_register_infos_powerpc32) / sizeof(g_register_infos_powerpc32[0])) == k_num_registers_powerpc,
- "g_register_infos_powerpc32 has wrong number of register infos");
-static_assert((sizeof(g_register_infos_powerpc64) / sizeof(g_register_infos_powerpc64[0])) == k_num_registers_powerpc,
- "g_register_infos_powerpc64 has wrong number of register infos");
-static_assert(sizeof(g_register_infos_powerpc64_32) == sizeof(g_register_infos_powerpc64),
- "g_register_infos_powerpc64_32 doesn't match size of g_register_infos_powerpc64");
+static_assert((sizeof(g_register_infos_powerpc32) /
+ sizeof(g_register_infos_powerpc32[0])) ==
+ k_num_registers_powerpc,
+ "g_register_infos_powerpc32 has wrong number of register infos");
+static_assert((sizeof(g_register_infos_powerpc64) /
+ sizeof(g_register_infos_powerpc64[0])) ==
+ k_num_registers_powerpc,
+ "g_register_infos_powerpc64 has wrong number of register infos");
+static_assert(sizeof(g_register_infos_powerpc64_32) ==
+ sizeof(g_register_infos_powerpc64),
+ "g_register_infos_powerpc64_32 doesn't match size of "
+ "g_register_infos_powerpc64");
#undef DEFINE_FPR
#undef DEFINE_GPR
@@ -181,4 +227,3 @@ static_assert(sizeof(g_register_infos_po
#endif // DECLARE_REGISTER_INFOS_POWERPC_STRUCT
#undef GPR_OFFSET
-
Modified: lldb/trunk/source/Plugins/Process/Utility/RegisterInfos_s390x.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Utility/RegisterInfos_s390x.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/Utility/RegisterInfos_s390x.h (original)
+++ lldb/trunk/source/Plugins/Process/Utility/RegisterInfos_s390x.h Tue Sep 6 15:57:50 2016
@@ -27,36 +27,39 @@
// RegisterKind: EHFrame, DWARF, Generic, Process Plugin, LLDB
-#define DEFINE_GPR(name, size, offset, alt, generic) \
- { \
- #name, alt, size, offset, eEncodingUint, eFormatHex, \
- { dwarf_##name##_s390x, dwarf_##name##_s390x, generic, LLDB_INVALID_REGNUM, lldb_##name##_s390x }, \
- NULL, NULL, NULL, 0 \
- }
-
-#define DEFINE_GPR_NODWARF(name, size, offset, alt, generic) \
- { \
- #name, alt, size, offset, eEncodingUint, eFormatHex, \
- { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, generic, LLDB_INVALID_REGNUM, lldb_##name##_s390x }, \
- NULL, NULL, NULL, 0 \
- }
-
-#define DEFINE_FPR(name, size, offset) \
- { \
- #name, NULL, size, offset, eEncodingUint, eFormatHex, \
- { dwarf_##name##_s390x, dwarf_##name##_s390x, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, lldb_##name##_s390x }, \
- NULL, NULL, NULL, 0 \
- }
-
-#define DEFINE_FPR_NODWARF(name, size, offset) \
- { \
- #name, NULL, size, offset, eEncodingUint, eFormatHex, \
- { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, lldb_##name##_s390x }, \
- NULL, NULL, NULL, 0 \
- }
+#define DEFINE_GPR(name, size, offset, alt, generic) \
+ { \
+ #name, alt, size, offset, eEncodingUint, eFormatHex, \
+ {dwarf_##name##_s390x, dwarf_##name##_s390x, generic, \
+ LLDB_INVALID_REGNUM, lldb_##name##_s390x }, \
+ NULL, NULL, NULL, 0 \
+ }
+
+#define DEFINE_GPR_NODWARF(name, size, offset, alt, generic) \
+ { \
+ #name, alt, size, offset, eEncodingUint, eFormatHex, \
+ {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, generic, \
+ LLDB_INVALID_REGNUM, lldb_##name##_s390x }, \
+ NULL, NULL, NULL, 0 \
+ }
+
+#define DEFINE_FPR(name, size, offset) \
+ { \
+ #name, NULL, size, offset, eEncodingUint, eFormatHex, \
+ {dwarf_##name##_s390x, dwarf_##name##_s390x, LLDB_INVALID_REGNUM, \
+ LLDB_INVALID_REGNUM, lldb_##name##_s390x }, \
+ NULL, NULL, NULL, 0 \
+ }
+
+#define DEFINE_FPR_NODWARF(name, size, offset) \
+ { \
+ #name, NULL, size, offset, eEncodingUint, eFormatHex, \
+ {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, \
+ LLDB_INVALID_REGNUM, lldb_##name##_s390x }, \
+ NULL, NULL, NULL, 0 \
+ }
-static RegisterInfo g_register_infos_s390x[] =
-{
+static RegisterInfo g_register_infos_s390x[] = {
// General purpose registers.
DEFINE_GPR(r0, 8, GPR_OFFSET(0), nullptr, LLDB_INVALID_REGNUM),
DEFINE_GPR(r1, 8, GPR_OFFSET(1), nullptr, LLDB_INVALID_REGNUM),
@@ -94,31 +97,25 @@ static RegisterInfo g_register_infos_s39
DEFINE_GPR(pswa, 8, 8, "pc", LLDB_REGNUM_GENERIC_PC),
// Floating point registers.
- DEFINE_FPR(f0, 8, FPR_OFFSET(0)),
- DEFINE_FPR(f1, 8, FPR_OFFSET(1)),
- DEFINE_FPR(f2, 8, FPR_OFFSET(2)),
- DEFINE_FPR(f3, 8, FPR_OFFSET(3)),
- DEFINE_FPR(f4, 8, FPR_OFFSET(4)),
- DEFINE_FPR(f5, 8, FPR_OFFSET(5)),
- DEFINE_FPR(f6, 8, FPR_OFFSET(6)),
- DEFINE_FPR(f7, 8, FPR_OFFSET(7)),
- DEFINE_FPR(f8, 8, FPR_OFFSET(8)),
- DEFINE_FPR(f9, 8, FPR_OFFSET(9)),
- DEFINE_FPR(f10, 8, FPR_OFFSET(10)),
- DEFINE_FPR(f11, 8, FPR_OFFSET(11)),
- DEFINE_FPR(f12, 8, FPR_OFFSET(12)),
- DEFINE_FPR(f13, 8, FPR_OFFSET(13)),
- DEFINE_FPR(f14, 8, FPR_OFFSET(14)),
- DEFINE_FPR(f15, 8, FPR_OFFSET(15)),
+ DEFINE_FPR(f0, 8, FPR_OFFSET(0)), DEFINE_FPR(f1, 8, FPR_OFFSET(1)),
+ DEFINE_FPR(f2, 8, FPR_OFFSET(2)), DEFINE_FPR(f3, 8, FPR_OFFSET(3)),
+ DEFINE_FPR(f4, 8, FPR_OFFSET(4)), DEFINE_FPR(f5, 8, FPR_OFFSET(5)),
+ DEFINE_FPR(f6, 8, FPR_OFFSET(6)), DEFINE_FPR(f7, 8, FPR_OFFSET(7)),
+ DEFINE_FPR(f8, 8, FPR_OFFSET(8)), DEFINE_FPR(f9, 8, FPR_OFFSET(9)),
+ DEFINE_FPR(f10, 8, FPR_OFFSET(10)), DEFINE_FPR(f11, 8, FPR_OFFSET(11)),
+ DEFINE_FPR(f12, 8, FPR_OFFSET(12)), DEFINE_FPR(f13, 8, FPR_OFFSET(13)),
+ DEFINE_FPR(f14, 8, FPR_OFFSET(14)), DEFINE_FPR(f15, 8, FPR_OFFSET(15)),
DEFINE_FPR_NODWARF(fpc, 4, 0),
// Linux operating-specific info.
- DEFINE_GPR_NODWARF(orig_r2, 8, 16 + 16 * 8 + 16 * 4, nullptr, LLDB_INVALID_REGNUM),
+ DEFINE_GPR_NODWARF(orig_r2, 8, 16 + 16 * 8 + 16 * 4, nullptr,
+ LLDB_INVALID_REGNUM),
DEFINE_GPR_NODWARF(last_break, 8, 0, nullptr, LLDB_INVALID_REGNUM),
DEFINE_GPR_NODWARF(system_call, 4, 0, nullptr, LLDB_INVALID_REGNUM),
};
-static_assert((sizeof(g_register_infos_s390x) / sizeof(g_register_infos_s390x[0])) == k_num_registers_s390x,
+static_assert((sizeof(g_register_infos_s390x) /
+ sizeof(g_register_infos_s390x[0])) == k_num_registers_s390x,
"g_register_infos_s390x has wrong number of register infos");
#undef GPR_OFFSET
Modified: lldb/trunk/source/Plugins/Process/Utility/RegisterInfos_x86_64.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Utility/RegisterInfos_x86_64.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/Utility/RegisterInfos_x86_64.h (original)
+++ lldb/trunk/source/Plugins/Process/Utility/RegisterInfos_x86_64.h Tue Sep 6 15:57:50 2016
@@ -17,30 +17,28 @@
// Project includes
// Computes the offset of the given GPR in the user data area.
-#define GPR_OFFSET(regname) \
- (LLVM_EXTENSION offsetof(GPR, regname))
+#define GPR_OFFSET(regname) (LLVM_EXTENSION offsetof(GPR, regname))
// Computes the offset of the given FPR in the extended data area.
-#define FPR_OFFSET(regname) \
- (LLVM_EXTENSION offsetof(UserArea, fpr) + \
- LLVM_EXTENSION offsetof(FPR, xstate) + \
- LLVM_EXTENSION offsetof(FXSAVE, regname))
+#define FPR_OFFSET(regname) \
+ (LLVM_EXTENSION offsetof(UserArea, fpr) + \
+ LLVM_EXTENSION offsetof(FPR, xstate) + \
+ LLVM_EXTENSION offsetof(FXSAVE, regname))
// Computes the offset of the YMM register assembled from register halves.
// Based on DNBArchImplX86_64.cpp from debugserver
-#define YMM_OFFSET(reg_index) \
- (LLVM_EXTENSION offsetof(UserArea, fpr) + \
- LLVM_EXTENSION offsetof(FPR, xstate) + \
- LLVM_EXTENSION offsetof(XSAVE, ymmh[0]) + \
- (32 * reg_index))
+#define YMM_OFFSET(reg_index) \
+ (LLVM_EXTENSION offsetof(UserArea, fpr) + \
+ LLVM_EXTENSION offsetof(FPR, xstate) + \
+ LLVM_EXTENSION offsetof(XSAVE, ymmh[0]) + (32 * reg_index))
#ifdef DECLARE_REGISTER_INFOS_X86_64_STRUCT
// Number of bytes needed to represent a FPR.
-#define FPR_SIZE(reg) sizeof(((FXSAVE*)NULL)->reg)
+#define FPR_SIZE(reg) sizeof(((FXSAVE *)NULL)->reg)
// Number of bytes needed to represent the i'th FP register.
-#define FP_SIZE sizeof(((MMSReg*)NULL)->bytes)
+#define FP_SIZE sizeof(((MMSReg *)NULL)->bytes)
// Number of bytes needed to represent an XMM register.
#define XMM_SIZE sizeof(XMMReg)
@@ -48,222 +46,255 @@
// Number of bytes needed to represent a YMM register.
#define YMM_SIZE sizeof(YMMReg)
-#define DR_SIZE sizeof(((DBG*)NULL)->dr[0])
+#define DR_SIZE sizeof(((DBG *)NULL)->dr[0])
// RegisterKind: EHFrame, DWARF, Generic, Process Plugin, LLDB
// Note that the size and offset will be updated by platform-specific classes.
-#define DEFINE_GPR(reg, alt, kind1, kind2, kind3, kind4) \
- { #reg, alt, sizeof(((GPR*)NULL)->reg), GPR_OFFSET(reg), eEncodingUint, \
- eFormatHex, { kind1, kind2, kind3, kind4, lldb_##reg##_x86_64 }, NULL, NULL, NULL, 0}
-
-#define DEFINE_FPR(name, reg, kind1, kind2, kind3, kind4) \
- { #name, NULL, FPR_SIZE(reg), FPR_OFFSET(reg), eEncodingUint, \
- eFormatHex, { kind1, kind2, kind3, kind4, lldb_##name##_x86_64 }, NULL, NULL, NULL, 0}
-
-#define DEFINE_FP_ST(reg, i) \
- { #reg#i, NULL, FP_SIZE, LLVM_EXTENSION FPR_OFFSET(stmm[i]), \
- eEncodingVector, eFormatVectorOfUInt8, \
- { dwarf_st##i##_x86_64, dwarf_st##i##_x86_64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, lldb_st##i##_x86_64 }, \
- NULL, NULL, NULL, 0}
-
-#define DEFINE_FP_MM(reg, i) \
- { #reg#i, NULL, sizeof(uint64_t), LLVM_EXTENSION FPR_OFFSET(stmm[i]), \
- eEncodingUint, eFormatHex, \
- { dwarf_mm##i##_x86_64, dwarf_mm##i##_x86_64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, lldb_mm##i##_x86_64 }, \
- NULL, NULL, NULL, 0}
-
-#define DEFINE_XMM(reg, i) \
- { #reg#i, NULL, XMM_SIZE, LLVM_EXTENSION FPR_OFFSET(reg[i]), \
- eEncodingVector, eFormatVectorOfUInt8, \
- { dwarf_##reg##i##_x86_64, dwarf_##reg##i##_x86_64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, lldb_##reg##i##_x86_64}, \
- NULL, NULL, NULL, 0}
-
-#define DEFINE_YMM(reg, i) \
- { #reg#i, NULL, YMM_SIZE, LLVM_EXTENSION YMM_OFFSET(i), \
- eEncodingVector, eFormatVectorOfUInt8, \
- { 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, NULL, 0}
-
-#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, NULL, 0}
-
-#define DEFINE_GPR_PSEUDO_32(reg32, reg64) \
- { #reg32, NULL, 4, GPR_OFFSET(reg64), eEncodingUint, \
- eFormatHex, { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, lldb_##reg32##_x86_64 }, RegisterContextPOSIX_x86::g_contained_##reg64, RegisterContextPOSIX_x86::g_invalidate_##reg64, NULL, 0}
-#define DEFINE_GPR_PSEUDO_16(reg16, reg64) \
- { #reg16, NULL, 2, GPR_OFFSET(reg64), eEncodingUint, \
- eFormatHex, { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, lldb_##reg16##_x86_64 }, RegisterContextPOSIX_x86::g_contained_##reg64, RegisterContextPOSIX_x86::g_invalidate_##reg64, NULL, 0}
-#define DEFINE_GPR_PSEUDO_8H(reg8, reg64) \
- { #reg8, NULL, 1, GPR_OFFSET(reg64)+1, eEncodingUint, \
- eFormatHex, { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, lldb_##reg8##_x86_64 }, RegisterContextPOSIX_x86::g_contained_##reg64, RegisterContextPOSIX_x86::g_invalidate_##reg64, NULL, 0}
-#define DEFINE_GPR_PSEUDO_8L(reg8, reg64) \
- { #reg8, NULL, 1, GPR_OFFSET(reg64), eEncodingUint, \
- eFormatHex, { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, lldb_##reg8##_x86_64 }, RegisterContextPOSIX_x86::g_contained_##reg64, RegisterContextPOSIX_x86::g_invalidate_##reg64, NULL, 0}
-
-static RegisterInfo
-g_register_infos_x86_64[] =
-{
- // General purpose registers. EH_Frame, DWARF, Generic, Process Plugin
- DEFINE_GPR(rax, nullptr, dwarf_rax_x86_64, dwarf_rax_x86_64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_GPR(rbx, nullptr, dwarf_rbx_x86_64, dwarf_rbx_x86_64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_GPR(rcx, "arg4", dwarf_rcx_x86_64, dwarf_rcx_x86_64, LLDB_REGNUM_GENERIC_ARG4, LLDB_INVALID_REGNUM),
- DEFINE_GPR(rdx, "arg3", dwarf_rdx_x86_64, dwarf_rdx_x86_64, LLDB_REGNUM_GENERIC_ARG3, LLDB_INVALID_REGNUM),
- DEFINE_GPR(rdi, "arg1", dwarf_rdi_x86_64, dwarf_rdi_x86_64, LLDB_REGNUM_GENERIC_ARG1, LLDB_INVALID_REGNUM),
- DEFINE_GPR(rsi, "arg2", dwarf_rsi_x86_64, dwarf_rsi_x86_64, LLDB_REGNUM_GENERIC_ARG2, LLDB_INVALID_REGNUM),
- DEFINE_GPR(rbp, "fp", dwarf_rbp_x86_64, dwarf_rbp_x86_64, LLDB_REGNUM_GENERIC_FP, LLDB_INVALID_REGNUM),
- DEFINE_GPR(rsp, "sp", dwarf_rsp_x86_64, dwarf_rsp_x86_64, LLDB_REGNUM_GENERIC_SP, LLDB_INVALID_REGNUM),
- DEFINE_GPR(r8, "arg5", dwarf_r8_x86_64, dwarf_r8_x86_64, LLDB_REGNUM_GENERIC_ARG5, LLDB_INVALID_REGNUM),
- DEFINE_GPR(r9, "arg6", dwarf_r9_x86_64, dwarf_r9_x86_64, LLDB_REGNUM_GENERIC_ARG6, LLDB_INVALID_REGNUM),
- DEFINE_GPR(r10, nullptr, dwarf_r10_x86_64, dwarf_r10_x86_64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_GPR(r11, nullptr, dwarf_r11_x86_64, dwarf_r11_x86_64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_GPR(r12, nullptr, dwarf_r12_x86_64, dwarf_r12_x86_64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_GPR(r13, nullptr, dwarf_r13_x86_64, dwarf_r13_x86_64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_GPR(r14, nullptr, dwarf_r14_x86_64, dwarf_r14_x86_64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_GPR(r15, nullptr, dwarf_r15_x86_64, dwarf_r15_x86_64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_GPR(rip, "pc", dwarf_rip_x86_64, dwarf_rip_x86_64, LLDB_REGNUM_GENERIC_PC, LLDB_INVALID_REGNUM),
- DEFINE_GPR(rflags, "flags", dwarf_rflags_x86_64, dwarf_rflags_x86_64, LLDB_REGNUM_GENERIC_FLAGS, LLDB_INVALID_REGNUM),
- DEFINE_GPR(cs, nullptr, dwarf_cs_x86_64, dwarf_cs_x86_64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_GPR(fs, nullptr, dwarf_fs_x86_64, dwarf_fs_x86_64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_GPR(gs, nullptr, dwarf_gs_x86_64, dwarf_gs_x86_64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_GPR(ss, nullptr, dwarf_ss_x86_64, dwarf_ss_x86_64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_GPR(ds, nullptr, dwarf_ds_x86_64, dwarf_ds_x86_64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_GPR(es, nullptr, dwarf_es_x86_64, dwarf_es_x86_64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
-
- DEFINE_GPR_PSEUDO_32(eax, rax),
- DEFINE_GPR_PSEUDO_32(ebx, rbx),
- DEFINE_GPR_PSEUDO_32(ecx, rcx),
- DEFINE_GPR_PSEUDO_32(edx, rdx),
- DEFINE_GPR_PSEUDO_32(edi, rdi),
- DEFINE_GPR_PSEUDO_32(esi, rsi),
- DEFINE_GPR_PSEUDO_32(ebp, rbp),
- DEFINE_GPR_PSEUDO_32(esp, rsp),
- DEFINE_GPR_PSEUDO_32(r8d, r8),
- DEFINE_GPR_PSEUDO_32(r9d, r9),
- DEFINE_GPR_PSEUDO_32(r10d, r10),
- DEFINE_GPR_PSEUDO_32(r11d, r11),
- DEFINE_GPR_PSEUDO_32(r12d, r12),
- DEFINE_GPR_PSEUDO_32(r13d, r13),
- DEFINE_GPR_PSEUDO_32(r14d, r14),
- DEFINE_GPR_PSEUDO_32(r15d, r15),
- DEFINE_GPR_PSEUDO_16(ax, rax),
- DEFINE_GPR_PSEUDO_16(bx, rbx),
- DEFINE_GPR_PSEUDO_16(cx, rcx),
- DEFINE_GPR_PSEUDO_16(dx, rdx),
- DEFINE_GPR_PSEUDO_16(di, rdi),
- DEFINE_GPR_PSEUDO_16(si, rsi),
- DEFINE_GPR_PSEUDO_16(bp, rbp),
- DEFINE_GPR_PSEUDO_16(sp, rsp),
- DEFINE_GPR_PSEUDO_16(r8w, r8),
- DEFINE_GPR_PSEUDO_16(r9w, r9),
- DEFINE_GPR_PSEUDO_16(r10w, r10),
- DEFINE_GPR_PSEUDO_16(r11w, r11),
- DEFINE_GPR_PSEUDO_16(r12w, r12),
- DEFINE_GPR_PSEUDO_16(r13w, r13),
- DEFINE_GPR_PSEUDO_16(r14w, r14),
- DEFINE_GPR_PSEUDO_16(r15w, r15),
- DEFINE_GPR_PSEUDO_8H(ah, rax),
- DEFINE_GPR_PSEUDO_8H(bh, rbx),
- DEFINE_GPR_PSEUDO_8H(ch, rcx),
- DEFINE_GPR_PSEUDO_8H(dh, rdx),
- DEFINE_GPR_PSEUDO_8L(al, rax),
- DEFINE_GPR_PSEUDO_8L(bl, rbx),
- DEFINE_GPR_PSEUDO_8L(cl, rcx),
- DEFINE_GPR_PSEUDO_8L(dl, rdx),
- DEFINE_GPR_PSEUDO_8L(dil, rdi),
- DEFINE_GPR_PSEUDO_8L(sil, rsi),
- DEFINE_GPR_PSEUDO_8L(bpl, rbp),
- DEFINE_GPR_PSEUDO_8L(spl, rsp),
- DEFINE_GPR_PSEUDO_8L(r8l, r8),
- DEFINE_GPR_PSEUDO_8L(r9l, r9),
- DEFINE_GPR_PSEUDO_8L(r10l, r10),
- DEFINE_GPR_PSEUDO_8L(r11l, r11),
- DEFINE_GPR_PSEUDO_8L(r12l, r12),
- DEFINE_GPR_PSEUDO_8L(r13l, r13),
- DEFINE_GPR_PSEUDO_8L(r14l, r14),
- DEFINE_GPR_PSEUDO_8L(r15l, r15),
-
- // i387 Floating point registers. EH_frame, DWARF, Generic, Process Plugin
- DEFINE_FPR(fctrl, fctrl, dwarf_fctrl_x86_64, dwarf_fctrl_x86_64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_FPR(fstat, fstat, dwarf_fstat_x86_64, dwarf_fstat_x86_64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_FPR(ftag, ftag, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_FPR(fop, fop, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_FPR(fiseg, ptr.i386_.fiseg, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_FPR(fioff, ptr.i386_.fioff, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_FPR(foseg, ptr.i386_.foseg, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_FPR(fooff, ptr.i386_.fooff, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_FPR(mxcsr, mxcsr, dwarf_mxcsr_x86_64, dwarf_mxcsr_x86_64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_FPR(mxcsrmask, mxcsrmask, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+#define DEFINE_GPR(reg, alt, kind1, kind2, kind3, kind4) \
+ { \
+ #reg, alt, sizeof(((GPR *) NULL)->reg), \
+ GPR_OFFSET(reg), eEncodingUint, eFormatHex, \
+ {kind1, kind2, kind3, kind4, \
+ lldb_##reg##_x86_64 }, \
+ NULL, NULL, NULL, 0 \
+ }
+
+#define DEFINE_FPR(name, reg, kind1, kind2, kind3, kind4) \
+ { \
+ #name, NULL, FPR_SIZE(reg), FPR_OFFSET(reg), eEncodingUint, eFormatHex, \
+ {kind1, kind2, kind3, kind4, \
+ lldb_##name##_x86_64 }, \
+ NULL, NULL, NULL, 0 \
+ }
+
+#define DEFINE_FP_ST(reg, i) \
+ { \
+ #reg #i, NULL, FP_SIZE, \
+ LLVM_EXTENSION FPR_OFFSET( \
+ stmm[i]), eEncodingVector, eFormatVectorOfUInt8, \
+ {dwarf_st##i##_x86_64, dwarf_st##i##_x86_64, LLDB_INVALID_REGNUM, \
+ LLDB_INVALID_REGNUM, lldb_st##i##_x86_64 }, \
+ NULL, NULL, NULL, 0 \
+ }
+
+#define DEFINE_FP_MM(reg, i) \
+ { \
+ #reg #i, NULL, sizeof(uint64_t), \
+ LLVM_EXTENSION FPR_OFFSET( \
+ stmm[i]), eEncodingUint, eFormatHex, \
+ {dwarf_mm##i##_x86_64, dwarf_mm##i##_x86_64, \
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, \
+ lldb_mm##i##_x86_64 }, \
+ NULL, NULL, NULL, 0 \
+ }
+
+#define DEFINE_XMM(reg, i) \
+ { \
+ #reg #i, NULL, XMM_SIZE, \
+ LLVM_EXTENSION FPR_OFFSET( \
+ reg[i]), eEncodingVector, eFormatVectorOfUInt8, \
+ {dwarf_##reg##i##_x86_64, dwarf_##reg##i##_x86_64, \
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, \
+ lldb_##reg##i##_x86_64 }, \
+ NULL, NULL, NULL, 0 \
+ }
+
+#define DEFINE_YMM(reg, i) \
+ { \
+ #reg #i, NULL, YMM_SIZE, \
+ LLVM_EXTENSION YMM_OFFSET(i), eEncodingVector, eFormatVectorOfUInt8, \
+ {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, NULL, 0 \
+ }
+
+#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, NULL, 0 \
+ }
+
+#define DEFINE_GPR_PSEUDO_32(reg32, reg64) \
+ { \
+ #reg32, NULL, 4, \
+ GPR_OFFSET(reg64), eEncodingUint, eFormatHex, \
+ {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, \
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, \
+ lldb_##reg32##_x86_64 }, \
+ RegisterContextPOSIX_x86::g_contained_##reg64, \
+ RegisterContextPOSIX_x86::g_invalidate_##reg64, NULL, 0 \
+ }
+#define DEFINE_GPR_PSEUDO_16(reg16, reg64) \
+ { \
+ #reg16, NULL, 2, \
+ GPR_OFFSET(reg64), eEncodingUint, eFormatHex, \
+ {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, \
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, \
+ lldb_##reg16##_x86_64 }, \
+ RegisterContextPOSIX_x86::g_contained_##reg64, \
+ RegisterContextPOSIX_x86::g_invalidate_##reg64, NULL, 0 \
+ }
+#define DEFINE_GPR_PSEUDO_8H(reg8, reg64) \
+ { \
+ #reg8, NULL, 1, \
+ GPR_OFFSET(reg64) + 1, eEncodingUint, eFormatHex, \
+ {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, \
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, \
+ lldb_##reg8##_x86_64 }, \
+ RegisterContextPOSIX_x86::g_contained_##reg64, \
+ RegisterContextPOSIX_x86::g_invalidate_##reg64, NULL, 0 \
+ }
+#define DEFINE_GPR_PSEUDO_8L(reg8, reg64) \
+ { \
+ #reg8, NULL, 1, \
+ GPR_OFFSET(reg64), eEncodingUint, eFormatHex, \
+ {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, \
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, \
+ lldb_##reg8##_x86_64 }, \
+ RegisterContextPOSIX_x86::g_contained_##reg64, \
+ RegisterContextPOSIX_x86::g_invalidate_##reg64, NULL, 0 \
+ }
+
+static RegisterInfo g_register_infos_x86_64[] = {
+ // General purpose registers. EH_Frame, DWARF,
+ // Generic, Process Plugin
+ DEFINE_GPR(rax, nullptr, dwarf_rax_x86_64, dwarf_rax_x86_64,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(rbx, nullptr, dwarf_rbx_x86_64, dwarf_rbx_x86_64,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(rcx, "arg4", dwarf_rcx_x86_64, dwarf_rcx_x86_64,
+ LLDB_REGNUM_GENERIC_ARG4, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(rdx, "arg3", dwarf_rdx_x86_64, dwarf_rdx_x86_64,
+ LLDB_REGNUM_GENERIC_ARG3, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(rdi, "arg1", dwarf_rdi_x86_64, dwarf_rdi_x86_64,
+ LLDB_REGNUM_GENERIC_ARG1, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(rsi, "arg2", dwarf_rsi_x86_64, dwarf_rsi_x86_64,
+ LLDB_REGNUM_GENERIC_ARG2, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(rbp, "fp", dwarf_rbp_x86_64, dwarf_rbp_x86_64,
+ LLDB_REGNUM_GENERIC_FP, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(rsp, "sp", dwarf_rsp_x86_64, dwarf_rsp_x86_64,
+ LLDB_REGNUM_GENERIC_SP, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(r8, "arg5", dwarf_r8_x86_64, dwarf_r8_x86_64,
+ LLDB_REGNUM_GENERIC_ARG5, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(r9, "arg6", dwarf_r9_x86_64, dwarf_r9_x86_64,
+ LLDB_REGNUM_GENERIC_ARG6, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(r10, nullptr, dwarf_r10_x86_64, dwarf_r10_x86_64,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(r11, nullptr, dwarf_r11_x86_64, dwarf_r11_x86_64,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(r12, nullptr, dwarf_r12_x86_64, dwarf_r12_x86_64,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(r13, nullptr, dwarf_r13_x86_64, dwarf_r13_x86_64,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(r14, nullptr, dwarf_r14_x86_64, dwarf_r14_x86_64,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(r15, nullptr, dwarf_r15_x86_64, dwarf_r15_x86_64,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(rip, "pc", dwarf_rip_x86_64, dwarf_rip_x86_64,
+ LLDB_REGNUM_GENERIC_PC, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(rflags, "flags", dwarf_rflags_x86_64, dwarf_rflags_x86_64,
+ LLDB_REGNUM_GENERIC_FLAGS, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(cs, nullptr, dwarf_cs_x86_64, dwarf_cs_x86_64,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(fs, nullptr, dwarf_fs_x86_64, dwarf_fs_x86_64,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(gs, nullptr, dwarf_gs_x86_64, dwarf_gs_x86_64,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(ss, nullptr, dwarf_ss_x86_64, dwarf_ss_x86_64,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(ds, nullptr, dwarf_ds_x86_64, dwarf_ds_x86_64,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_GPR(es, nullptr, dwarf_es_x86_64, dwarf_es_x86_64,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+
+ DEFINE_GPR_PSEUDO_32(eax, rax), DEFINE_GPR_PSEUDO_32(ebx, rbx),
+ DEFINE_GPR_PSEUDO_32(ecx, rcx), DEFINE_GPR_PSEUDO_32(edx, rdx),
+ DEFINE_GPR_PSEUDO_32(edi, rdi), DEFINE_GPR_PSEUDO_32(esi, rsi),
+ DEFINE_GPR_PSEUDO_32(ebp, rbp), DEFINE_GPR_PSEUDO_32(esp, rsp),
+ DEFINE_GPR_PSEUDO_32(r8d, r8), DEFINE_GPR_PSEUDO_32(r9d, r9),
+ DEFINE_GPR_PSEUDO_32(r10d, r10), DEFINE_GPR_PSEUDO_32(r11d, r11),
+ DEFINE_GPR_PSEUDO_32(r12d, r12), DEFINE_GPR_PSEUDO_32(r13d, r13),
+ DEFINE_GPR_PSEUDO_32(r14d, r14), DEFINE_GPR_PSEUDO_32(r15d, r15),
+ DEFINE_GPR_PSEUDO_16(ax, rax), DEFINE_GPR_PSEUDO_16(bx, rbx),
+ DEFINE_GPR_PSEUDO_16(cx, rcx), DEFINE_GPR_PSEUDO_16(dx, rdx),
+ DEFINE_GPR_PSEUDO_16(di, rdi), DEFINE_GPR_PSEUDO_16(si, rsi),
+ DEFINE_GPR_PSEUDO_16(bp, rbp), DEFINE_GPR_PSEUDO_16(sp, rsp),
+ DEFINE_GPR_PSEUDO_16(r8w, r8), DEFINE_GPR_PSEUDO_16(r9w, r9),
+ DEFINE_GPR_PSEUDO_16(r10w, r10), DEFINE_GPR_PSEUDO_16(r11w, r11),
+ DEFINE_GPR_PSEUDO_16(r12w, r12), DEFINE_GPR_PSEUDO_16(r13w, r13),
+ DEFINE_GPR_PSEUDO_16(r14w, r14), DEFINE_GPR_PSEUDO_16(r15w, r15),
+ DEFINE_GPR_PSEUDO_8H(ah, rax), DEFINE_GPR_PSEUDO_8H(bh, rbx),
+ DEFINE_GPR_PSEUDO_8H(ch, rcx), DEFINE_GPR_PSEUDO_8H(dh, rdx),
+ DEFINE_GPR_PSEUDO_8L(al, rax), DEFINE_GPR_PSEUDO_8L(bl, rbx),
+ DEFINE_GPR_PSEUDO_8L(cl, rcx), DEFINE_GPR_PSEUDO_8L(dl, rdx),
+ DEFINE_GPR_PSEUDO_8L(dil, rdi), DEFINE_GPR_PSEUDO_8L(sil, rsi),
+ DEFINE_GPR_PSEUDO_8L(bpl, rbp), DEFINE_GPR_PSEUDO_8L(spl, rsp),
+ DEFINE_GPR_PSEUDO_8L(r8l, r8), DEFINE_GPR_PSEUDO_8L(r9l, r9),
+ DEFINE_GPR_PSEUDO_8L(r10l, r10), DEFINE_GPR_PSEUDO_8L(r11l, r11),
+ DEFINE_GPR_PSEUDO_8L(r12l, r12), DEFINE_GPR_PSEUDO_8L(r13l, r13),
+ DEFINE_GPR_PSEUDO_8L(r14l, r14), DEFINE_GPR_PSEUDO_8L(r15l, r15),
+
+ // i387 Floating point registers. EH_frame,
+ // DWARF, Generic, Process Plugin
+ DEFINE_FPR(fctrl, fctrl, dwarf_fctrl_x86_64, dwarf_fctrl_x86_64,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_FPR(fstat, fstat, dwarf_fstat_x86_64, dwarf_fstat_x86_64,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_FPR(ftag, ftag, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_FPR(fop, fop, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_FPR(fiseg, ptr.i386_.fiseg, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_FPR(fioff, ptr.i386_.fioff, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_FPR(foseg, ptr.i386_.foseg, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_FPR(fooff, ptr.i386_.fooff, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_FPR(mxcsr, mxcsr, dwarf_mxcsr_x86_64, dwarf_mxcsr_x86_64,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
+ DEFINE_FPR(mxcsrmask, mxcsrmask, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
// FP registers.
- DEFINE_FP_ST(st, 0),
- DEFINE_FP_ST(st, 1),
- DEFINE_FP_ST(st, 2),
- DEFINE_FP_ST(st, 3),
- DEFINE_FP_ST(st, 4),
- DEFINE_FP_ST(st, 5),
- DEFINE_FP_ST(st, 6),
- DEFINE_FP_ST(st, 7),
- DEFINE_FP_MM(mm, 0),
- DEFINE_FP_MM(mm, 1),
- DEFINE_FP_MM(mm, 2),
- DEFINE_FP_MM(mm, 3),
- DEFINE_FP_MM(mm, 4),
- DEFINE_FP_MM(mm, 5),
- DEFINE_FP_MM(mm, 6),
+ DEFINE_FP_ST(st, 0), DEFINE_FP_ST(st, 1), DEFINE_FP_ST(st, 2),
+ DEFINE_FP_ST(st, 3), DEFINE_FP_ST(st, 4), DEFINE_FP_ST(st, 5),
+ DEFINE_FP_ST(st, 6), DEFINE_FP_ST(st, 7), DEFINE_FP_MM(mm, 0),
+ DEFINE_FP_MM(mm, 1), DEFINE_FP_MM(mm, 2), DEFINE_FP_MM(mm, 3),
+ DEFINE_FP_MM(mm, 4), DEFINE_FP_MM(mm, 5), DEFINE_FP_MM(mm, 6),
DEFINE_FP_MM(mm, 7),
// XMM registers
- DEFINE_XMM(xmm, 0),
- DEFINE_XMM(xmm, 1),
- DEFINE_XMM(xmm, 2),
- DEFINE_XMM(xmm, 3),
- DEFINE_XMM(xmm, 4),
- DEFINE_XMM(xmm, 5),
- DEFINE_XMM(xmm, 6),
- DEFINE_XMM(xmm, 7),
- DEFINE_XMM(xmm, 8),
- DEFINE_XMM(xmm, 9),
- DEFINE_XMM(xmm, 10),
- DEFINE_XMM(xmm, 11),
- DEFINE_XMM(xmm, 12),
- DEFINE_XMM(xmm, 13),
- DEFINE_XMM(xmm, 14),
+ DEFINE_XMM(xmm, 0), DEFINE_XMM(xmm, 1), DEFINE_XMM(xmm, 2),
+ DEFINE_XMM(xmm, 3), DEFINE_XMM(xmm, 4), DEFINE_XMM(xmm, 5),
+ DEFINE_XMM(xmm, 6), DEFINE_XMM(xmm, 7), DEFINE_XMM(xmm, 8),
+ DEFINE_XMM(xmm, 9), DEFINE_XMM(xmm, 10), DEFINE_XMM(xmm, 11),
+ DEFINE_XMM(xmm, 12), DEFINE_XMM(xmm, 13), DEFINE_XMM(xmm, 14),
DEFINE_XMM(xmm, 15),
// Copy of YMM registers assembled from xmm and ymmh
- DEFINE_YMM(ymm, 0),
- DEFINE_YMM(ymm, 1),
- DEFINE_YMM(ymm, 2),
- DEFINE_YMM(ymm, 3),
- DEFINE_YMM(ymm, 4),
- DEFINE_YMM(ymm, 5),
- DEFINE_YMM(ymm, 6),
- DEFINE_YMM(ymm, 7),
- DEFINE_YMM(ymm, 8),
- DEFINE_YMM(ymm, 9),
- DEFINE_YMM(ymm, 10),
- DEFINE_YMM(ymm, 11),
- DEFINE_YMM(ymm, 12),
- DEFINE_YMM(ymm, 13),
- DEFINE_YMM(ymm, 14),
+ DEFINE_YMM(ymm, 0), DEFINE_YMM(ymm, 1), DEFINE_YMM(ymm, 2),
+ DEFINE_YMM(ymm, 3), DEFINE_YMM(ymm, 4), DEFINE_YMM(ymm, 5),
+ DEFINE_YMM(ymm, 6), DEFINE_YMM(ymm, 7), DEFINE_YMM(ymm, 8),
+ DEFINE_YMM(ymm, 9), DEFINE_YMM(ymm, 10), DEFINE_YMM(ymm, 11),
+ DEFINE_YMM(ymm, 12), DEFINE_YMM(ymm, 13), DEFINE_YMM(ymm, 14),
DEFINE_YMM(ymm, 15),
// Debug registers for lldb internal use
- DEFINE_DR(dr, 0),
- DEFINE_DR(dr, 1),
- DEFINE_DR(dr, 2),
- DEFINE_DR(dr, 3),
- DEFINE_DR(dr, 4),
- DEFINE_DR(dr, 5),
- DEFINE_DR(dr, 6),
- DEFINE_DR(dr, 7)
-};
+ DEFINE_DR(dr, 0), DEFINE_DR(dr, 1), DEFINE_DR(dr, 2), DEFINE_DR(dr, 3),
+ DEFINE_DR(dr, 4), DEFINE_DR(dr, 5), DEFINE_DR(dr, 6), DEFINE_DR(dr, 7)};
-static_assert((sizeof(g_register_infos_x86_64) / sizeof(g_register_infos_x86_64[0])) == k_num_registers_x86_64,
- "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,
+ "g_register_infos_x86_64 has wrong number of register infos");
#undef FPR_SIZE
#undef FP_SIZE
@@ -284,130 +315,131 @@ static_assert((sizeof(g_register_infos_x
#ifdef UPDATE_REGISTER_INFOS_I386_STRUCT_WITH_X86_64_OFFSETS
-#define UPDATE_GPR_INFO(reg, reg64) \
-do { \
- g_register_infos[lldb_##reg##_i386].byte_offset = GPR_OFFSET(reg64); \
-} while(false);
-
-#define UPDATE_GPR_INFO_8H(reg, reg64) \
-do { \
- g_register_infos[lldb_##reg##_i386].byte_offset = GPR_OFFSET(reg64) + 1; \
-} while(false);
-
-#define UPDATE_FPR_INFO(reg, reg64) \
-do { \
- g_register_infos[lldb_##reg##_i386].byte_offset = FPR_OFFSET(reg64); \
-} while(false);
-
-#define UPDATE_FP_INFO(reg, i) \
-do { \
- g_register_infos[lldb_##reg##i##_i386].byte_offset = FPR_OFFSET(stmm[i]); \
-} while(false);
-
-#define UPDATE_XMM_INFO(reg, i) \
-do { \
- g_register_infos[lldb_##reg##i##_i386].byte_offset = FPR_OFFSET(reg[i]); \
-} while(false);
-
-#define UPDATE_YMM_INFO(reg, i) \
-do { \
- g_register_infos[lldb_##reg##i##_i386].byte_offset = YMM_OFFSET(i); \
-} while(false);
-
-#define UPDATE_DR_INFO(reg_index) \
-do { \
- g_register_infos[lldb_dr##reg_index##_i386].byte_offset = DR_OFFSET(reg_index); \
-} while(false);
-
- // Update the register offsets
- UPDATE_GPR_INFO(eax, rax);
- UPDATE_GPR_INFO(ebx, rbx);
- UPDATE_GPR_INFO(ecx, rcx);
- UPDATE_GPR_INFO(edx, rdx);
- UPDATE_GPR_INFO(edi, rdi);
- UPDATE_GPR_INFO(esi, rsi);
- UPDATE_GPR_INFO(ebp, rbp);
- UPDATE_GPR_INFO(esp, rsp);
- UPDATE_GPR_INFO(eip, rip);
- UPDATE_GPR_INFO(eflags, rflags);
- UPDATE_GPR_INFO(cs, cs);
- UPDATE_GPR_INFO(fs, fs);
- UPDATE_GPR_INFO(gs, gs);
- UPDATE_GPR_INFO(ss, ss);
- UPDATE_GPR_INFO(ds, ds);
- UPDATE_GPR_INFO(es, es);
-
- UPDATE_GPR_INFO(ax, rax);
- UPDATE_GPR_INFO(bx, rbx);
- UPDATE_GPR_INFO(cx, rcx);
- UPDATE_GPR_INFO(dx, rdx);
- UPDATE_GPR_INFO(di, rdi);
- UPDATE_GPR_INFO(si, rsi);
- UPDATE_GPR_INFO(bp, rbp);
- UPDATE_GPR_INFO(sp, rsp);
- UPDATE_GPR_INFO_8H(ah, rax);
- UPDATE_GPR_INFO_8H(bh, rbx);
- UPDATE_GPR_INFO_8H(ch, rcx);
- UPDATE_GPR_INFO_8H(dh, rdx);
- UPDATE_GPR_INFO(al, rax);
- UPDATE_GPR_INFO(bl, rbx);
- UPDATE_GPR_INFO(cl, rcx);
- UPDATE_GPR_INFO(dl, rdx);
-
- UPDATE_FPR_INFO(fctrl, fctrl);
- UPDATE_FPR_INFO(fstat, fstat);
- UPDATE_FPR_INFO(ftag, ftag);
- UPDATE_FPR_INFO(fop, fop);
- UPDATE_FPR_INFO(fiseg, ptr.i386_.fiseg);
- UPDATE_FPR_INFO(fioff, ptr.i386_.fioff);
- UPDATE_FPR_INFO(fooff, ptr.i386_.fooff);
- UPDATE_FPR_INFO(foseg, ptr.i386_.foseg);
- UPDATE_FPR_INFO(mxcsr, mxcsr);
- UPDATE_FPR_INFO(mxcsrmask, mxcsrmask);
-
- UPDATE_FP_INFO(st, 0);
- UPDATE_FP_INFO(st, 1);
- UPDATE_FP_INFO(st, 2);
- UPDATE_FP_INFO(st, 3);
- UPDATE_FP_INFO(st, 4);
- UPDATE_FP_INFO(st, 5);
- UPDATE_FP_INFO(st, 6);
- UPDATE_FP_INFO(st, 7);
- UPDATE_FP_INFO(mm, 0);
- UPDATE_FP_INFO(mm, 1);
- UPDATE_FP_INFO(mm, 2);
- UPDATE_FP_INFO(mm, 3);
- UPDATE_FP_INFO(mm, 4);
- UPDATE_FP_INFO(mm, 5);
- UPDATE_FP_INFO(mm, 6);
- UPDATE_FP_INFO(mm, 7);
-
- UPDATE_XMM_INFO(xmm, 0);
- UPDATE_XMM_INFO(xmm, 1);
- UPDATE_XMM_INFO(xmm, 2);
- UPDATE_XMM_INFO(xmm, 3);
- UPDATE_XMM_INFO(xmm, 4);
- UPDATE_XMM_INFO(xmm, 5);
- UPDATE_XMM_INFO(xmm, 6);
- UPDATE_XMM_INFO(xmm, 7);
-
- UPDATE_YMM_INFO(ymm, 0);
- UPDATE_YMM_INFO(ymm, 1);
- UPDATE_YMM_INFO(ymm, 2);
- UPDATE_YMM_INFO(ymm, 3);
- UPDATE_YMM_INFO(ymm, 4);
- UPDATE_YMM_INFO(ymm, 5);
- UPDATE_YMM_INFO(ymm, 6);
- UPDATE_YMM_INFO(ymm, 7);
-
- UPDATE_DR_INFO(0);
- UPDATE_DR_INFO(1);
- UPDATE_DR_INFO(2);
- UPDATE_DR_INFO(3);
- UPDATE_DR_INFO(4);
- UPDATE_DR_INFO(5);
- UPDATE_DR_INFO(6);
- UPDATE_DR_INFO(7);
+#define UPDATE_GPR_INFO(reg, reg64) \
+ do { \
+ g_register_infos[lldb_##reg##_i386].byte_offset = GPR_OFFSET(reg64); \
+ } while (false);
+
+#define UPDATE_GPR_INFO_8H(reg, reg64) \
+ do { \
+ g_register_infos[lldb_##reg##_i386].byte_offset = GPR_OFFSET(reg64) + 1; \
+ } while (false);
+
+#define UPDATE_FPR_INFO(reg, reg64) \
+ do { \
+ g_register_infos[lldb_##reg##_i386].byte_offset = FPR_OFFSET(reg64); \
+ } while (false);
+
+#define UPDATE_FP_INFO(reg, i) \
+ do { \
+ g_register_infos[lldb_##reg##i##_i386].byte_offset = FPR_OFFSET(stmm[i]); \
+ } while (false);
+
+#define UPDATE_XMM_INFO(reg, i) \
+ do { \
+ g_register_infos[lldb_##reg##i##_i386].byte_offset = FPR_OFFSET(reg[i]); \
+ } while (false);
+
+#define UPDATE_YMM_INFO(reg, i) \
+ do { \
+ g_register_infos[lldb_##reg##i##_i386].byte_offset = YMM_OFFSET(i); \
+ } while (false);
+
+#define UPDATE_DR_INFO(reg_index) \
+ do { \
+ g_register_infos[lldb_dr##reg_index##_i386].byte_offset = \
+ DR_OFFSET(reg_index); \
+ } while (false);
+
+// Update the register offsets
+UPDATE_GPR_INFO(eax, rax);
+UPDATE_GPR_INFO(ebx, rbx);
+UPDATE_GPR_INFO(ecx, rcx);
+UPDATE_GPR_INFO(edx, rdx);
+UPDATE_GPR_INFO(edi, rdi);
+UPDATE_GPR_INFO(esi, rsi);
+UPDATE_GPR_INFO(ebp, rbp);
+UPDATE_GPR_INFO(esp, rsp);
+UPDATE_GPR_INFO(eip, rip);
+UPDATE_GPR_INFO(eflags, rflags);
+UPDATE_GPR_INFO(cs, cs);
+UPDATE_GPR_INFO(fs, fs);
+UPDATE_GPR_INFO(gs, gs);
+UPDATE_GPR_INFO(ss, ss);
+UPDATE_GPR_INFO(ds, ds);
+UPDATE_GPR_INFO(es, es);
+
+UPDATE_GPR_INFO(ax, rax);
+UPDATE_GPR_INFO(bx, rbx);
+UPDATE_GPR_INFO(cx, rcx);
+UPDATE_GPR_INFO(dx, rdx);
+UPDATE_GPR_INFO(di, rdi);
+UPDATE_GPR_INFO(si, rsi);
+UPDATE_GPR_INFO(bp, rbp);
+UPDATE_GPR_INFO(sp, rsp);
+UPDATE_GPR_INFO_8H(ah, rax);
+UPDATE_GPR_INFO_8H(bh, rbx);
+UPDATE_GPR_INFO_8H(ch, rcx);
+UPDATE_GPR_INFO_8H(dh, rdx);
+UPDATE_GPR_INFO(al, rax);
+UPDATE_GPR_INFO(bl, rbx);
+UPDATE_GPR_INFO(cl, rcx);
+UPDATE_GPR_INFO(dl, rdx);
+
+UPDATE_FPR_INFO(fctrl, fctrl);
+UPDATE_FPR_INFO(fstat, fstat);
+UPDATE_FPR_INFO(ftag, ftag);
+UPDATE_FPR_INFO(fop, fop);
+UPDATE_FPR_INFO(fiseg, ptr.i386_.fiseg);
+UPDATE_FPR_INFO(fioff, ptr.i386_.fioff);
+UPDATE_FPR_INFO(fooff, ptr.i386_.fooff);
+UPDATE_FPR_INFO(foseg, ptr.i386_.foseg);
+UPDATE_FPR_INFO(mxcsr, mxcsr);
+UPDATE_FPR_INFO(mxcsrmask, mxcsrmask);
+
+UPDATE_FP_INFO(st, 0);
+UPDATE_FP_INFO(st, 1);
+UPDATE_FP_INFO(st, 2);
+UPDATE_FP_INFO(st, 3);
+UPDATE_FP_INFO(st, 4);
+UPDATE_FP_INFO(st, 5);
+UPDATE_FP_INFO(st, 6);
+UPDATE_FP_INFO(st, 7);
+UPDATE_FP_INFO(mm, 0);
+UPDATE_FP_INFO(mm, 1);
+UPDATE_FP_INFO(mm, 2);
+UPDATE_FP_INFO(mm, 3);
+UPDATE_FP_INFO(mm, 4);
+UPDATE_FP_INFO(mm, 5);
+UPDATE_FP_INFO(mm, 6);
+UPDATE_FP_INFO(mm, 7);
+
+UPDATE_XMM_INFO(xmm, 0);
+UPDATE_XMM_INFO(xmm, 1);
+UPDATE_XMM_INFO(xmm, 2);
+UPDATE_XMM_INFO(xmm, 3);
+UPDATE_XMM_INFO(xmm, 4);
+UPDATE_XMM_INFO(xmm, 5);
+UPDATE_XMM_INFO(xmm, 6);
+UPDATE_XMM_INFO(xmm, 7);
+
+UPDATE_YMM_INFO(ymm, 0);
+UPDATE_YMM_INFO(ymm, 1);
+UPDATE_YMM_INFO(ymm, 2);
+UPDATE_YMM_INFO(ymm, 3);
+UPDATE_YMM_INFO(ymm, 4);
+UPDATE_YMM_INFO(ymm, 5);
+UPDATE_YMM_INFO(ymm, 6);
+UPDATE_YMM_INFO(ymm, 7);
+
+UPDATE_DR_INFO(0);
+UPDATE_DR_INFO(1);
+UPDATE_DR_INFO(2);
+UPDATE_DR_INFO(3);
+UPDATE_DR_INFO(4);
+UPDATE_DR_INFO(5);
+UPDATE_DR_INFO(6);
+UPDATE_DR_INFO(7);
#undef UPDATE_GPR_INFO
#undef UPDATE_GPR_INFO_8H
Modified: lldb/trunk/source/Plugins/Process/Utility/StopInfoMachException.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Utility/StopInfoMachException.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/Utility/StopInfoMachException.cpp (original)
+++ lldb/trunk/source/Plugins/Process/Utility/StopInfoMachException.cpp Tue Sep 6 15:57:50 2016
@@ -28,509 +28,557 @@
using namespace lldb;
using namespace lldb_private;
-
-const char *
-StopInfoMachException::GetDescription ()
-{
- if (m_description.empty() && m_value != 0)
- {
- ExecutionContext exe_ctx (m_thread_wp.lock());
- Target *target = exe_ctx.GetTargetPtr();
- const llvm::Triple::ArchType cpu = target ? target->GetArchitecture().GetMachine() : llvm::Triple::UnknownArch;
-
- const char *exc_desc = NULL;
- const char *code_label = "code";
- const char *code_desc = NULL;
- const char *subcode_label = "subcode";
- const char *subcode_desc = NULL;
- switch (m_value)
- {
- case 1: // EXC_BAD_ACCESS
- exc_desc = "EXC_BAD_ACCESS";
- subcode_label = "address";
- switch (cpu)
- {
- case llvm::Triple::x86:
- case llvm::Triple::x86_64:
- switch (m_exc_code)
- {
- case 0xd: code_desc = "EXC_I386_GPFLT"; m_exc_data_count = 1; break;
- }
- break;
- case llvm::Triple::arm:
- case llvm::Triple::thumb:
- switch (m_exc_code)
- {
- case 0x101: code_desc = "EXC_ARM_DA_ALIGN"; break;
- case 0x102: code_desc = "EXC_ARM_DA_DEBUG"; break;
- }
- break;
-
- case llvm::Triple::ppc:
- case llvm::Triple::ppc64:
- switch (m_exc_code)
- {
- case 0x101: code_desc = "EXC_PPC_VM_PROT_READ"; break;
- case 0x102: code_desc = "EXC_PPC_BADSPACE"; break;
- case 0x103: code_desc = "EXC_PPC_UNALIGNED"; break;
- }
- break;
- default:
- break;
- }
- break;
+const char *StopInfoMachException::GetDescription() {
+ if (m_description.empty() && m_value != 0) {
+ ExecutionContext exe_ctx(m_thread_wp.lock());
+ Target *target = exe_ctx.GetTargetPtr();
+ const llvm::Triple::ArchType cpu =
+ target ? target->GetArchitecture().GetMachine()
+ : llvm::Triple::UnknownArch;
+
+ const char *exc_desc = NULL;
+ const char *code_label = "code";
+ const char *code_desc = NULL;
+ const char *subcode_label = "subcode";
+ const char *subcode_desc = NULL;
+ switch (m_value) {
+ case 1: // EXC_BAD_ACCESS
+ exc_desc = "EXC_BAD_ACCESS";
+ subcode_label = "address";
+ switch (cpu) {
+ case llvm::Triple::x86:
+ case llvm::Triple::x86_64:
+ switch (m_exc_code) {
+ case 0xd:
+ code_desc = "EXC_I386_GPFLT";
+ m_exc_data_count = 1;
+ break;
+ }
+ break;
+ case llvm::Triple::arm:
+ case llvm::Triple::thumb:
+ switch (m_exc_code) {
+ case 0x101:
+ code_desc = "EXC_ARM_DA_ALIGN";
+ break;
+ case 0x102:
+ code_desc = "EXC_ARM_DA_DEBUG";
+ break;
+ }
+ break;
- case 2: // EXC_BAD_INSTRUCTION
- exc_desc = "EXC_BAD_INSTRUCTION";
- switch (cpu)
- {
- case llvm::Triple::x86:
- case llvm::Triple::x86_64:
- if (m_exc_code == 1)
- code_desc = "EXC_I386_INVOP";
- break;
-
- case llvm::Triple::ppc:
- case llvm::Triple::ppc64:
- switch (m_exc_code)
- {
- case 1: code_desc = "EXC_PPC_INVALID_SYSCALL"; break;
- case 2: code_desc = "EXC_PPC_UNIPL_INST"; break;
- case 3: code_desc = "EXC_PPC_PRIVINST"; break;
- case 4: code_desc = "EXC_PPC_PRIVREG"; break;
- case 5: code_desc = "EXC_PPC_TRACE"; break;
- case 6: code_desc = "EXC_PPC_PERFMON"; break;
- }
- break;
-
- case llvm::Triple::arm:
- case llvm::Triple::thumb:
- if (m_exc_code == 1)
- code_desc = "EXC_ARM_UNDEFINED";
- break;
+ case llvm::Triple::ppc:
+ case llvm::Triple::ppc64:
+ switch (m_exc_code) {
+ case 0x101:
+ code_desc = "EXC_PPC_VM_PROT_READ";
+ break;
+ case 0x102:
+ code_desc = "EXC_PPC_BADSPACE";
+ break;
+ case 0x103:
+ code_desc = "EXC_PPC_UNALIGNED";
+ break;
+ }
+ break;
- default:
- break;
- }
- break;
+ default:
+ break;
+ }
+ break;
+
+ case 2: // EXC_BAD_INSTRUCTION
+ exc_desc = "EXC_BAD_INSTRUCTION";
+ switch (cpu) {
+ case llvm::Triple::x86:
+ case llvm::Triple::x86_64:
+ if (m_exc_code == 1)
+ code_desc = "EXC_I386_INVOP";
+ break;
+
+ case llvm::Triple::ppc:
+ case llvm::Triple::ppc64:
+ switch (m_exc_code) {
+ case 1:
+ code_desc = "EXC_PPC_INVALID_SYSCALL";
+ break;
+ case 2:
+ code_desc = "EXC_PPC_UNIPL_INST";
+ break;
+ case 3:
+ code_desc = "EXC_PPC_PRIVINST";
+ break;
+ case 4:
+ code_desc = "EXC_PPC_PRIVREG";
+ break;
+ case 5:
+ code_desc = "EXC_PPC_TRACE";
+ break;
+ case 6:
+ code_desc = "EXC_PPC_PERFMON";
+ break;
+ }
+ break;
- case 3: // EXC_ARITHMETIC
- exc_desc = "EXC_ARITHMETIC";
- switch (cpu)
- {
- case llvm::Triple::x86:
- case llvm::Triple::x86_64:
- switch (m_exc_code)
- {
- case 1: code_desc = "EXC_I386_DIV"; break;
- case 2: code_desc = "EXC_I386_INTO"; break;
- case 3: code_desc = "EXC_I386_NOEXT"; break;
- case 4: code_desc = "EXC_I386_EXTOVR"; break;
- case 5: code_desc = "EXC_I386_EXTERR"; break;
- case 6: code_desc = "EXC_I386_EMERR"; break;
- case 7: code_desc = "EXC_I386_BOUND"; break;
- case 8: code_desc = "EXC_I386_SSEEXTERR"; break;
- }
- break;
-
- case llvm::Triple::ppc:
- case llvm::Triple::ppc64:
- switch (m_exc_code)
- {
- case 1: code_desc = "EXC_PPC_OVERFLOW"; break;
- case 2: code_desc = "EXC_PPC_ZERO_DIVIDE"; break;
- case 3: code_desc = "EXC_PPC_FLT_INEXACT"; break;
- case 4: code_desc = "EXC_PPC_FLT_ZERO_DIVIDE"; break;
- case 5: code_desc = "EXC_PPC_FLT_UNDERFLOW"; break;
- case 6: code_desc = "EXC_PPC_FLT_OVERFLOW"; break;
- case 7: code_desc = "EXC_PPC_FLT_NOT_A_NUMBER"; break;
- }
- break;
+ case llvm::Triple::arm:
+ case llvm::Triple::thumb:
+ if (m_exc_code == 1)
+ code_desc = "EXC_ARM_UNDEFINED";
+ break;
+
+ default:
+ break;
+ }
+ break;
+
+ case 3: // EXC_ARITHMETIC
+ exc_desc = "EXC_ARITHMETIC";
+ switch (cpu) {
+ case llvm::Triple::x86:
+ case llvm::Triple::x86_64:
+ switch (m_exc_code) {
+ case 1:
+ code_desc = "EXC_I386_DIV";
+ break;
+ case 2:
+ code_desc = "EXC_I386_INTO";
+ break;
+ case 3:
+ code_desc = "EXC_I386_NOEXT";
+ break;
+ case 4:
+ code_desc = "EXC_I386_EXTOVR";
+ break;
+ case 5:
+ code_desc = "EXC_I386_EXTERR";
+ break;
+ case 6:
+ code_desc = "EXC_I386_EMERR";
+ break;
+ case 7:
+ code_desc = "EXC_I386_BOUND";
+ break;
+ case 8:
+ code_desc = "EXC_I386_SSEEXTERR";
+ break;
+ }
+ break;
- default:
- break;
- }
- break;
+ case llvm::Triple::ppc:
+ case llvm::Triple::ppc64:
+ switch (m_exc_code) {
+ case 1:
+ code_desc = "EXC_PPC_OVERFLOW";
+ break;
+ case 2:
+ code_desc = "EXC_PPC_ZERO_DIVIDE";
+ break;
+ case 3:
+ code_desc = "EXC_PPC_FLT_INEXACT";
+ break;
+ case 4:
+ code_desc = "EXC_PPC_FLT_ZERO_DIVIDE";
+ break;
+ case 5:
+ code_desc = "EXC_PPC_FLT_UNDERFLOW";
+ break;
+ case 6:
+ code_desc = "EXC_PPC_FLT_OVERFLOW";
+ break;
+ case 7:
+ code_desc = "EXC_PPC_FLT_NOT_A_NUMBER";
+ break;
+ }
+ break;
- case 4: // EXC_EMULATION
- exc_desc = "EXC_EMULATION";
- break;
+ default:
+ break;
+ }
+ break;
+
+ case 4: // EXC_EMULATION
+ exc_desc = "EXC_EMULATION";
+ break;
+
+ case 5: // EXC_SOFTWARE
+ exc_desc = "EXC_SOFTWARE";
+ if (m_exc_code == 0x10003) {
+ subcode_desc = "EXC_SOFT_SIGNAL";
+ subcode_label = "signo";
+ }
+ break;
+ case 6: // EXC_BREAKPOINT
+ {
+ exc_desc = "EXC_BREAKPOINT";
+ switch (cpu) {
+ case llvm::Triple::x86:
+ case llvm::Triple::x86_64:
+ switch (m_exc_code) {
+ case 1:
+ code_desc = "EXC_I386_SGL";
+ break;
+ case 2:
+ code_desc = "EXC_I386_BPT";
+ break;
+ }
+ break;
- case 5: // EXC_SOFTWARE
- exc_desc = "EXC_SOFTWARE";
- if (m_exc_code == 0x10003)
- {
- subcode_desc = "EXC_SOFT_SIGNAL";
- subcode_label = "signo";
- }
- break;
-
- case 6: // EXC_BREAKPOINT
- {
- exc_desc = "EXC_BREAKPOINT";
- switch (cpu)
- {
- case llvm::Triple::x86:
- case llvm::Triple::x86_64:
- switch (m_exc_code)
- {
- case 1: code_desc = "EXC_I386_SGL"; break;
- case 2: code_desc = "EXC_I386_BPT"; break;
- }
- break;
-
- case llvm::Triple::ppc:
- case llvm::Triple::ppc64:
- switch (m_exc_code)
- {
- case 1: code_desc = "EXC_PPC_BREAKPOINT"; break;
- }
- break;
-
- case llvm::Triple::arm:
- case llvm::Triple::thumb:
- switch (m_exc_code)
- {
- case 0x101: code_desc = "EXC_ARM_DA_ALIGN"; break;
- case 0x102: code_desc = "EXC_ARM_DA_DEBUG"; break;
- case 1: code_desc = "EXC_ARM_BREAKPOINT"; break;
- // FIXME temporary workaround, exc_code 0 does not really mean EXC_ARM_BREAKPOINT
- case 0: code_desc = "EXC_ARM_BREAKPOINT"; break;
- }
- break;
-
- default:
- break;
- }
- }
- break;
+ case llvm::Triple::ppc:
+ case llvm::Triple::ppc64:
+ switch (m_exc_code) {
+ case 1:
+ code_desc = "EXC_PPC_BREAKPOINT";
+ break;
+ }
+ break;
- case 7:
- exc_desc = "EXC_SYSCALL";
- break;
+ case llvm::Triple::arm:
+ case llvm::Triple::thumb:
+ switch (m_exc_code) {
+ case 0x101:
+ code_desc = "EXC_ARM_DA_ALIGN";
+ break;
+ case 0x102:
+ code_desc = "EXC_ARM_DA_DEBUG";
+ break;
+ case 1:
+ code_desc = "EXC_ARM_BREAKPOINT";
+ break;
+ // FIXME temporary workaround, exc_code 0 does not really mean
+ // EXC_ARM_BREAKPOINT
+ case 0:
+ code_desc = "EXC_ARM_BREAKPOINT";
+ break;
+ }
+ break;
- case 8:
- exc_desc = "EXC_MACH_SYSCALL";
- break;
+ default:
+ break;
+ }
+ } break;
+
+ case 7:
+ exc_desc = "EXC_SYSCALL";
+ break;
+
+ case 8:
+ exc_desc = "EXC_MACH_SYSCALL";
+ break;
+
+ case 9:
+ exc_desc = "EXC_RPC_ALERT";
+ break;
+
+ case 10:
+ exc_desc = "EXC_CRASH";
+ break;
+ case 11:
+ exc_desc = "EXC_RESOURCE";
+ break;
+ case 12:
+ exc_desc = "EXC_GUARD";
+ break;
+ }
- case 9:
- exc_desc = "EXC_RPC_ALERT";
- break;
-
- case 10:
- exc_desc = "EXC_CRASH";
- break;
- case 11:
- exc_desc = "EXC_RESOURCE";
- break;
- case 12:
- exc_desc = "EXC_GUARD";
- break;
- }
-
- StreamString strm;
-
- if (exc_desc)
- strm.PutCString(exc_desc);
- else
- strm.Printf("EXC_??? (%" PRIu64 ")", m_value);
+ StreamString strm;
- if (m_exc_data_count >= 1)
- {
- if (code_desc)
- strm.Printf(" (%s=%s", code_label, code_desc);
- else
- strm.Printf(" (%s=%" PRIu64, code_label, m_exc_code);
- }
+ if (exc_desc)
+ strm.PutCString(exc_desc);
+ else
+ strm.Printf("EXC_??? (%" PRIu64 ")", m_value);
+
+ if (m_exc_data_count >= 1) {
+ if (code_desc)
+ strm.Printf(" (%s=%s", code_label, code_desc);
+ else
+ strm.Printf(" (%s=%" PRIu64, code_label, m_exc_code);
+ }
- if (m_exc_data_count >= 2)
- {
- if (subcode_desc)
- strm.Printf(", %s=%s", subcode_label, subcode_desc);
- else
- strm.Printf(", %s=0x%" PRIx64, subcode_label, m_exc_subcode);
- }
-
- if (m_exc_data_count > 0)
- strm.PutChar(')');
-
- m_description.swap (strm.GetString());
+ if (m_exc_data_count >= 2) {
+ if (subcode_desc)
+ strm.Printf(", %s=%s", subcode_label, subcode_desc);
+ else
+ strm.Printf(", %s=0x%" PRIx64, subcode_label, m_exc_subcode);
}
- return m_description.c_str();
-}
+ if (m_exc_data_count > 0)
+ strm.PutChar(')');
+ m_description.swap(strm.GetString());
+ }
+ return m_description.c_str();
+}
+StopInfoSP StopInfoMachException::CreateStopReasonWithMachException(
+ Thread &thread, uint32_t exc_type, uint32_t exc_data_count,
+ uint64_t exc_code, uint64_t exc_sub_code, uint64_t exc_sub_sub_code,
+ bool pc_already_adjusted, bool adjust_pc_if_needed) {
+ if (exc_type != 0) {
+ uint32_t pc_decrement = 0;
+ ExecutionContext exe_ctx(thread.shared_from_this());
+ Target *target = exe_ctx.GetTargetPtr();
+ const llvm::Triple::ArchType cpu =
+ target ? target->GetArchitecture().GetMachine()
+ : llvm::Triple::UnknownArch;
+
+ switch (exc_type) {
+ case 1: // EXC_BAD_ACCESS
+ break;
+
+ case 2: // EXC_BAD_INSTRUCTION
+ switch (cpu) {
+ case llvm::Triple::ppc:
+ case llvm::Triple::ppc64:
+ switch (exc_code) {
+ case 1: // EXC_PPC_INVALID_SYSCALL
+ case 2: // EXC_PPC_UNIPL_INST
+ case 3: // EXC_PPC_PRIVINST
+ case 4: // EXC_PPC_PRIVREG
+ break;
+ case 5: // EXC_PPC_TRACE
+ return StopInfo::CreateStopReasonToTrace(thread);
+ case 6: // EXC_PPC_PERFMON
+ break;
+ }
+ break;
+ default:
+ break;
+ }
+ break;
+
+ case 3: // EXC_ARITHMETIC
+ case 4: // EXC_EMULATION
+ break;
+
+ case 5: // EXC_SOFTWARE
+ if (exc_code == 0x10003) // EXC_SOFT_SIGNAL
+ {
+ if (exc_sub_code == 5) {
+ // On MacOSX, a SIGTRAP can signify that a process has called
+ // exec, so we should check with our dynamic loader to verify.
+ ProcessSP process_sp(thread.GetProcess());
+ if (process_sp) {
+ DynamicLoader *dynamic_loader = process_sp->GetDynamicLoader();
+ if (dynamic_loader && dynamic_loader->ProcessDidExec()) {
+ // The program was re-exec'ed
+ return StopInfo::CreateStopReasonWithExec(thread);
+ }
+ // if (!process_did_exec)
+ // {
+ // // We have a SIGTRAP, make sure we
+ // didn't exec by checking
+ // // for the PC being at
+ // "_dyld_start"...
+ // lldb::StackFrameSP frame_sp
+ // (thread.GetStackFrameAtIndex(0));
+ // if (frame_sp)
+ // {
+ // const Symbol *symbol =
+ // frame_sp->GetSymbolContext(eSymbolContextSymbol).symbol;
+ // if (symbol)
+ // {
+ // if (symbol->GetName() ==
+ // ConstString("_dyld_start"))
+ // process_did_exec = true;
+ // }
+ // }
+ // }
+ }
+ }
+ return StopInfo::CreateStopReasonWithSignal(thread, exc_sub_code);
+ }
+ break;
-StopInfoSP
-StopInfoMachException::CreateStopReasonWithMachException
-(
- Thread &thread,
- uint32_t exc_type,
- uint32_t exc_data_count,
- uint64_t exc_code,
- uint64_t exc_sub_code,
- uint64_t exc_sub_sub_code,
- bool pc_already_adjusted,
- bool adjust_pc_if_needed
-)
-{
- if (exc_type != 0)
+ case 6: // EXC_BREAKPOINT
{
- uint32_t pc_decrement = 0;
- ExecutionContext exe_ctx (thread.shared_from_this());
- Target *target = exe_ctx.GetTargetPtr();
- const llvm::Triple::ArchType cpu = target ? target->GetArchitecture().GetMachine() : llvm::Triple::UnknownArch;
-
- switch (exc_type)
+ bool is_actual_breakpoint = false;
+ bool is_trace_if_actual_breakpoint_missing = false;
+ switch (cpu) {
+ case llvm::Triple::x86:
+ case llvm::Triple::x86_64:
+ if (exc_code == 1) // EXC_I386_SGL
{
- case 1: // EXC_BAD_ACCESS
- break;
-
- case 2: // EXC_BAD_INSTRUCTION
- switch (cpu)
- {
- case llvm::Triple::ppc:
- case llvm::Triple::ppc64:
- switch (exc_code)
- {
- case 1: // EXC_PPC_INVALID_SYSCALL
- case 2: // EXC_PPC_UNIPL_INST
- case 3: // EXC_PPC_PRIVINST
- case 4: // EXC_PPC_PRIVREG
- break;
- case 5: // EXC_PPC_TRACE
- return StopInfo::CreateStopReasonToTrace (thread);
- case 6: // EXC_PPC_PERFMON
- break;
- }
- break;
-
- default:
- break;
+ if (!exc_sub_code) {
+ // This looks like a plain trap.
+ // Have to check if there is a breakpoint here as well. When you
+ // single-step onto a trap,
+ // the single step stops you not to trap. Since we also do that
+ // check below, let's just use
+ // that logic.
+ is_actual_breakpoint = true;
+ is_trace_if_actual_breakpoint_missing = true;
+ } else {
+
+ // It's a watchpoint, then.
+ // The exc_sub_code indicates the data break address.
+ lldb::WatchpointSP wp_sp;
+ if (target)
+ wp_sp = target->GetWatchpointList().FindByAddress(
+ (lldb::addr_t)exc_sub_code);
+ if (wp_sp && wp_sp->IsEnabled()) {
+ // Debugserver may piggyback the hardware index of the fired
+ // watchpoint in the exception data.
+ // Set the hardware index if that's the case.
+ if (exc_data_count >= 3)
+ wp_sp->SetHardwareIndex((uint32_t)exc_sub_sub_code);
+ return StopInfo::CreateStopReasonWithWatchpointID(thread,
+ wp_sp->GetID());
}
- break;
+ }
+ } else if (exc_code == 2 || // EXC_I386_BPT
+ exc_code == 3) // EXC_I386_BPTFLT
+ {
+ // KDP returns EXC_I386_BPTFLT for trace breakpoints
+ if (exc_code == 3)
+ is_trace_if_actual_breakpoint_missing = true;
+
+ is_actual_breakpoint = true;
+ if (!pc_already_adjusted)
+ pc_decrement = 1;
+ }
+ break;
- case 3: // EXC_ARITHMETIC
- case 4: // EXC_EMULATION
- break;
-
- case 5: // EXC_SOFTWARE
- if (exc_code == 0x10003) // EXC_SOFT_SIGNAL
- {
- if (exc_sub_code == 5)
- {
- // On MacOSX, a SIGTRAP can signify that a process has called
- // exec, so we should check with our dynamic loader to verify.
- ProcessSP process_sp (thread.GetProcess());
- if (process_sp)
- {
- DynamicLoader *dynamic_loader = process_sp->GetDynamicLoader();
- if (dynamic_loader && dynamic_loader->ProcessDidExec())
- {
- // The program was re-exec'ed
- return StopInfo::CreateStopReasonWithExec (thread);
- }
-// if (!process_did_exec)
-// {
-// // We have a SIGTRAP, make sure we didn't exec by checking
-// // for the PC being at "_dyld_start"...
-// lldb::StackFrameSP frame_sp (thread.GetStackFrameAtIndex(0));
-// if (frame_sp)
-// {
-// const Symbol *symbol = frame_sp->GetSymbolContext(eSymbolContextSymbol).symbol;
-// if (symbol)
-// {
-// if (symbol->GetName() == ConstString("_dyld_start"))
-// process_did_exec = true;
-// }
-// }
-// }
- }
- }
- return StopInfo::CreateStopReasonWithSignal (thread, exc_sub_code);
- }
- break;
-
- case 6: // EXC_BREAKPOINT
- {
- bool is_actual_breakpoint = false;
- bool is_trace_if_actual_breakpoint_missing = false;
- switch (cpu)
- {
- case llvm::Triple::x86:
- case llvm::Triple::x86_64:
- if (exc_code == 1) // EXC_I386_SGL
- {
- if (!exc_sub_code)
- {
- // This looks like a plain trap.
- // Have to check if there is a breakpoint here as well. When you single-step onto a trap,
- // the single step stops you not to trap. Since we also do that check below, let's just use
- // that logic.
- is_actual_breakpoint = true;
- is_trace_if_actual_breakpoint_missing = true;
- }
- else
- {
-
- // It's a watchpoint, then.
- // The exc_sub_code indicates the data break address.
- lldb::WatchpointSP wp_sp;
- if (target)
- wp_sp = target->GetWatchpointList().FindByAddress((lldb::addr_t)exc_sub_code);
- if (wp_sp && wp_sp->IsEnabled())
- {
- // Debugserver may piggyback the hardware index of the fired watchpoint in the exception data.
- // Set the hardware index if that's the case.
- if (exc_data_count >=3)
- wp_sp->SetHardwareIndex((uint32_t)exc_sub_sub_code);
- return StopInfo::CreateStopReasonWithWatchpointID(thread, wp_sp->GetID());
- }
- }
- }
- else if (exc_code == 2 || // EXC_I386_BPT
- exc_code == 3) // EXC_I386_BPTFLT
- {
- // KDP returns EXC_I386_BPTFLT for trace breakpoints
- if (exc_code == 3)
- is_trace_if_actual_breakpoint_missing = true;
-
- is_actual_breakpoint = true;
- if (!pc_already_adjusted)
- pc_decrement = 1;
- }
- break;
-
- case llvm::Triple::ppc:
- case llvm::Triple::ppc64:
- is_actual_breakpoint = exc_code == 1; // EXC_PPC_BREAKPOINT
- break;
-
- case llvm::Triple::arm:
- case llvm::Triple::thumb:
- if (exc_code == 0x102) // EXC_ARM_DA_DEBUG
- {
- // It's a watchpoint, then, if the exc_sub_code indicates a known/enabled
- // data break address from our watchpoint list.
- lldb::WatchpointSP wp_sp;
- if (target)
- wp_sp = target->GetWatchpointList().FindByAddress((lldb::addr_t)exc_sub_code);
- if (wp_sp && wp_sp->IsEnabled())
- {
- // Debugserver may piggyback the hardware index of the fired watchpoint in the exception data.
- // Set the hardware index if that's the case.
- if (exc_data_count >=3)
- wp_sp->SetHardwareIndex((uint32_t)exc_sub_sub_code);
- return StopInfo::CreateStopReasonWithWatchpointID(thread, wp_sp->GetID());
- }
- else
- {
- is_actual_breakpoint = true;
- is_trace_if_actual_breakpoint_missing = true;
- }
- }
- else if (exc_code == 1) // EXC_ARM_BREAKPOINT
- {
- is_actual_breakpoint = true;
- is_trace_if_actual_breakpoint_missing = true;
- }
- else if (exc_code == 0) // FIXME not EXC_ARM_BREAKPOINT but a kernel is currently returning this so accept it as indicating a breakpoint until the kernel is fixed
- {
- is_actual_breakpoint = true;
- is_trace_if_actual_breakpoint_missing = true;
- }
- break;
-
- case llvm::Triple::aarch64:
- {
- if (exc_code == 1 && exc_sub_code == 0) // EXC_ARM_BREAKPOINT
- {
- // This is hit when we single instruction step aka MDSCR_EL1 SS bit 0 is set
- is_actual_breakpoint = false;
- is_trace_if_actual_breakpoint_missing = true;
- }
- if (exc_code == 0x102) // EXC_ARM_DA_DEBUG
- {
- // It's a watchpoint, then, if the exc_sub_code indicates a known/enabled
- // data break address from our watchpoint list.
- lldb::WatchpointSP wp_sp;
- if (target)
- wp_sp = target->GetWatchpointList().FindByAddress((lldb::addr_t)exc_sub_code);
- if (wp_sp && wp_sp->IsEnabled())
- {
- // Debugserver may piggyback the hardware index of the fired watchpoint in the exception data.
- // Set the hardware index if that's the case.
- if (exc_data_count >= 3)
- wp_sp->SetHardwareIndex((uint32_t)exc_sub_sub_code);
- return StopInfo::CreateStopReasonWithWatchpointID(thread, wp_sp->GetID());
- }
- // EXC_ARM_DA_DEBUG seems to be reused for EXC_BREAKPOINT as well as EXC_BAD_ACCESS
- if (thread.GetTemporaryResumeState() == eStateStepping)
- return StopInfo::CreateStopReasonToTrace(thread);
- }
- // It looks like exc_sub_code has the 4 bytes of the instruction that triggered the
- // exception, i.e. our breakpoint opcode
- is_actual_breakpoint = exc_code == 1;
- break;
- }
-
- default:
- break;
- }
-
- if (is_actual_breakpoint)
- {
- RegisterContextSP reg_ctx_sp (thread.GetRegisterContext());
- addr_t pc = reg_ctx_sp->GetPC() - pc_decrement;
-
- ProcessSP process_sp (thread.CalculateProcess());
-
- lldb::BreakpointSiteSP bp_site_sp;
- if (process_sp)
- bp_site_sp = process_sp->GetBreakpointSiteList().FindByAddress(pc);
- if (bp_site_sp && bp_site_sp->IsEnabled())
- {
- // Update the PC if we were asked to do so, but only do
- // so if we find a breakpoint that we know about cause
- // this could be a trap instruction in the code
- if (pc_decrement > 0 && adjust_pc_if_needed)
- reg_ctx_sp->SetPC (pc);
-
- // If the breakpoint is for this thread, then we'll report the hit, but if it is for another thread,
- // we can just report no reason. We don't need to worry about stepping over the breakpoint here, that
- // will be taken care of when the thread resumes and notices that there's a breakpoint under the pc.
- // If we have an operating system plug-in, we might have set a thread specific breakpoint using the
- // operating system thread ID, so we can't make any assumptions about the thread ID so we must always
- // report the breakpoint regardless of the thread.
- if (bp_site_sp->ValidForThisThread (&thread) || thread.GetProcess()->GetOperatingSystem () != NULL)
- return StopInfo::CreateStopReasonWithBreakpointSiteID (thread, bp_site_sp->GetID());
- else if (is_trace_if_actual_breakpoint_missing)
- return StopInfo::CreateStopReasonToTrace (thread);
- else
- return StopInfoSP();
- }
-
- // Don't call this a trace if we weren't single stepping this thread.
- if (is_trace_if_actual_breakpoint_missing && thread.GetTemporaryResumeState() == eStateStepping)
- {
- return StopInfo::CreateStopReasonToTrace (thread);
- }
- }
- }
- break;
+ case llvm::Triple::ppc:
+ case llvm::Triple::ppc64:
+ is_actual_breakpoint = exc_code == 1; // EXC_PPC_BREAKPOINT
+ break;
+
+ case llvm::Triple::arm:
+ case llvm::Triple::thumb:
+ if (exc_code == 0x102) // EXC_ARM_DA_DEBUG
+ {
+ // It's a watchpoint, then, if the exc_sub_code indicates a
+ // known/enabled
+ // data break address from our watchpoint list.
+ lldb::WatchpointSP wp_sp;
+ if (target)
+ wp_sp = target->GetWatchpointList().FindByAddress(
+ (lldb::addr_t)exc_sub_code);
+ if (wp_sp && wp_sp->IsEnabled()) {
+ // Debugserver may piggyback the hardware index of the fired
+ // watchpoint in the exception data.
+ // Set the hardware index if that's the case.
+ if (exc_data_count >= 3)
+ wp_sp->SetHardwareIndex((uint32_t)exc_sub_sub_code);
+ return StopInfo::CreateStopReasonWithWatchpointID(thread,
+ wp_sp->GetID());
+ } else {
+ is_actual_breakpoint = true;
+ is_trace_if_actual_breakpoint_missing = true;
+ }
+ } else if (exc_code == 1) // EXC_ARM_BREAKPOINT
+ {
+ is_actual_breakpoint = true;
+ is_trace_if_actual_breakpoint_missing = true;
+ } else if (exc_code == 0) // FIXME not EXC_ARM_BREAKPOINT but a kernel
+ // is currently returning this so accept it as
+ // indicating a breakpoint until the kernel is
+ // fixed
+ {
+ is_actual_breakpoint = true;
+ is_trace_if_actual_breakpoint_missing = true;
+ }
+ break;
+
+ case llvm::Triple::aarch64: {
+ if (exc_code == 1 && exc_sub_code == 0) // EXC_ARM_BREAKPOINT
+ {
+ // This is hit when we single instruction step aka MDSCR_EL1 SS bit 0
+ // is set
+ is_actual_breakpoint = false;
+ is_trace_if_actual_breakpoint_missing = true;
+ }
+ if (exc_code == 0x102) // EXC_ARM_DA_DEBUG
+ {
+ // It's a watchpoint, then, if the exc_sub_code indicates a
+ // known/enabled
+ // data break address from our watchpoint list.
+ lldb::WatchpointSP wp_sp;
+ if (target)
+ wp_sp = target->GetWatchpointList().FindByAddress(
+ (lldb::addr_t)exc_sub_code);
+ if (wp_sp && wp_sp->IsEnabled()) {
+ // Debugserver may piggyback the hardware index of the fired
+ // watchpoint in the exception data.
+ // Set the hardware index if that's the case.
+ if (exc_data_count >= 3)
+ wp_sp->SetHardwareIndex((uint32_t)exc_sub_sub_code);
+ return StopInfo::CreateStopReasonWithWatchpointID(thread,
+ wp_sp->GetID());
+ }
+ // EXC_ARM_DA_DEBUG seems to be reused for EXC_BREAKPOINT as well as
+ // EXC_BAD_ACCESS
+ if (thread.GetTemporaryResumeState() == eStateStepping)
+ return StopInfo::CreateStopReasonToTrace(thread);
+ }
+ // It looks like exc_sub_code has the 4 bytes of the instruction that
+ // triggered the
+ // exception, i.e. our breakpoint opcode
+ is_actual_breakpoint = exc_code == 1;
+ break;
+ }
+
+ default:
+ break;
+ }
+
+ if (is_actual_breakpoint) {
+ RegisterContextSP reg_ctx_sp(thread.GetRegisterContext());
+ addr_t pc = reg_ctx_sp->GetPC() - pc_decrement;
+
+ ProcessSP process_sp(thread.CalculateProcess());
+
+ lldb::BreakpointSiteSP bp_site_sp;
+ if (process_sp)
+ bp_site_sp = process_sp->GetBreakpointSiteList().FindByAddress(pc);
+ if (bp_site_sp && bp_site_sp->IsEnabled()) {
+ // Update the PC if we were asked to do so, but only do
+ // so if we find a breakpoint that we know about cause
+ // this could be a trap instruction in the code
+ if (pc_decrement > 0 && adjust_pc_if_needed)
+ reg_ctx_sp->SetPC(pc);
+
+ // If the breakpoint is for this thread, then we'll report the hit,
+ // but if it is for another thread,
+ // we can just report no reason. We don't need to worry about
+ // stepping over the breakpoint here, that
+ // will be taken care of when the thread resumes and notices that
+ // there's a breakpoint under the pc.
+ // If we have an operating system plug-in, we might have set a thread
+ // specific breakpoint using the
+ // operating system thread ID, so we can't make any assumptions about
+ // the thread ID so we must always
+ // report the breakpoint regardless of the thread.
+ if (bp_site_sp->ValidForThisThread(&thread) ||
+ thread.GetProcess()->GetOperatingSystem() != NULL)
+ return StopInfo::CreateStopReasonWithBreakpointSiteID(
+ thread, bp_site_sp->GetID());
+ else if (is_trace_if_actual_breakpoint_missing)
+ return StopInfo::CreateStopReasonToTrace(thread);
+ else
+ return StopInfoSP();
+ }
- case 7: // EXC_SYSCALL
- case 8: // EXC_MACH_SYSCALL
- case 9: // EXC_RPC_ALERT
- case 10: // EXC_CRASH
- break;
+ // Don't call this a trace if we weren't single stepping this thread.
+ if (is_trace_if_actual_breakpoint_missing &&
+ thread.GetTemporaryResumeState() == eStateStepping) {
+ return StopInfo::CreateStopReasonToTrace(thread);
}
-
- return StopInfoSP(new StopInfoMachException (thread, exc_type, exc_data_count, exc_code, exc_sub_code));
+ }
+ } break;
+
+ case 7: // EXC_SYSCALL
+ case 8: // EXC_MACH_SYSCALL
+ case 9: // EXC_RPC_ALERT
+ case 10: // EXC_CRASH
+ break;
}
- return StopInfoSP();
+
+ return StopInfoSP(new StopInfoMachException(
+ thread, exc_type, exc_data_count, exc_code, exc_sub_code));
+ }
+ return StopInfoSP();
}
Modified: lldb/trunk/source/Plugins/Process/Utility/StopInfoMachException.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Utility/StopInfoMachException.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/Utility/StopInfoMachException.h (original)
+++ lldb/trunk/source/Plugins/Process/Utility/StopInfoMachException.h Tue Sep 6 15:57:50 2016
@@ -20,52 +20,37 @@
namespace lldb_private {
-class StopInfoMachException : public StopInfo
-{
+class StopInfoMachException : public StopInfo {
public:
- //------------------------------------------------------------------
- // Constructors and Destructors
- //------------------------------------------------------------------
- StopInfoMachException (Thread &thread,
- uint32_t exc_type,
- uint32_t exc_data_count,
- uint64_t exc_code,
- uint64_t exc_subcode) :
- StopInfo (thread, exc_type),
- m_exc_data_count (exc_data_count),
- m_exc_code (exc_code),
- m_exc_subcode (exc_subcode)
- {
- }
-
- ~StopInfoMachException() override = default;
-
- lldb::StopReason
- GetStopReason() const override
- {
- return lldb::eStopReasonException;
- }
-
- const char *
- GetDescription() override;
-
- // Since some mach exceptions will be reported as breakpoints, signals,
- // or trace, we use this static accessor which will translate the mach
- // exception into the correct StopInfo.
- static lldb::StopInfoSP
- CreateStopReasonWithMachException (Thread &thread,
- uint32_t exc_type,
- uint32_t exc_data_count,
- uint64_t exc_code,
- uint64_t exc_sub_code,
- uint64_t exc_sub_sub_code,
- bool pc_already_adjusted = true,
- bool adjust_pc_if_needed = false);
+ //------------------------------------------------------------------
+ // Constructors and Destructors
+ //------------------------------------------------------------------
+ StopInfoMachException(Thread &thread, uint32_t exc_type,
+ uint32_t exc_data_count, uint64_t exc_code,
+ uint64_t exc_subcode)
+ : StopInfo(thread, exc_type), m_exc_data_count(exc_data_count),
+ m_exc_code(exc_code), m_exc_subcode(exc_subcode) {}
+
+ ~StopInfoMachException() override = default;
+
+ lldb::StopReason GetStopReason() const override {
+ return lldb::eStopReasonException;
+ }
+
+ const char *GetDescription() override;
+
+ // Since some mach exceptions will be reported as breakpoints, signals,
+ // or trace, we use this static accessor which will translate the mach
+ // exception into the correct StopInfo.
+ static lldb::StopInfoSP CreateStopReasonWithMachException(
+ Thread &thread, uint32_t exc_type, uint32_t exc_data_count,
+ uint64_t exc_code, uint64_t exc_sub_code, uint64_t exc_sub_sub_code,
+ bool pc_already_adjusted = true, bool adjust_pc_if_needed = false);
protected:
- uint32_t m_exc_data_count;
- uint64_t m_exc_code;
- uint64_t m_exc_subcode;
+ uint32_t m_exc_data_count;
+ uint64_t m_exc_code;
+ uint64_t m_exc_subcode;
};
} // namespace lldb_private
Modified: lldb/trunk/source/Plugins/Process/Utility/ThreadMemory.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Utility/ThreadMemory.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/Utility/ThreadMemory.cpp (original)
+++ lldb/trunk/source/Plugins/Process/Utility/ThreadMemory.cpp Tue Sep 6 15:57:50 2016
@@ -1,4 +1,5 @@
-//===-- ThreadMemory.cpp ----------------------------------------------*- C++ -*-===//
+//===-- ThreadMemory.cpp ----------------------------------------------*- C++
+//-*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -8,133 +9,97 @@
//===----------------------------------------------------------------------===//
#include "Plugins/Process/Utility/ThreadMemory.h"
+#include "Plugins/Process/Utility/RegisterContextThreadMemory.h"
#include "lldb/Target/OperatingSystem.h"
-#include "lldb/Target/RegisterContext.h"
#include "lldb/Target/Process.h"
+#include "lldb/Target/RegisterContext.h"
#include "lldb/Target/StopInfo.h"
#include "lldb/Target/Unwind.h"
-#include "Plugins/Process/Utility/RegisterContextThreadMemory.h"
using namespace lldb;
using namespace lldb_private;
-ThreadMemory::ThreadMemory (Process &process,
- tid_t tid,
- const ValueObjectSP &thread_info_valobj_sp) :
- Thread (process, tid),
- m_backing_thread_sp (),
- m_thread_info_valobj_sp (thread_info_valobj_sp),
- m_name(),
- m_queue()
-{
-}
-
-
-ThreadMemory::ThreadMemory (Process &process,
- lldb::tid_t tid,
- const char *name,
- const char *queue,
- lldb::addr_t register_data_addr) :
- Thread (process, tid),
- m_backing_thread_sp (),
- m_thread_info_valobj_sp (),
- m_name(),
- m_queue(),
- m_register_data_addr (register_data_addr)
-{
- if (name)
- m_name = name;
- if (queue)
- m_queue = queue;
-}
-
-
-ThreadMemory::~ThreadMemory()
-{
- DestroyThread();
-}
-
-void
-ThreadMemory::WillResume (StateType resume_state)
-{
- if (m_backing_thread_sp)
- m_backing_thread_sp->WillResume(resume_state);
-}
-
-void
-ThreadMemory::ClearStackFrames ()
-{
- if (m_backing_thread_sp)
- m_backing_thread_sp->ClearStackFrames();
- Thread::ClearStackFrames();
-}
-
-RegisterContextSP
-ThreadMemory::GetRegisterContext ()
-{
- if (!m_reg_context_sp)
- m_reg_context_sp.reset (new RegisterContextThreadMemory (*this, m_register_data_addr));
- return m_reg_context_sp;
+ThreadMemory::ThreadMemory(Process &process, tid_t tid,
+ const ValueObjectSP &thread_info_valobj_sp)
+ : Thread(process, tid), m_backing_thread_sp(),
+ m_thread_info_valobj_sp(thread_info_valobj_sp), m_name(), m_queue() {}
+
+ThreadMemory::ThreadMemory(Process &process, lldb::tid_t tid, const char *name,
+ const char *queue, lldb::addr_t register_data_addr)
+ : Thread(process, tid), m_backing_thread_sp(), m_thread_info_valobj_sp(),
+ m_name(), m_queue(), m_register_data_addr(register_data_addr) {
+ if (name)
+ m_name = name;
+ if (queue)
+ m_queue = queue;
+}
+
+ThreadMemory::~ThreadMemory() { DestroyThread(); }
+
+void ThreadMemory::WillResume(StateType resume_state) {
+ if (m_backing_thread_sp)
+ m_backing_thread_sp->WillResume(resume_state);
+}
+
+void ThreadMemory::ClearStackFrames() {
+ if (m_backing_thread_sp)
+ m_backing_thread_sp->ClearStackFrames();
+ Thread::ClearStackFrames();
+}
+
+RegisterContextSP ThreadMemory::GetRegisterContext() {
+ if (!m_reg_context_sp)
+ m_reg_context_sp.reset(
+ new RegisterContextThreadMemory(*this, m_register_data_addr));
+ return m_reg_context_sp;
}
RegisterContextSP
-ThreadMemory::CreateRegisterContextForFrame (StackFrame *frame)
-{
- RegisterContextSP reg_ctx_sp;
- uint32_t concrete_frame_idx = 0;
-
- if (frame)
- concrete_frame_idx = frame->GetConcreteFrameIndex ();
-
- if (concrete_frame_idx == 0)
- {
- reg_ctx_sp = GetRegisterContext ();
+ThreadMemory::CreateRegisterContextForFrame(StackFrame *frame) {
+ RegisterContextSP reg_ctx_sp;
+ uint32_t concrete_frame_idx = 0;
+
+ if (frame)
+ concrete_frame_idx = frame->GetConcreteFrameIndex();
+
+ if (concrete_frame_idx == 0) {
+ reg_ctx_sp = GetRegisterContext();
+ } else {
+ Unwind *unwinder = GetUnwinder();
+ if (unwinder)
+ reg_ctx_sp = unwinder->CreateRegisterContextForFrame(frame);
+ }
+ return reg_ctx_sp;
+}
+
+bool ThreadMemory::CalculateStopInfo() {
+ if (m_backing_thread_sp) {
+ lldb::StopInfoSP backing_stop_info_sp(
+ m_backing_thread_sp->GetPrivateStopInfo());
+ if (backing_stop_info_sp &&
+ backing_stop_info_sp->IsValidForOperatingSystemThread(*this)) {
+ backing_stop_info_sp->SetThread(shared_from_this());
+ SetStopInfo(backing_stop_info_sp);
+ return true;
}
- else
- {
- Unwind *unwinder = GetUnwinder ();
- if (unwinder)
- reg_ctx_sp = unwinder->CreateRegisterContextForFrame (frame);
- }
- return reg_ctx_sp;
-}
+ } else {
+ ProcessSP process_sp(GetProcess());
-bool
-ThreadMemory::CalculateStopInfo ()
-{
- if (m_backing_thread_sp)
- {
- lldb::StopInfoSP backing_stop_info_sp (m_backing_thread_sp->GetPrivateStopInfo());
- if (backing_stop_info_sp && backing_stop_info_sp->IsValidForOperatingSystemThread(*this))
- {
- backing_stop_info_sp->SetThread (shared_from_this());
- SetStopInfo (backing_stop_info_sp);
- return true;
- }
+ if (process_sp) {
+ OperatingSystem *os = process_sp->GetOperatingSystem();
+ if (os) {
+ SetStopInfo(os->CreateThreadStopReason(this));
+ return true;
+ }
}
- else
- {
- ProcessSP process_sp (GetProcess());
-
- if (process_sp)
- {
- OperatingSystem *os = process_sp->GetOperatingSystem ();
- if (os)
- {
- SetStopInfo (os->CreateThreadStopReason (this));
- return true;
- }
- }
- }
- return false;
+ }
+ return false;
}
-void
-ThreadMemory::RefreshStateAfterStop()
-{
- if (m_backing_thread_sp)
- return m_backing_thread_sp->RefreshStateAfterStop();
-
- if (m_reg_context_sp)
- m_reg_context_sp->InvalidateAllRegisters();
+void ThreadMemory::RefreshStateAfterStop() {
+ if (m_backing_thread_sp)
+ return m_backing_thread_sp->RefreshStateAfterStop();
+
+ if (m_reg_context_sp)
+ m_reg_context_sp->InvalidateAllRegisters();
}
Modified: lldb/trunk/source/Plugins/Process/Utility/ThreadMemory.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Utility/ThreadMemory.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/Utility/ThreadMemory.h (original)
+++ lldb/trunk/source/Plugins/Process/Utility/ThreadMemory.h Tue Sep 6 15:57:50 2016
@@ -18,129 +18,94 @@
// Project includes
#include "lldb/Target/Thread.h"
-class ThreadMemory :
- public lldb_private::Thread
-{
+class ThreadMemory : public lldb_private::Thread {
public:
- ThreadMemory (lldb_private::Process &process,
- lldb::tid_t tid,
- const lldb::ValueObjectSP &thread_info_valobj_sp);
-
- ThreadMemory (lldb_private::Process &process,
- lldb::tid_t tid,
- const char *name,
- const char *queue,
- lldb::addr_t register_data_addr);
-
- ~ThreadMemory() override;
-
- lldb::RegisterContextSP
- GetRegisterContext() override;
-
- lldb::RegisterContextSP
- CreateRegisterContextForFrame(lldb_private::StackFrame *frame) override;
-
- bool
- CalculateStopInfo() override;
-
- const char *
- GetInfo() override
- {
- if (m_backing_thread_sp)
- m_backing_thread_sp->GetInfo();
- return nullptr;
- }
-
- const char *
- GetName() override
- {
- if (!m_name.empty())
- return m_name.c_str();
- if (m_backing_thread_sp)
- m_backing_thread_sp->GetName();
- return nullptr;
- }
-
- const char *
- GetQueueName() override
- {
- if (!m_queue.empty())
- return m_queue.c_str();
- if (m_backing_thread_sp)
- m_backing_thread_sp->GetQueueName();
- return nullptr;
- }
-
- void
- WillResume(lldb::StateType resume_state) override;
-
- void
- DidResume() override
- {
- if (m_backing_thread_sp)
- m_backing_thread_sp->DidResume();
- }
-
- lldb::user_id_t
- GetProtocolID() const override
- {
- if (m_backing_thread_sp)
- return m_backing_thread_sp->GetProtocolID();
- return Thread::GetProtocolID();
- }
-
- void
- RefreshStateAfterStop() override;
-
- lldb::ValueObjectSP &
- GetValueObject ()
- {
- return m_thread_info_valobj_sp;
- }
-
- void
- ClearStackFrames() override;
-
- void
- ClearBackingThread() override
- {
- m_backing_thread_sp.reset();
- }
-
- bool
- SetBackingThread(const lldb::ThreadSP &thread_sp) override
- {
- //printf ("Thread 0x%llx is being backed by thread 0x%llx\n", GetID(), thread_sp->GetID());
- m_backing_thread_sp = thread_sp;
- return (bool)thread_sp;
- }
-
- lldb::ThreadSP
- GetBackingThread() const override
- {
- return m_backing_thread_sp;
- }
+ ThreadMemory(lldb_private::Process &process, lldb::tid_t tid,
+ const lldb::ValueObjectSP &thread_info_valobj_sp);
+
+ ThreadMemory(lldb_private::Process &process, lldb::tid_t tid,
+ const char *name, const char *queue,
+ lldb::addr_t register_data_addr);
+
+ ~ThreadMemory() override;
+
+ lldb::RegisterContextSP GetRegisterContext() override;
+
+ lldb::RegisterContextSP
+ CreateRegisterContextForFrame(lldb_private::StackFrame *frame) override;
+
+ bool CalculateStopInfo() override;
+
+ const char *GetInfo() override {
+ if (m_backing_thread_sp)
+ m_backing_thread_sp->GetInfo();
+ return nullptr;
+ }
+
+ const char *GetName() override {
+ if (!m_name.empty())
+ return m_name.c_str();
+ if (m_backing_thread_sp)
+ m_backing_thread_sp->GetName();
+ return nullptr;
+ }
+
+ const char *GetQueueName() override {
+ if (!m_queue.empty())
+ return m_queue.c_str();
+ if (m_backing_thread_sp)
+ m_backing_thread_sp->GetQueueName();
+ return nullptr;
+ }
+
+ void WillResume(lldb::StateType resume_state) override;
+
+ void DidResume() override {
+ if (m_backing_thread_sp)
+ m_backing_thread_sp->DidResume();
+ }
+
+ lldb::user_id_t GetProtocolID() const override {
+ if (m_backing_thread_sp)
+ return m_backing_thread_sp->GetProtocolID();
+ return Thread::GetProtocolID();
+ }
+
+ void RefreshStateAfterStop() override;
+
+ lldb::ValueObjectSP &GetValueObject() { return m_thread_info_valobj_sp; }
+
+ void ClearStackFrames() override;
+
+ void ClearBackingThread() override { m_backing_thread_sp.reset(); }
+
+ bool SetBackingThread(const lldb::ThreadSP &thread_sp) override {
+ // printf ("Thread 0x%llx is being backed by thread 0x%llx\n", GetID(),
+ // thread_sp->GetID());
+ m_backing_thread_sp = thread_sp;
+ return (bool)thread_sp;
+ }
+
+ lldb::ThreadSP GetBackingThread() const override {
+ return m_backing_thread_sp;
+ }
protected:
- bool
- IsOperatingSystemPluginThread() const override
- {
- return true;
- }
-
- // If this memory thread is actually represented by a thread from the
- // lldb_private::Process subclass, then fill in the thread here and
- // all APIs will be routed through this thread object. If m_backing_thread_sp
- // is empty, then this thread is simply in memory with no representation
- // through the process plug-in.
- lldb::ThreadSP m_backing_thread_sp;
- lldb::ValueObjectSP m_thread_info_valobj_sp;
- std::string m_name;
- std::string m_queue;
- lldb::addr_t m_register_data_addr;
+ bool IsOperatingSystemPluginThread() const override { return true; }
+
+ // If this memory thread is actually represented by a thread from the
+ // lldb_private::Process subclass, then fill in the thread here and
+ // all APIs will be routed through this thread object. If m_backing_thread_sp
+ // is empty, then this thread is simply in memory with no representation
+ // through the process plug-in.
+ lldb::ThreadSP m_backing_thread_sp;
+ lldb::ValueObjectSP m_thread_info_valobj_sp;
+ std::string m_name;
+ std::string m_queue;
+ lldb::addr_t m_register_data_addr;
private:
- DISALLOW_COPY_AND_ASSIGN (ThreadMemory);
+ DISALLOW_COPY_AND_ASSIGN(ThreadMemory);
};
#endif // liblldb_ThreadMemory_h_
Modified: lldb/trunk/source/Plugins/Process/Utility/UnwindLLDB.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Utility/UnwindLLDB.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/Utility/UnwindLLDB.cpp (original)
+++ lldb/trunk/source/Plugins/Process/Utility/UnwindLLDB.cpp Tue Sep 6 15:57:50 2016
@@ -7,529 +7,533 @@
//
//===----------------------------------------------------------------------===//
-#include "lldb/Core/Module.h"
#include "lldb/Core/Log.h"
+#include "lldb/Core/Module.h"
#include "lldb/Symbol/FuncUnwinders.h"
#include "lldb/Symbol/Function.h"
#include "lldb/Symbol/UnwindPlan.h"
#include "lldb/Target/ABI.h"
-#include "lldb/Target/Thread.h"
-#include "lldb/Target/Target.h"
#include "lldb/Target/Process.h"
#include "lldb/Target/RegisterContext.h"
+#include "lldb/Target/Target.h"
+#include "lldb/Target/Thread.h"
-#include "UnwindLLDB.h"
#include "RegisterContextLLDB.h"
+#include "UnwindLLDB.h"
using namespace lldb;
using namespace lldb_private;
-UnwindLLDB::UnwindLLDB (Thread &thread) :
- Unwind (thread),
- m_frames(),
- m_unwind_complete(false),
- m_user_supplied_trap_handler_functions()
-{
- ProcessSP process_sp(thread.GetProcess());
- if (process_sp)
- {
- Args args;
- process_sp->GetTarget().GetUserSpecifiedTrapHandlerNames (args);
- size_t count = args.GetArgumentCount();
- for (size_t i = 0; i < count; i++)
- {
- const char *func_name = args.GetArgumentAtIndex(i);
- m_user_supplied_trap_handler_functions.push_back (ConstString (func_name));
- }
+UnwindLLDB::UnwindLLDB(Thread &thread)
+ : Unwind(thread), m_frames(), m_unwind_complete(false),
+ m_user_supplied_trap_handler_functions() {
+ ProcessSP process_sp(thread.GetProcess());
+ if (process_sp) {
+ Args args;
+ process_sp->GetTarget().GetUserSpecifiedTrapHandlerNames(args);
+ size_t count = args.GetArgumentCount();
+ for (size_t i = 0; i < count; i++) {
+ const char *func_name = args.GetArgumentAtIndex(i);
+ m_user_supplied_trap_handler_functions.push_back(ConstString(func_name));
}
+ }
}
-uint32_t
-UnwindLLDB::DoGetFrameCount()
-{
- if (!m_unwind_complete)
- {
+uint32_t UnwindLLDB::DoGetFrameCount() {
+ if (!m_unwind_complete) {
//#define DEBUG_FRAME_SPEED 1
#if DEBUG_FRAME_SPEED
#define FRAME_COUNT 10000
- TimeValue time_value (TimeValue::Now());
+ TimeValue time_value(TimeValue::Now());
#endif
- if (!AddFirstFrame ())
- return 0;
+ if (!AddFirstFrame())
+ return 0;
- ProcessSP process_sp (m_thread.GetProcess());
- ABI *abi = process_sp ? process_sp->GetABI().get() : NULL;
+ ProcessSP process_sp(m_thread.GetProcess());
+ ABI *abi = process_sp ? process_sp->GetABI().get() : NULL;
- while (AddOneMoreFrame (abi))
- {
+ while (AddOneMoreFrame(abi)) {
#if DEBUG_FRAME_SPEED
- if ((m_frames.size() % FRAME_COUNT) == 0)
- {
- TimeValue now(TimeValue::Now());
- uint64_t delta_t = now - time_value;
- printf ("%u frames in %" PRIu64 ".%09llu ms (%g frames/sec)\n",
- FRAME_COUNT,
- delta_t / TimeValue::NanoSecPerSec,
- delta_t % TimeValue::NanoSecPerSec,
- (float)FRAME_COUNT / ((float)delta_t / (float)TimeValue::NanoSecPerSec));
- time_value = now;
- }
+ if ((m_frames.size() % FRAME_COUNT) == 0) {
+ TimeValue now(TimeValue::Now());
+ uint64_t delta_t = now - time_value;
+ printf("%u frames in %" PRIu64 ".%09llu ms (%g frames/sec)\n",
+ FRAME_COUNT, delta_t / TimeValue::NanoSecPerSec,
+ delta_t % TimeValue::NanoSecPerSec,
+ (float)FRAME_COUNT /
+ ((float)delta_t / (float)TimeValue::NanoSecPerSec));
+ time_value = now;
+ }
#endif
- }
}
- return m_frames.size ();
+ }
+ return m_frames.size();
}
-bool
-UnwindLLDB::AddFirstFrame ()
-{
- if (m_frames.size() > 0)
- return true;
-
- ProcessSP process_sp (m_thread.GetProcess());
- ABI *abi = process_sp ? process_sp->GetABI().get() : NULL;
+bool UnwindLLDB::AddFirstFrame() {
+ if (m_frames.size() > 0)
+ return true;
- // First, set up the 0th (initial) frame
- CursorSP first_cursor_sp(new Cursor ());
- RegisterContextLLDBSP reg_ctx_sp (new RegisterContextLLDB (m_thread,
- RegisterContextLLDBSP(),
- first_cursor_sp->sctx,
- 0, *this));
- if (reg_ctx_sp.get() == NULL)
- goto unwind_done;
-
- if (!reg_ctx_sp->IsValid())
- goto unwind_done;
-
- if (!reg_ctx_sp->GetCFA (first_cursor_sp->cfa))
- goto unwind_done;
-
- if (!reg_ctx_sp->ReadPC (first_cursor_sp->start_pc))
- goto unwind_done;
-
- // Everything checks out, so release the auto pointer value and let the
- // cursor own it in its shared pointer
- first_cursor_sp->reg_ctx_lldb_sp = reg_ctx_sp;
- m_frames.push_back (first_cursor_sp);
+ ProcessSP process_sp(m_thread.GetProcess());
+ ABI *abi = process_sp ? process_sp->GetABI().get() : NULL;
- // Update the Full Unwind Plan for this frame if not valid
- UpdateUnwindPlanForFirstFrameIfInvalid(abi);
+ // First, set up the 0th (initial) frame
+ CursorSP first_cursor_sp(new Cursor());
+ RegisterContextLLDBSP reg_ctx_sp(new RegisterContextLLDB(
+ m_thread, RegisterContextLLDBSP(), first_cursor_sp->sctx, 0, *this));
+ if (reg_ctx_sp.get() == NULL)
+ goto unwind_done;
+
+ if (!reg_ctx_sp->IsValid())
+ goto unwind_done;
+
+ if (!reg_ctx_sp->GetCFA(first_cursor_sp->cfa))
+ goto unwind_done;
+
+ if (!reg_ctx_sp->ReadPC(first_cursor_sp->start_pc))
+ goto unwind_done;
+
+ // Everything checks out, so release the auto pointer value and let the
+ // cursor own it in its shared pointer
+ first_cursor_sp->reg_ctx_lldb_sp = reg_ctx_sp;
+ m_frames.push_back(first_cursor_sp);
- return true;
+ // Update the Full Unwind Plan for this frame if not valid
+ UpdateUnwindPlanForFirstFrameIfInvalid(abi);
+
+ return true;
unwind_done:
- Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_UNWIND));
- if (log)
- {
- log->Printf ("th%d Unwind of this thread is complete.", m_thread.GetIndexID());
- }
- m_unwind_complete = true;
- return false;
+ Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_UNWIND));
+ if (log) {
+ log->Printf("th%d Unwind of this thread is complete.",
+ m_thread.GetIndexID());
+ }
+ m_unwind_complete = true;
+ return false;
}
-UnwindLLDB::CursorSP
-UnwindLLDB::GetOneMoreFrame (ABI* abi)
-{
- assert (m_frames.size() != 0 && "Get one more frame called with empty frame list");
-
- // If we've already gotten to the end of the stack, don't bother to try again...
- if (m_unwind_complete)
+UnwindLLDB::CursorSP UnwindLLDB::GetOneMoreFrame(ABI *abi) {
+ assert(m_frames.size() != 0 &&
+ "Get one more frame called with empty frame list");
+
+ // If we've already gotten to the end of the stack, don't bother to try
+ // again...
+ if (m_unwind_complete)
+ return nullptr;
+
+ Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_UNWIND));
+
+ CursorSP prev_frame = m_frames.back();
+ uint32_t cur_idx = m_frames.size();
+
+ CursorSP cursor_sp(new Cursor());
+ RegisterContextLLDBSP reg_ctx_sp(new RegisterContextLLDB(
+ m_thread, prev_frame->reg_ctx_lldb_sp, cursor_sp->sctx, cur_idx, *this));
+
+ // We want to detect an unwind that cycles erroneously and stop backtracing.
+ // Don't want this maximum unwind limit to be too low -- if you have a
+ // backtrace
+ // with an "infinitely recursing" bug, it will crash when the stack blows out
+ // and the first 35,000 frames are uninteresting - it's the top most 5 frames
+ // that
+ // you actually care about. So you can't just cap the unwind at 10,000 or
+ // something.
+ // Realistically anything over around 200,000 is going to blow out the stack
+ // space.
+ // If we're still unwinding at that point, we're probably never going to
+ // finish.
+ if (cur_idx > 300000) {
+ if (log)
+ log->Printf("%*sFrame %d unwound too many frames, assuming unwind has "
+ "gone astray, stopping.",
+ cur_idx < 100 ? cur_idx : 100, "", cur_idx);
+ return nullptr;
+ }
+
+ if (reg_ctx_sp.get() == NULL) {
+ // If the RegisterContextLLDB has a fallback UnwindPlan, it will switch to
+ // that and return
+ // true. Subsequent calls to TryFallbackUnwindPlan() will return false.
+ if (prev_frame->reg_ctx_lldb_sp->TryFallbackUnwindPlan()) {
+ // TryFallbackUnwindPlan for prev_frame succeeded and updated
+ // reg_ctx_lldb_sp field of
+ // prev_frame. However, cfa field of prev_frame still needs to be updated.
+ // Hence updating it.
+ if (!(prev_frame->reg_ctx_lldb_sp->GetCFA(prev_frame->cfa)))
return nullptr;
-
- Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_UNWIND));
-
- CursorSP prev_frame = m_frames.back();
- uint32_t cur_idx = m_frames.size();
- CursorSP cursor_sp(new Cursor ());
- RegisterContextLLDBSP reg_ctx_sp(new RegisterContextLLDB (m_thread,
- prev_frame->reg_ctx_lldb_sp,
- cursor_sp->sctx,
- cur_idx,
- *this));
-
- // We want to detect an unwind that cycles erroneously and stop backtracing.
- // Don't want this maximum unwind limit to be too low -- if you have a backtrace
- // with an "infinitely recursing" bug, it will crash when the stack blows out
- // and the first 35,000 frames are uninteresting - it's the top most 5 frames that
- // you actually care about. So you can't just cap the unwind at 10,000 or something.
- // Realistically anything over around 200,000 is going to blow out the stack space.
- // If we're still unwinding at that point, we're probably never going to finish.
- if (cur_idx > 300000)
- {
- if (log)
- log->Printf ("%*sFrame %d unwound too many frames, assuming unwind has gone astray, stopping.",
- cur_idx < 100 ? cur_idx : 100, "", cur_idx);
- return nullptr;
+ return GetOneMoreFrame(abi);
}
- if (reg_ctx_sp.get() == NULL)
- {
- // If the RegisterContextLLDB has a fallback UnwindPlan, it will switch to that and return
- // true. Subsequent calls to TryFallbackUnwindPlan() will return false.
- if (prev_frame->reg_ctx_lldb_sp->TryFallbackUnwindPlan())
- {
- // TryFallbackUnwindPlan for prev_frame succeeded and updated reg_ctx_lldb_sp field of
- // prev_frame. However, cfa field of prev_frame still needs to be updated. Hence updating it.
- if ( !(prev_frame->reg_ctx_lldb_sp->GetCFA(prev_frame->cfa)))
- return nullptr;
+ if (log)
+ log->Printf("%*sFrame %d did not get a RegisterContext, stopping.",
+ cur_idx < 100 ? cur_idx : 100, "", cur_idx);
+ return nullptr;
+ }
+
+ if (!reg_ctx_sp->IsValid()) {
+ // We failed to get a valid RegisterContext.
+ // See if the regctx below this on the stack has a fallback unwind plan it
+ // can use.
+ // Subsequent calls to TryFallbackUnwindPlan() will return false.
+ if (prev_frame->reg_ctx_lldb_sp->TryFallbackUnwindPlan()) {
+ // TryFallbackUnwindPlan for prev_frame succeeded and updated
+ // reg_ctx_lldb_sp field of
+ // prev_frame. However, cfa field of prev_frame still needs to be updated.
+ // Hence updating it.
+ if (!(prev_frame->reg_ctx_lldb_sp->GetCFA(prev_frame->cfa)))
+ return nullptr;
- return GetOneMoreFrame (abi);
- }
+ return GetOneMoreFrame(abi);
+ }
- if (log)
- log->Printf ("%*sFrame %d did not get a RegisterContext, stopping.",
- cur_idx < 100 ? cur_idx : 100, "", cur_idx);
+ if (log)
+ log->Printf("%*sFrame %d invalid RegisterContext for this frame, "
+ "stopping stack walk",
+ cur_idx < 100 ? cur_idx : 100, "", cur_idx);
+ return nullptr;
+ }
+ if (!reg_ctx_sp->GetCFA(cursor_sp->cfa)) {
+ // If the RegisterContextLLDB has a fallback UnwindPlan, it will switch to
+ // that and return
+ // true. Subsequent calls to TryFallbackUnwindPlan() will return false.
+ if (prev_frame->reg_ctx_lldb_sp->TryFallbackUnwindPlan()) {
+ // TryFallbackUnwindPlan for prev_frame succeeded and updated
+ // reg_ctx_lldb_sp field of
+ // prev_frame. However, cfa field of prev_frame still needs to be updated.
+ // Hence updating it.
+ if (!(prev_frame->reg_ctx_lldb_sp->GetCFA(prev_frame->cfa)))
return nullptr;
+
+ return GetOneMoreFrame(abi);
}
- if (!reg_ctx_sp->IsValid())
- {
- // We failed to get a valid RegisterContext.
- // See if the regctx below this on the stack has a fallback unwind plan it can use.
- // Subsequent calls to TryFallbackUnwindPlan() will return false.
- if (prev_frame->reg_ctx_lldb_sp->TryFallbackUnwindPlan())
- {
- // TryFallbackUnwindPlan for prev_frame succeeded and updated reg_ctx_lldb_sp field of
- // prev_frame. However, cfa field of prev_frame still needs to be updated. Hence updating it.
- if ( !(prev_frame->reg_ctx_lldb_sp->GetCFA(prev_frame->cfa)))
- return nullptr;
+ if (log)
+ log->Printf(
+ "%*sFrame %d did not get CFA for this frame, stopping stack walk",
+ cur_idx < 100 ? cur_idx : 100, "", cur_idx);
+ return nullptr;
+ }
+ if (abi && !abi->CallFrameAddressIsValid(cursor_sp->cfa)) {
+ // On Mac OS X, the _sigtramp asynchronous signal trampoline frame may not
+ // have
+ // its (constructed) CFA aligned correctly -- don't do the abi alignment
+ // check for
+ // these.
+ if (reg_ctx_sp->IsTrapHandlerFrame() == false) {
+ // See if we can find a fallback unwind plan for THIS frame. It may be
+ // that the UnwindPlan we're using for THIS frame was bad and gave us a
+ // bad CFA.
+ // If that's not it, then see if we can change the UnwindPlan for the
+ // frame
+ // below us ("NEXT") -- see if using that other UnwindPlan gets us a
+ // better
+ // unwind state.
+ if (reg_ctx_sp->TryFallbackUnwindPlan() == false ||
+ reg_ctx_sp->GetCFA(cursor_sp->cfa) == false ||
+ abi->CallFrameAddressIsValid(cursor_sp->cfa) == false) {
+ if (prev_frame->reg_ctx_lldb_sp->TryFallbackUnwindPlan()) {
+ // TryFallbackUnwindPlan for prev_frame succeeded and updated
+ // reg_ctx_lldb_sp field of
+ // prev_frame. However, cfa field of prev_frame still needs to be
+ // updated. Hence updating it.
+ if (!(prev_frame->reg_ctx_lldb_sp->GetCFA(prev_frame->cfa)))
+ return nullptr;
- return GetOneMoreFrame (abi);
+ return GetOneMoreFrame(abi);
}
if (log)
- log->Printf("%*sFrame %d invalid RegisterContext for this frame, stopping stack walk",
- cur_idx < 100 ? cur_idx : 100, "", cur_idx);
+ log->Printf("%*sFrame %d did not get a valid CFA for this frame, "
+ "stopping stack walk",
+ cur_idx < 100 ? cur_idx : 100, "", cur_idx);
return nullptr;
- }
- if (!reg_ctx_sp->GetCFA (cursor_sp->cfa))
- {
- // If the RegisterContextLLDB has a fallback UnwindPlan, it will switch to that and return
- // true. Subsequent calls to TryFallbackUnwindPlan() will return false.
- if (prev_frame->reg_ctx_lldb_sp->TryFallbackUnwindPlan())
- {
- // TryFallbackUnwindPlan for prev_frame succeeded and updated reg_ctx_lldb_sp field of
- // prev_frame. However, cfa field of prev_frame still needs to be updated. Hence updating it.
- if ( !(prev_frame->reg_ctx_lldb_sp->GetCFA(prev_frame->cfa)))
- return nullptr;
-
- return GetOneMoreFrame (abi);
- }
-
+ } else {
if (log)
- log->Printf("%*sFrame %d did not get CFA for this frame, stopping stack walk",
- cur_idx < 100 ? cur_idx : 100, "", cur_idx);
+ log->Printf("%*sFrame %d had a bad CFA value but we switched the "
+ "UnwindPlan being used and got one that looks more "
+ "realistic.",
+ cur_idx < 100 ? cur_idx : 100, "", cur_idx);
+ }
+ }
+ }
+ if (!reg_ctx_sp->ReadPC(cursor_sp->start_pc)) {
+ // If the RegisterContextLLDB has a fallback UnwindPlan, it will switch to
+ // that and return
+ // true. Subsequent calls to TryFallbackUnwindPlan() will return false.
+ if (prev_frame->reg_ctx_lldb_sp->TryFallbackUnwindPlan()) {
+ // TryFallbackUnwindPlan for prev_frame succeeded and updated
+ // reg_ctx_lldb_sp field of
+ // prev_frame. However, cfa field of prev_frame still needs to be updated.
+ // Hence updating it.
+ if (!(prev_frame->reg_ctx_lldb_sp->GetCFA(prev_frame->cfa)))
return nullptr;
- }
- if (abi && !abi->CallFrameAddressIsValid(cursor_sp->cfa))
- {
- // On Mac OS X, the _sigtramp asynchronous signal trampoline frame may not have
- // its (constructed) CFA aligned correctly -- don't do the abi alignment check for
- // these.
- if (reg_ctx_sp->IsTrapHandlerFrame() == false)
- {
- // See if we can find a fallback unwind plan for THIS frame. It may be
- // that the UnwindPlan we're using for THIS frame was bad and gave us a
- // bad CFA.
- // If that's not it, then see if we can change the UnwindPlan for the frame
- // below us ("NEXT") -- see if using that other UnwindPlan gets us a better
- // unwind state.
- if (reg_ctx_sp->TryFallbackUnwindPlan() == false
- || reg_ctx_sp->GetCFA (cursor_sp->cfa) == false
- || abi->CallFrameAddressIsValid(cursor_sp->cfa) == false)
- {
- if (prev_frame->reg_ctx_lldb_sp->TryFallbackUnwindPlan())
- {
- // TryFallbackUnwindPlan for prev_frame succeeded and updated reg_ctx_lldb_sp field of
- // prev_frame. However, cfa field of prev_frame still needs to be updated. Hence updating it.
- if ( !(prev_frame->reg_ctx_lldb_sp->GetCFA(prev_frame->cfa)))
- return nullptr;
-
- return GetOneMoreFrame (abi);
- }
-
- if (log)
- log->Printf("%*sFrame %d did not get a valid CFA for this frame, stopping stack walk",
- cur_idx < 100 ? cur_idx : 100, "", cur_idx);
- return nullptr;
- }
- else
- {
- if (log)
- log->Printf("%*sFrame %d had a bad CFA value but we switched the UnwindPlan being used and got one that looks more realistic.",
- cur_idx < 100 ? cur_idx : 100, "", cur_idx);
- }
- }
- }
- if (!reg_ctx_sp->ReadPC (cursor_sp->start_pc))
- {
- // If the RegisterContextLLDB has a fallback UnwindPlan, it will switch to that and return
- // true. Subsequent calls to TryFallbackUnwindPlan() will return false.
- if (prev_frame->reg_ctx_lldb_sp->TryFallbackUnwindPlan())
- {
- // TryFallbackUnwindPlan for prev_frame succeeded and updated reg_ctx_lldb_sp field of
- // prev_frame. However, cfa field of prev_frame still needs to be updated. Hence updating it.
- if ( !(prev_frame->reg_ctx_lldb_sp->GetCFA(prev_frame->cfa)))
- return nullptr;
-
- return GetOneMoreFrame (abi);
- }
- if (log)
- log->Printf("%*sFrame %d did not get PC for this frame, stopping stack walk",
- cur_idx < 100 ? cur_idx : 100, "", cur_idx);
- return nullptr;
+ return GetOneMoreFrame(abi);
}
- if (abi && !abi->CodeAddressIsValid (cursor_sp->start_pc))
- {
- // If the RegisterContextLLDB has a fallback UnwindPlan, it will switch to that and return
- // true. Subsequent calls to TryFallbackUnwindPlan() will return false.
- if (prev_frame->reg_ctx_lldb_sp->TryFallbackUnwindPlan())
- {
- // TryFallbackUnwindPlan for prev_frame succeeded and updated reg_ctx_lldb_sp field of
- // prev_frame. However, cfa field of prev_frame still needs to be updated. Hence updating it.
- if ( !(prev_frame->reg_ctx_lldb_sp->GetCFA(prev_frame->cfa)))
- return nullptr;
- return GetOneMoreFrame (abi);
- }
-
- if (log)
- log->Printf("%*sFrame %d did not get a valid PC, stopping stack walk",
- cur_idx < 100 ? cur_idx : 100, "", cur_idx);
- return nullptr;
- }
- // Infinite loop where the current cursor is the same as the previous one...
- if (prev_frame->start_pc == cursor_sp->start_pc && prev_frame->cfa == cursor_sp->cfa)
- {
- if (log)
- log->Printf ("th%d pc of this frame is the same as the previous frame and CFAs for both frames are identical -- stopping unwind", m_thread.GetIndexID());
+ if (log)
+ log->Printf(
+ "%*sFrame %d did not get PC for this frame, stopping stack walk",
+ cur_idx < 100 ? cur_idx : 100, "", cur_idx);
+ return nullptr;
+ }
+ if (abi && !abi->CodeAddressIsValid(cursor_sp->start_pc)) {
+ // If the RegisterContextLLDB has a fallback UnwindPlan, it will switch to
+ // that and return
+ // true. Subsequent calls to TryFallbackUnwindPlan() will return false.
+ if (prev_frame->reg_ctx_lldb_sp->TryFallbackUnwindPlan()) {
+ // TryFallbackUnwindPlan for prev_frame succeeded and updated
+ // reg_ctx_lldb_sp field of
+ // prev_frame. However, cfa field of prev_frame still needs to be updated.
+ // Hence updating it.
+ if (!(prev_frame->reg_ctx_lldb_sp->GetCFA(prev_frame->cfa)))
return nullptr;
+
+ return GetOneMoreFrame(abi);
}
- cursor_sp->reg_ctx_lldb_sp = reg_ctx_sp;
- return cursor_sp;
+ if (log)
+ log->Printf("%*sFrame %d did not get a valid PC, stopping stack walk",
+ cur_idx < 100 ? cur_idx : 100, "", cur_idx);
+ return nullptr;
+ }
+ // Infinite loop where the current cursor is the same as the previous one...
+ if (prev_frame->start_pc == cursor_sp->start_pc &&
+ prev_frame->cfa == cursor_sp->cfa) {
+ if (log)
+ log->Printf("th%d pc of this frame is the same as the previous frame and "
+ "CFAs for both frames are identical -- stopping unwind",
+ m_thread.GetIndexID());
+ return nullptr;
+ }
+
+ cursor_sp->reg_ctx_lldb_sp = reg_ctx_sp;
+ return cursor_sp;
}
-void
-UnwindLLDB::UpdateUnwindPlanForFirstFrameIfInvalid (ABI *abi)
-{
- // This function is called for First Frame only.
- assert (m_frames.size() == 1 && "No. of cursor frames are not 1");
-
- bool old_m_unwind_complete = m_unwind_complete;
- CursorSP old_m_candidate_frame = m_candidate_frame;
-
- // Try to unwind 2 more frames using the Unwinder. It uses Full UnwindPlan
- // and if Full UnwindPlan fails, then uses FallBack UnwindPlan. Also
- // update the cfa of Frame 0 (if required).
- AddOneMoreFrame(abi);
-
- // Remove all the frames added by above function as the purpose of
- // using above function was just to check whether Unwinder of Frame 0
- // works or not.
- for(uint32_t i=1; i<m_frames.size(); i++)
- m_frames.pop_back();
-
- // Restore status after calling AddOneMoreFrame
- m_unwind_complete = old_m_unwind_complete;
- m_candidate_frame = old_m_candidate_frame;
- return;
+void UnwindLLDB::UpdateUnwindPlanForFirstFrameIfInvalid(ABI *abi) {
+ // This function is called for First Frame only.
+ assert(m_frames.size() == 1 && "No. of cursor frames are not 1");
+
+ bool old_m_unwind_complete = m_unwind_complete;
+ CursorSP old_m_candidate_frame = m_candidate_frame;
+
+ // Try to unwind 2 more frames using the Unwinder. It uses Full UnwindPlan
+ // and if Full UnwindPlan fails, then uses FallBack UnwindPlan. Also
+ // update the cfa of Frame 0 (if required).
+ AddOneMoreFrame(abi);
+
+ // Remove all the frames added by above function as the purpose of
+ // using above function was just to check whether Unwinder of Frame 0
+ // works or not.
+ for (uint32_t i = 1; i < m_frames.size(); i++)
+ m_frames.pop_back();
+
+ // Restore status after calling AddOneMoreFrame
+ m_unwind_complete = old_m_unwind_complete;
+ m_candidate_frame = old_m_candidate_frame;
+ return;
}
+bool UnwindLLDB::AddOneMoreFrame(ABI *abi) {
+ Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_UNWIND));
-bool
-UnwindLLDB::AddOneMoreFrame (ABI *abi)
-{
- Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_UNWIND));
-
- // Frame zero is a little different
- if (m_frames.empty())
- return false;
-
- // If we've already gotten to the end of the stack, don't bother to try again...
- if (m_unwind_complete)
- return false;
-
- CursorSP new_frame = m_candidate_frame;
- if (new_frame == nullptr)
- new_frame = GetOneMoreFrame(abi);
+ // Frame zero is a little different
+ if (m_frames.empty())
+ return false;
- if (new_frame == nullptr)
- {
- if (log)
- log->Printf ("th%d Unwind of this thread is complete.", m_thread.GetIndexID());
- m_unwind_complete = true;
- return false;
- }
+ // If we've already gotten to the end of the stack, don't bother to try
+ // again...
+ if (m_unwind_complete)
+ return false;
- m_frames.push_back(new_frame);
+ CursorSP new_frame = m_candidate_frame;
+ if (new_frame == nullptr)
+ new_frame = GetOneMoreFrame(abi);
- // If we can get one more frame further then accept that we get back a correct frame.
- m_candidate_frame = GetOneMoreFrame(abi);
- if (m_candidate_frame)
- return true;
-
- // We can't go further from the frame returned by GetOneMore frame. Lets try to get a
- // different frame with using the fallback unwind plan.
- if (!m_frames[m_frames.size() - 2]->reg_ctx_lldb_sp->TryFallbackUnwindPlan())
- {
- // We don't have a valid fallback unwind plan. Accept the frame as it is. This is a
- // valid situation when we are at the bottom of the stack.
- return true;
- }
+ if (new_frame == nullptr) {
+ if (log)
+ log->Printf("th%d Unwind of this thread is complete.",
+ m_thread.GetIndexID());
+ m_unwind_complete = true;
+ return false;
+ }
- // Remove the possibly incorrect frame from the frame list and try to add a different one with
- // the newly selected fallback unwind plan.
- m_frames.pop_back();
- CursorSP new_frame_v2 = GetOneMoreFrame(abi);
- if (new_frame_v2 == nullptr)
- {
- // We haven't got a new frame from the fallback unwind plan. Accept the frame from the
- // original unwind plan. This is a valid situation when we are at the bottom of the stack.
- m_frames.push_back(new_frame);
- return true;
- }
+ m_frames.push_back(new_frame);
- // Push the new frame to the list and try to continue from this frame. If we can get a new frame
- // then accept it as the correct one.
- m_frames.push_back(new_frame_v2);
- m_candidate_frame = GetOneMoreFrame(abi);
- if (m_candidate_frame)
- {
- // If control reached here then TryFallbackUnwindPlan had succeeded for Cursor::m_frames[m_frames.size() - 2].
- // It also succeeded to Unwind next 2 frames i.e. m_frames[m_frames.size() - 1] and a frame after that.
- // For Cursor::m_frames[m_frames.size() - 2], reg_ctx_lldb_sp field was already updated during TryFallbackUnwindPlan
- // call above. However, cfa field still needs to be updated. Hence updating it here and then returning.
- if ( !(m_frames[m_frames.size() - 2]->reg_ctx_lldb_sp->GetCFA(m_frames[m_frames.size() - 2]->cfa)))
- return false;
- return true;
- }
+ // If we can get one more frame further then accept that we get back a correct
+ // frame.
+ m_candidate_frame = GetOneMoreFrame(abi);
+ if (m_candidate_frame)
+ return true;
- // The new frame hasn't helped in unwinding. Fall back to the original one as the default unwind
- // plan is usually more reliable then the fallback one.
- m_frames.pop_back();
- m_frames.push_back(new_frame);
+ // We can't go further from the frame returned by GetOneMore frame. Lets try
+ // to get a
+ // different frame with using the fallback unwind plan.
+ if (!m_frames[m_frames.size() - 2]
+ ->reg_ctx_lldb_sp->TryFallbackUnwindPlan()) {
+ // We don't have a valid fallback unwind plan. Accept the frame as it is.
+ // This is a
+ // valid situation when we are at the bottom of the stack.
return true;
-}
+ }
-bool
-UnwindLLDB::DoGetFrameInfoAtIndex (uint32_t idx, addr_t& cfa, addr_t& pc)
-{
- if (m_frames.size() == 0)
- {
- if (!AddFirstFrame())
- return false;
- }
+ // Remove the possibly incorrect frame from the frame list and try to add a
+ // different one with
+ // the newly selected fallback unwind plan.
+ m_frames.pop_back();
+ CursorSP new_frame_v2 = GetOneMoreFrame(abi);
+ if (new_frame_v2 == nullptr) {
+ // We haven't got a new frame from the fallback unwind plan. Accept the
+ // frame from the
+ // original unwind plan. This is a valid situation when we are at the bottom
+ // of the stack.
+ m_frames.push_back(new_frame);
+ return true;
+ }
- ProcessSP process_sp (m_thread.GetProcess());
- ABI *abi = process_sp ? process_sp->GetABI().get() : NULL;
+ // Push the new frame to the list and try to continue from this frame. If we
+ // can get a new frame
+ // then accept it as the correct one.
+ m_frames.push_back(new_frame_v2);
+ m_candidate_frame = GetOneMoreFrame(abi);
+ if (m_candidate_frame) {
+ // If control reached here then TryFallbackUnwindPlan had succeeded for
+ // Cursor::m_frames[m_frames.size() - 2].
+ // It also succeeded to Unwind next 2 frames i.e. m_frames[m_frames.size() -
+ // 1] and a frame after that.
+ // For Cursor::m_frames[m_frames.size() - 2], reg_ctx_lldb_sp field was
+ // already updated during TryFallbackUnwindPlan
+ // call above. However, cfa field still needs to be updated. Hence updating
+ // it here and then returning.
+ if (!(m_frames[m_frames.size() - 2]->reg_ctx_lldb_sp->GetCFA(
+ m_frames[m_frames.size() - 2]->cfa)))
+ return false;
+ return true;
+ }
- while (idx >= m_frames.size() && AddOneMoreFrame (abi))
- ;
+ // The new frame hasn't helped in unwinding. Fall back to the original one as
+ // the default unwind
+ // plan is usually more reliable then the fallback one.
+ m_frames.pop_back();
+ m_frames.push_back(new_frame);
+ return true;
+}
- if (idx < m_frames.size ())
- {
- cfa = m_frames[idx]->cfa;
- pc = m_frames[idx]->start_pc;
- return true;
- }
- return false;
+bool UnwindLLDB::DoGetFrameInfoAtIndex(uint32_t idx, addr_t &cfa, addr_t &pc) {
+ if (m_frames.size() == 0) {
+ if (!AddFirstFrame())
+ return false;
+ }
+
+ ProcessSP process_sp(m_thread.GetProcess());
+ ABI *abi = process_sp ? process_sp->GetABI().get() : NULL;
+
+ while (idx >= m_frames.size() && AddOneMoreFrame(abi))
+ ;
+
+ if (idx < m_frames.size()) {
+ cfa = m_frames[idx]->cfa;
+ pc = m_frames[idx]->start_pc;
+ return true;
+ }
+ return false;
}
lldb::RegisterContextSP
-UnwindLLDB::DoCreateRegisterContextForFrame (StackFrame *frame)
-{
- lldb::RegisterContextSP reg_ctx_sp;
- uint32_t idx = frame->GetConcreteFrameIndex ();
-
- if (idx == 0)
- {
- return m_thread.GetRegisterContext();
- }
-
- if (m_frames.size() == 0)
- {
- if (!AddFirstFrame())
- return reg_ctx_sp;
- }
-
- ProcessSP process_sp (m_thread.GetProcess());
- ABI *abi = process_sp ? process_sp->GetABI().get() : NULL;
-
- while (idx >= m_frames.size())
- {
- if (!AddOneMoreFrame (abi))
- break;
- }
-
- const uint32_t num_frames = m_frames.size();
- if (idx < num_frames)
- {
- Cursor *frame_cursor = m_frames[idx].get();
- reg_ctx_sp = frame_cursor->reg_ctx_lldb_sp;
- }
- return reg_ctx_sp;
+UnwindLLDB::DoCreateRegisterContextForFrame(StackFrame *frame) {
+ lldb::RegisterContextSP reg_ctx_sp;
+ uint32_t idx = frame->GetConcreteFrameIndex();
+
+ if (idx == 0) {
+ return m_thread.GetRegisterContext();
+ }
+
+ if (m_frames.size() == 0) {
+ if (!AddFirstFrame())
+ return reg_ctx_sp;
+ }
+
+ ProcessSP process_sp(m_thread.GetProcess());
+ ABI *abi = process_sp ? process_sp->GetABI().get() : NULL;
+
+ while (idx >= m_frames.size()) {
+ if (!AddOneMoreFrame(abi))
+ break;
+ }
+
+ const uint32_t num_frames = m_frames.size();
+ if (idx < num_frames) {
+ Cursor *frame_cursor = m_frames[idx].get();
+ reg_ctx_sp = frame_cursor->reg_ctx_lldb_sp;
+ }
+ return reg_ctx_sp;
}
UnwindLLDB::RegisterContextLLDBSP
-UnwindLLDB::GetRegisterContextForFrameNum (uint32_t frame_num)
-{
- RegisterContextLLDBSP reg_ctx_sp;
- if (frame_num < m_frames.size())
- reg_ctx_sp = m_frames[frame_num]->reg_ctx_lldb_sp;
- return reg_ctx_sp;
+UnwindLLDB::GetRegisterContextForFrameNum(uint32_t frame_num) {
+ RegisterContextLLDBSP reg_ctx_sp;
+ if (frame_num < m_frames.size())
+ reg_ctx_sp = m_frames[frame_num]->reg_ctx_lldb_sp;
+ return reg_ctx_sp;
}
-bool
-UnwindLLDB::SearchForSavedLocationForRegister (uint32_t lldb_regnum, lldb_private::UnwindLLDB::RegisterLocation ®loc, uint32_t starting_frame_num, bool pc_reg)
-{
- int64_t frame_num = starting_frame_num;
- if (static_cast<size_t>(frame_num) >= m_frames.size())
- return false;
-
- // Never interrogate more than one level while looking for the saved pc value. If the value
- // isn't saved by frame_num, none of the frames lower on the stack will have a useful value.
- if (pc_reg)
- {
- UnwindLLDB::RegisterSearchResult result;
- result = m_frames[frame_num]->reg_ctx_lldb_sp->SavedLocationForRegister (lldb_regnum, regloc);
- if (result == UnwindLLDB::RegisterSearchResult::eRegisterFound)
- return true;
- else
- return false;
- }
- while (frame_num >= 0)
- {
- UnwindLLDB::RegisterSearchResult result;
- result = m_frames[frame_num]->reg_ctx_lldb_sp->SavedLocationForRegister (lldb_regnum, regloc);
-
- // We descended down to the live register context aka stack frame 0 and are reading the value
- // out of a live register.
- if (result == UnwindLLDB::RegisterSearchResult::eRegisterFound
- && regloc.type == UnwindLLDB::RegisterLocation::eRegisterInLiveRegisterContext)
- {
- return true;
- }
-
- // If we have unwind instructions saying that register N is saved in register M in the middle of
- // the stack (and N can equal M here, meaning the register was not used in this function), then
- // change the register number we're looking for to M and keep looking for a concrete location
- // down the stack, or an actual value from a live RegisterContext at frame 0.
- if (result == UnwindLLDB::RegisterSearchResult::eRegisterFound
- && regloc.type == UnwindLLDB::RegisterLocation::eRegisterInRegister
- && frame_num > 0)
- {
- result = UnwindLLDB::RegisterSearchResult::eRegisterNotFound;
- lldb_regnum = regloc.location.register_number;
- }
-
- if (result == UnwindLLDB::RegisterSearchResult::eRegisterFound)
- return true;
- if (result == UnwindLLDB::RegisterSearchResult::eRegisterIsVolatile)
- return false;
- frame_num--;
- }
+bool UnwindLLDB::SearchForSavedLocationForRegister(
+ uint32_t lldb_regnum, lldb_private::UnwindLLDB::RegisterLocation ®loc,
+ uint32_t starting_frame_num, bool pc_reg) {
+ int64_t frame_num = starting_frame_num;
+ if (static_cast<size_t>(frame_num) >= m_frames.size())
return false;
+
+ // Never interrogate more than one level while looking for the saved pc value.
+ // If the value
+ // isn't saved by frame_num, none of the frames lower on the stack will have a
+ // useful value.
+ if (pc_reg) {
+ UnwindLLDB::RegisterSearchResult result;
+ result = m_frames[frame_num]->reg_ctx_lldb_sp->SavedLocationForRegister(
+ lldb_regnum, regloc);
+ if (result == UnwindLLDB::RegisterSearchResult::eRegisterFound)
+ return true;
+ else
+ return false;
+ }
+ while (frame_num >= 0) {
+ UnwindLLDB::RegisterSearchResult result;
+ result = m_frames[frame_num]->reg_ctx_lldb_sp->SavedLocationForRegister(
+ lldb_regnum, regloc);
+
+ // We descended down to the live register context aka stack frame 0 and are
+ // reading the value
+ // out of a live register.
+ if (result == UnwindLLDB::RegisterSearchResult::eRegisterFound &&
+ regloc.type ==
+ UnwindLLDB::RegisterLocation::eRegisterInLiveRegisterContext) {
+ return true;
+ }
+
+ // If we have unwind instructions saying that register N is saved in
+ // register M in the middle of
+ // the stack (and N can equal M here, meaning the register was not used in
+ // this function), then
+ // change the register number we're looking for to M and keep looking for a
+ // concrete location
+ // down the stack, or an actual value from a live RegisterContext at frame
+ // 0.
+ if (result == UnwindLLDB::RegisterSearchResult::eRegisterFound &&
+ regloc.type == UnwindLLDB::RegisterLocation::eRegisterInRegister &&
+ frame_num > 0) {
+ result = UnwindLLDB::RegisterSearchResult::eRegisterNotFound;
+ lldb_regnum = regloc.location.register_number;
+ }
+
+ if (result == UnwindLLDB::RegisterSearchResult::eRegisterFound)
+ return true;
+ if (result == UnwindLLDB::RegisterSearchResult::eRegisterIsVolatile)
+ return false;
+ frame_num--;
+ }
+ return false;
}
Modified: lldb/trunk/source/Plugins/Process/Utility/UnwindLLDB.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Utility/UnwindLLDB.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/Utility/UnwindLLDB.h (original)
+++ lldb/trunk/source/Plugins/Process/Utility/UnwindLLDB.h Tue Sep 6 15:57:50 2016
@@ -16,148 +16,150 @@
// Other libraries and framework includes
// Project includes
-#include "lldb/lldb-public.h"
#include "lldb/Core/ConstString.h"
#include "lldb/Symbol/FuncUnwinders.h"
#include "lldb/Symbol/UnwindPlan.h"
#include "lldb/Target/RegisterContext.h"
#include "lldb/Target/Unwind.h"
+#include "lldb/lldb-public.h"
namespace lldb_private {
class RegisterContextLLDB;
-class UnwindLLDB : public lldb_private::Unwind
-{
-public:
- UnwindLLDB (lldb_private::Thread &thread);
-
- ~UnwindLLDB() override = default;
-
- enum RegisterSearchResult
- {
- eRegisterFound = 0,
- eRegisterNotFound,
- eRegisterIsVolatile
- };
+class UnwindLLDB : public lldb_private::Unwind {
+public:
+ UnwindLLDB(lldb_private::Thread &thread);
+
+ ~UnwindLLDB() override = default;
+
+ enum RegisterSearchResult {
+ eRegisterFound = 0,
+ eRegisterNotFound,
+ eRegisterIsVolatile
+ };
protected:
- friend class lldb_private::RegisterContextLLDB;
+ friend class lldb_private::RegisterContextLLDB;
- struct RegisterLocation {
- enum RegisterLocationTypes
- {
- eRegisterNotSaved = 0, // register was not preserved by callee. If volatile reg, is unavailable
- eRegisterSavedAtMemoryLocation, // register is saved at a specific word of target mem (target_memory_location)
- eRegisterInRegister, // register is available in a (possible other) register (register_number)
- eRegisterSavedAtHostMemoryLocation, // register is saved at a word in lldb's address space
- eRegisterValueInferred, // register val was computed (and is in inferred_value)
- eRegisterInLiveRegisterContext // register value is in a live (stack frame #0) register
- };
- int type;
- union
- {
- lldb::addr_t target_memory_location;
- uint32_t register_number; // in eRegisterKindLLDB register numbering system
- void* host_memory_location;
- uint64_t inferred_value; // eRegisterValueInferred - e.g. stack pointer == cfa + offset
- } location;
+ struct RegisterLocation {
+ enum RegisterLocationTypes {
+ eRegisterNotSaved = 0, // register was not preserved by callee. If
+ // volatile reg, is unavailable
+ eRegisterSavedAtMemoryLocation, // register is saved at a specific word of
+ // target mem (target_memory_location)
+ eRegisterInRegister, // register is available in a (possible other)
+ // register (register_number)
+ eRegisterSavedAtHostMemoryLocation, // register is saved at a word in
+ // lldb's address space
+ eRegisterValueInferred, // register val was computed (and is in
+ // inferred_value)
+ eRegisterInLiveRegisterContext // register value is in a live (stack frame
+ // #0) register
};
-
- void
- DoClear() override
- {
- m_frames.clear();
- m_candidate_frame.reset();
- m_unwind_complete = false;
- }
-
- uint32_t
- DoGetFrameCount() override;
-
- bool
- DoGetFrameInfoAtIndex(uint32_t frame_idx,
- lldb::addr_t& cfa,
- lldb::addr_t& start_pc) override;
-
- lldb::RegisterContextSP
- DoCreateRegisterContextForFrame(lldb_private::StackFrame *frame) override;
-
- typedef std::shared_ptr<RegisterContextLLDB> RegisterContextLLDBSP;
-
- // Needed to retrieve the "next" frame (e.g. frame 2 needs to retrieve frame 1's RegisterContextLLDB)
- // The RegisterContext for frame_num must already exist or this returns an empty shared pointer.
- RegisterContextLLDBSP
- GetRegisterContextForFrameNum (uint32_t frame_num);
-
- // Iterate over the RegisterContextLLDB's in our m_frames vector, look for the first one that
- // has a saved location for this reg.
- bool
- SearchForSavedLocationForRegister (uint32_t lldb_regnum, lldb_private::UnwindLLDB::RegisterLocation ®loc, uint32_t starting_frame_num, bool pc_register);
-
-
- //------------------------------------------------------------------
- /// Provide the list of user-specified trap handler functions
- ///
- /// The Platform is one source of trap handler function names; that
- /// may be augmented via a setting. The setting needs to be converted
- /// into an array of ConstStrings before it can be used - we only want
- /// to do that once per thread so it's here in the UnwindLLDB object.
- ///
- /// @return
- /// Vector of ConstStrings of trap handler function names. May be
- /// empty.
- //------------------------------------------------------------------
- const std::vector<ConstString> &
- GetUserSpecifiedTrapHandlerFunctionNames ()
- {
- return m_user_supplied_trap_handler_functions;
- }
+ int type;
+ union {
+ lldb::addr_t target_memory_location;
+ uint32_t
+ register_number; // in eRegisterKindLLDB register numbering system
+ void *host_memory_location;
+ uint64_t inferred_value; // eRegisterValueInferred - e.g. stack pointer ==
+ // cfa + offset
+ } location;
+ };
+
+ void DoClear() override {
+ m_frames.clear();
+ m_candidate_frame.reset();
+ m_unwind_complete = false;
+ }
+
+ uint32_t DoGetFrameCount() override;
+
+ bool DoGetFrameInfoAtIndex(uint32_t frame_idx, lldb::addr_t &cfa,
+ lldb::addr_t &start_pc) override;
+
+ lldb::RegisterContextSP
+ DoCreateRegisterContextForFrame(lldb_private::StackFrame *frame) override;
+
+ typedef std::shared_ptr<RegisterContextLLDB> RegisterContextLLDBSP;
+
+ // Needed to retrieve the "next" frame (e.g. frame 2 needs to retrieve frame
+ // 1's RegisterContextLLDB)
+ // The RegisterContext for frame_num must already exist or this returns an
+ // empty shared pointer.
+ RegisterContextLLDBSP GetRegisterContextForFrameNum(uint32_t frame_num);
+
+ // Iterate over the RegisterContextLLDB's in our m_frames vector, look for the
+ // first one that
+ // has a saved location for this reg.
+ bool SearchForSavedLocationForRegister(
+ uint32_t lldb_regnum, lldb_private::UnwindLLDB::RegisterLocation ®loc,
+ uint32_t starting_frame_num, bool pc_register);
+
+ //------------------------------------------------------------------
+ /// Provide the list of user-specified trap handler functions
+ ///
+ /// The Platform is one source of trap handler function names; that
+ /// may be augmented via a setting. The setting needs to be converted
+ /// into an array of ConstStrings before it can be used - we only want
+ /// to do that once per thread so it's here in the UnwindLLDB object.
+ ///
+ /// @return
+ /// Vector of ConstStrings of trap handler function names. May be
+ /// empty.
+ //------------------------------------------------------------------
+ const std::vector<ConstString> &GetUserSpecifiedTrapHandlerFunctionNames() {
+ return m_user_supplied_trap_handler_functions;
+ }
private:
- struct Cursor
- {
- lldb::addr_t start_pc; // The start address of the function/symbol for this frame - current pc if unknown
- lldb::addr_t cfa; // The canonical frame address for this stack frame
- lldb_private::SymbolContext sctx; // A symbol context we'll contribute to & provide to the StackFrame creation
- RegisterContextLLDBSP reg_ctx_lldb_sp; // These are all RegisterContextLLDB's
-
- Cursor () : start_pc (LLDB_INVALID_ADDRESS), cfa (LLDB_INVALID_ADDRESS), sctx(), reg_ctx_lldb_sp() { }
- private:
- DISALLOW_COPY_AND_ASSIGN (Cursor);
- };
+ struct Cursor {
+ lldb::addr_t start_pc; // The start address of the function/symbol for this
+ // frame - current pc if unknown
+ lldb::addr_t cfa; // The canonical frame address for this stack frame
+ lldb_private::SymbolContext sctx; // A symbol context we'll contribute to &
+ // provide to the StackFrame creation
+ RegisterContextLLDBSP
+ reg_ctx_lldb_sp; // These are all RegisterContextLLDB's
- typedef std::shared_ptr<Cursor> CursorSP;
- std::vector<CursorSP> m_frames;
- CursorSP m_candidate_frame;
- bool m_unwind_complete; // If this is true, we've enumerated all the frames in the stack, and m_frames.size() is the
- // number of frames, etc. Otherwise we've only gone as far as directly asked, and m_frames.size()
- // is how far we've currently gone.
-
- std::vector<ConstString> m_user_supplied_trap_handler_functions;
-
- //-----------------------------------------------------------------
- // Check if Full UnwindPlan of First frame is valid or not.
- // If not then try Fallback UnwindPlan of the frame. If Fallback
- // UnwindPlan succeeds then update the Full UnwindPlan with the
- // Fallback UnwindPlan.
- //-----------------------------------------------------------------
- void
- UpdateUnwindPlanForFirstFrameIfInvalid (ABI* abi);
-
- CursorSP
- GetOneMoreFrame (ABI* abi);
-
- bool
- AddOneMoreFrame (ABI *abi);
-
- bool
- AddFirstFrame ();
-
- //------------------------------------------------------------------
- // For UnwindLLDB only
- //------------------------------------------------------------------
- DISALLOW_COPY_AND_ASSIGN (UnwindLLDB);
+ Cursor()
+ : start_pc(LLDB_INVALID_ADDRESS), cfa(LLDB_INVALID_ADDRESS), sctx(),
+ reg_ctx_lldb_sp() {}
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(Cursor);
+ };
+
+ typedef std::shared_ptr<Cursor> CursorSP;
+ std::vector<CursorSP> m_frames;
+ CursorSP m_candidate_frame;
+ bool m_unwind_complete; // If this is true, we've enumerated all the frames in
+ // the stack, and m_frames.size() is the
+ // number of frames, etc. Otherwise we've only gone as far as directly asked,
+ // and m_frames.size()
+ // is how far we've currently gone.
+
+ std::vector<ConstString> m_user_supplied_trap_handler_functions;
+
+ //-----------------------------------------------------------------
+ // Check if Full UnwindPlan of First frame is valid or not.
+ // If not then try Fallback UnwindPlan of the frame. If Fallback
+ // UnwindPlan succeeds then update the Full UnwindPlan with the
+ // Fallback UnwindPlan.
+ //-----------------------------------------------------------------
+ void UpdateUnwindPlanForFirstFrameIfInvalid(ABI *abi);
+
+ CursorSP GetOneMoreFrame(ABI *abi);
+
+ bool AddOneMoreFrame(ABI *abi);
+
+ bool AddFirstFrame();
+
+ //------------------------------------------------------------------
+ // For UnwindLLDB only
+ //------------------------------------------------------------------
+ DISALLOW_COPY_AND_ASSIGN(UnwindLLDB);
};
} // namespace lldb_private
Modified: lldb/trunk/source/Plugins/Process/Utility/UnwindMacOSXFrameBackchain.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Utility/UnwindMacOSXFrameBackchain.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/Utility/UnwindMacOSXFrameBackchain.cpp (original)
+++ lldb/trunk/source/Plugins/Process/Utility/UnwindMacOSXFrameBackchain.cpp Tue Sep 6 15:57:50 2016
@@ -13,8 +13,8 @@
// Project includes
#include "lldb/Core/ArchSpec.h"
#include "lldb/Symbol/Function.h"
-#include "lldb/Symbol/Symbol.h"
#include "lldb/Symbol/ObjectFile.h"
+#include "lldb/Symbol/Symbol.h"
#include "lldb/Target/ExecutionContext.h"
#include "lldb/Target/Process.h"
#include "lldb/Target/Target.h"
@@ -25,251 +25,230 @@
using namespace lldb;
using namespace lldb_private;
-UnwindMacOSXFrameBackchain::UnwindMacOSXFrameBackchain (Thread &thread) :
- Unwind (thread),
- m_cursors()
-{
-}
+UnwindMacOSXFrameBackchain::UnwindMacOSXFrameBackchain(Thread &thread)
+ : Unwind(thread), m_cursors() {}
-uint32_t
-UnwindMacOSXFrameBackchain::DoGetFrameCount()
-{
- if (m_cursors.empty())
- {
- ExecutionContext exe_ctx (m_thread.shared_from_this());
- Target *target = exe_ctx.GetTargetPtr();
- if (target)
- {
- const ArchSpec& target_arch = target->GetArchitecture ();
- // Frame zero should always be supplied by the thread...
- exe_ctx.SetFrameSP (m_thread.GetStackFrameAtIndex (0));
-
- if (target_arch.GetAddressByteSize() == 8)
- GetStackFrameData_x86_64 (exe_ctx);
- else
- GetStackFrameData_i386 (exe_ctx);
- }
- }
- return m_cursors.size();
+uint32_t UnwindMacOSXFrameBackchain::DoGetFrameCount() {
+ if (m_cursors.empty()) {
+ ExecutionContext exe_ctx(m_thread.shared_from_this());
+ Target *target = exe_ctx.GetTargetPtr();
+ if (target) {
+ const ArchSpec &target_arch = target->GetArchitecture();
+ // Frame zero should always be supplied by the thread...
+ exe_ctx.SetFrameSP(m_thread.GetStackFrameAtIndex(0));
+
+ if (target_arch.GetAddressByteSize() == 8)
+ GetStackFrameData_x86_64(exe_ctx);
+ else
+ GetStackFrameData_i386(exe_ctx);
+ }
+ }
+ return m_cursors.size();
+}
+
+bool UnwindMacOSXFrameBackchain::DoGetFrameInfoAtIndex(uint32_t idx,
+ addr_t &cfa,
+ addr_t &pc) {
+ const uint32_t frame_count = GetFrameCount();
+ if (idx < frame_count) {
+ if (m_cursors[idx].pc == LLDB_INVALID_ADDRESS)
+ return false;
+ if (m_cursors[idx].fp == LLDB_INVALID_ADDRESS)
+ return false;
+
+ pc = m_cursors[idx].pc;
+ cfa = m_cursors[idx].fp;
+
+ return true;
+ }
+ return false;
}
-bool
-UnwindMacOSXFrameBackchain::DoGetFrameInfoAtIndex (uint32_t idx, addr_t& cfa, addr_t& pc)
-{
- const uint32_t frame_count = GetFrameCount();
- if (idx < frame_count)
- {
- if (m_cursors[idx].pc == LLDB_INVALID_ADDRESS)
- return false;
- if (m_cursors[idx].fp == LLDB_INVALID_ADDRESS)
- return false;
-
- pc = m_cursors[idx].pc;
- cfa = m_cursors[idx].fp;
-
- return true;
- }
- return false;
-}
-
lldb::RegisterContextSP
-UnwindMacOSXFrameBackchain::DoCreateRegisterContextForFrame (StackFrame *frame)
-{
- lldb::RegisterContextSP reg_ctx_sp;
- uint32_t concrete_idx = frame->GetConcreteFrameIndex ();
- const uint32_t frame_count = GetFrameCount();
- if (concrete_idx < frame_count)
- reg_ctx_sp.reset (new RegisterContextMacOSXFrameBackchain (m_thread, concrete_idx, m_cursors[concrete_idx]));
- return reg_ctx_sp;
-}
+UnwindMacOSXFrameBackchain::DoCreateRegisterContextForFrame(StackFrame *frame) {
+ lldb::RegisterContextSP reg_ctx_sp;
+ uint32_t concrete_idx = frame->GetConcreteFrameIndex();
+ const uint32_t frame_count = GetFrameCount();
+ if (concrete_idx < frame_count)
+ reg_ctx_sp.reset(new RegisterContextMacOSXFrameBackchain(
+ m_thread, concrete_idx, m_cursors[concrete_idx]));
+ return reg_ctx_sp;
+}
+
+size_t UnwindMacOSXFrameBackchain::GetStackFrameData_i386(
+ const ExecutionContext &exe_ctx) {
+ m_cursors.clear();
+
+ StackFrame *first_frame = exe_ctx.GetFramePtr();
+
+ Process *process = exe_ctx.GetProcessPtr();
+ if (process == NULL)
+ return 0;
+
+ std::pair<lldb::addr_t, lldb::addr_t> fp_pc_pair;
+
+ struct Frame_i386 {
+ uint32_t fp;
+ uint32_t pc;
+ };
+
+ RegisterContext *reg_ctx = m_thread.GetRegisterContext().get();
+ assert(reg_ctx);
+
+ Cursor cursor;
+ cursor.pc = reg_ctx->GetPC(LLDB_INVALID_ADDRESS);
+ cursor.fp = reg_ctx->GetFP(0);
+
+ Frame_i386 frame = {static_cast<uint32_t>(cursor.fp),
+ static_cast<uint32_t>(cursor.pc)};
+
+ m_cursors.push_back(cursor);
+
+ const size_t k_frame_size = sizeof(frame);
+ Error error;
+ while (frame.fp != 0 && frame.pc != 0 && ((frame.fp & 7) == 0)) {
+ // Read both the FP and PC (8 bytes)
+ if (process->ReadMemory(frame.fp, &frame.fp, k_frame_size, error) !=
+ k_frame_size)
+ break;
+ if (frame.pc >= 0x1000) {
+ cursor.pc = frame.pc;
+ cursor.fp = frame.fp;
+ m_cursors.push_back(cursor);
+ }
+ }
+ if (!m_cursors.empty()) {
+ lldb::addr_t first_frame_pc = m_cursors.front().pc;
+ if (first_frame_pc != LLDB_INVALID_ADDRESS) {
+ const uint32_t resolve_scope =
+ eSymbolContextModule | eSymbolContextCompUnit |
+ eSymbolContextFunction | eSymbolContextSymbol;
+
+ SymbolContext first_frame_sc(
+ first_frame->GetSymbolContext(resolve_scope));
+ const AddressRange *addr_range_ptr = NULL;
+ AddressRange range;
+ if (first_frame_sc.function)
+ addr_range_ptr = &first_frame_sc.function->GetAddressRange();
+ else if (first_frame_sc.symbol) {
+ range.GetBaseAddress() = first_frame_sc.symbol->GetAddress();
+ range.SetByteSize(first_frame_sc.symbol->GetByteSize());
+ addr_range_ptr = ⦥
+ }
+
+ if (addr_range_ptr) {
+ if (first_frame->GetFrameCodeAddress() ==
+ addr_range_ptr->GetBaseAddress()) {
+ // We are at the first instruction, so we can recover the
+ // previous PC by dereferencing the SP
+ lldb::addr_t first_frame_sp = reg_ctx->GetSP(0);
+ // Read the real second frame return address into frame.pc
+ if (first_frame_sp &&
+ process->ReadMemory(first_frame_sp, &frame.pc, sizeof(frame.pc),
+ error) == sizeof(frame.pc)) {
+ cursor.fp = m_cursors.front().fp;
+ cursor.pc = frame.pc; // Set the new second frame PC
-size_t
-UnwindMacOSXFrameBackchain::GetStackFrameData_i386 (const ExecutionContext &exe_ctx)
-{
- m_cursors.clear();
-
- StackFrame *first_frame = exe_ctx.GetFramePtr();
-
- Process *process = exe_ctx.GetProcessPtr();
- if (process == NULL)
- return 0;
-
- std::pair<lldb::addr_t, lldb::addr_t> fp_pc_pair;
-
- struct Frame_i386
- {
- uint32_t fp;
- uint32_t pc;
- };
-
- RegisterContext *reg_ctx = m_thread.GetRegisterContext().get();
- assert (reg_ctx);
-
- Cursor cursor;
- cursor.pc = reg_ctx->GetPC (LLDB_INVALID_ADDRESS);
- cursor.fp = reg_ctx->GetFP (0);
-
- Frame_i386 frame = { static_cast<uint32_t>(cursor.fp), static_cast<uint32_t>(cursor.pc) };
-
- m_cursors.push_back(cursor);
-
- const size_t k_frame_size = sizeof(frame);
- Error error;
- while (frame.fp != 0 && frame.pc != 0 && ((frame.fp & 7) == 0))
- {
- // Read both the FP and PC (8 bytes)
- if (process->ReadMemory (frame.fp, &frame.fp, k_frame_size, error) != k_frame_size)
- break;
- if (frame.pc >= 0x1000)
- {
- cursor.pc = frame.pc;
- cursor.fp = frame.fp;
- m_cursors.push_back (cursor);
- }
- }
- if (!m_cursors.empty())
- {
- lldb::addr_t first_frame_pc = m_cursors.front().pc;
- if (first_frame_pc != LLDB_INVALID_ADDRESS)
- {
- const uint32_t resolve_scope = eSymbolContextModule |
- eSymbolContextCompUnit |
- eSymbolContextFunction |
- eSymbolContextSymbol;
-
- SymbolContext first_frame_sc (first_frame->GetSymbolContext(resolve_scope));
- const AddressRange *addr_range_ptr = NULL;
- AddressRange range;
- if (first_frame_sc.function)
- addr_range_ptr = &first_frame_sc.function->GetAddressRange();
- else if (first_frame_sc.symbol)
- {
- range.GetBaseAddress() = first_frame_sc.symbol->GetAddress();
- range.SetByteSize (first_frame_sc.symbol->GetByteSize());
- addr_range_ptr = ⦥
- }
-
- if (addr_range_ptr)
- {
- if (first_frame->GetFrameCodeAddress() == addr_range_ptr->GetBaseAddress())
- {
- // We are at the first instruction, so we can recover the
- // previous PC by dereferencing the SP
- lldb::addr_t first_frame_sp = reg_ctx->GetSP (0);
- // Read the real second frame return address into frame.pc
- if (first_frame_sp && process->ReadMemory (first_frame_sp, &frame.pc, sizeof(frame.pc), error) == sizeof(frame.pc))
- {
- cursor.fp = m_cursors.front().fp;
- cursor.pc = frame.pc; // Set the new second frame PC
-
- // Insert the second frame
- m_cursors.insert(m_cursors.begin()+1, cursor);
-
- m_cursors.front().fp = first_frame_sp;
- }
- }
- }
+ // Insert the second frame
+ m_cursors.insert(m_cursors.begin() + 1, cursor);
+
+ m_cursors.front().fp = first_frame_sp;
+ }
}
+ }
}
-// uint32_t i=0;
-// printf(" PC FP\n");
-// printf(" ------------------ ------------------ \n");
-// for (i=0; i<m_cursors.size(); ++i)
-// {
-// printf("[%3u] 0x%16.16" PRIx64 " 0x%16.16" PRIx64 "\n", i, m_cursors[i].pc, m_cursors[i].fp);
-// }
- return m_cursors.size();
-}
+ }
+ // uint32_t i=0;
+ // printf(" PC FP\n");
+ // printf(" ------------------ ------------------ \n");
+ // for (i=0; i<m_cursors.size(); ++i)
+ // {
+ // printf("[%3u] 0x%16.16" PRIx64 " 0x%16.16" PRIx64 "\n", i,
+ // m_cursors[i].pc, m_cursors[i].fp);
+ // }
+ return m_cursors.size();
+}
+
+size_t UnwindMacOSXFrameBackchain::GetStackFrameData_x86_64(
+ const ExecutionContext &exe_ctx) {
+ m_cursors.clear();
+
+ Process *process = exe_ctx.GetProcessPtr();
+ if (process == NULL)
+ return 0;
+
+ StackFrame *first_frame = exe_ctx.GetFramePtr();
+
+ std::pair<lldb::addr_t, lldb::addr_t> fp_pc_pair;
+
+ struct Frame_x86_64 {
+ uint64_t fp;
+ uint64_t pc;
+ };
+
+ RegisterContext *reg_ctx = m_thread.GetRegisterContext().get();
+ assert(reg_ctx);
+
+ Cursor cursor;
+ cursor.pc = reg_ctx->GetPC(LLDB_INVALID_ADDRESS);
+ cursor.fp = reg_ctx->GetFP(0);
+
+ Frame_x86_64 frame = {cursor.fp, cursor.pc};
+
+ m_cursors.push_back(cursor);
+ Error error;
+ const size_t k_frame_size = sizeof(frame);
+ while (frame.fp != 0 && frame.pc != 0 && ((frame.fp & 7) == 0)) {
+ // Read both the FP and PC (16 bytes)
+ if (process->ReadMemory(frame.fp, &frame.fp, k_frame_size, error) !=
+ k_frame_size)
+ break;
+
+ if (frame.pc >= 0x1000) {
+ cursor.pc = frame.pc;
+ cursor.fp = frame.fp;
+ m_cursors.push_back(cursor);
+ }
+ }
+ if (!m_cursors.empty()) {
+ lldb::addr_t first_frame_pc = m_cursors.front().pc;
+ if (first_frame_pc != LLDB_INVALID_ADDRESS) {
+ const uint32_t resolve_scope =
+ eSymbolContextModule | eSymbolContextCompUnit |
+ eSymbolContextFunction | eSymbolContextSymbol;
+
+ SymbolContext first_frame_sc(
+ first_frame->GetSymbolContext(resolve_scope));
+ const AddressRange *addr_range_ptr = NULL;
+ AddressRange range;
+ if (first_frame_sc.function)
+ addr_range_ptr = &first_frame_sc.function->GetAddressRange();
+ else if (first_frame_sc.symbol) {
+ range.GetBaseAddress() = first_frame_sc.symbol->GetAddress();
+ range.SetByteSize(first_frame_sc.symbol->GetByteSize());
+ addr_range_ptr = ⦥
+ }
+
+ if (addr_range_ptr) {
+ if (first_frame->GetFrameCodeAddress() ==
+ addr_range_ptr->GetBaseAddress()) {
+ // We are at the first instruction, so we can recover the
+ // previous PC by dereferencing the SP
+ lldb::addr_t first_frame_sp = reg_ctx->GetSP(0);
+ // Read the real second frame return address into frame.pc
+ if (process->ReadMemory(first_frame_sp, &frame.pc, sizeof(frame.pc),
+ error) == sizeof(frame.pc)) {
+ cursor.fp = m_cursors.front().fp;
+ cursor.pc = frame.pc; // Set the new second frame PC
+ // Insert the second frame
+ m_cursors.insert(m_cursors.begin() + 1, cursor);
-size_t
-UnwindMacOSXFrameBackchain::GetStackFrameData_x86_64 (const ExecutionContext &exe_ctx)
-{
- m_cursors.clear();
-
- Process *process = exe_ctx.GetProcessPtr();
- if (process == NULL)
- return 0;
-
- StackFrame *first_frame = exe_ctx.GetFramePtr();
-
- std::pair<lldb::addr_t, lldb::addr_t> fp_pc_pair;
-
- struct Frame_x86_64
- {
- uint64_t fp;
- uint64_t pc;
- };
-
- RegisterContext *reg_ctx = m_thread.GetRegisterContext().get();
- assert (reg_ctx);
-
- Cursor cursor;
- cursor.pc = reg_ctx->GetPC (LLDB_INVALID_ADDRESS);
- cursor.fp = reg_ctx->GetFP (0);
-
- Frame_x86_64 frame = { cursor.fp, cursor.pc };
-
- m_cursors.push_back(cursor);
- Error error;
- const size_t k_frame_size = sizeof(frame);
- while (frame.fp != 0 && frame.pc != 0 && ((frame.fp & 7) == 0))
- {
- // Read both the FP and PC (16 bytes)
- if (process->ReadMemory (frame.fp, &frame.fp, k_frame_size, error) != k_frame_size)
- break;
-
- if (frame.pc >= 0x1000)
- {
- cursor.pc = frame.pc;
- cursor.fp = frame.fp;
- m_cursors.push_back (cursor);
- }
- }
- if (!m_cursors.empty())
- {
- lldb::addr_t first_frame_pc = m_cursors.front().pc;
- if (first_frame_pc != LLDB_INVALID_ADDRESS)
- {
- const uint32_t resolve_scope = eSymbolContextModule |
- eSymbolContextCompUnit |
- eSymbolContextFunction |
- eSymbolContextSymbol;
-
- SymbolContext first_frame_sc(first_frame->GetSymbolContext(resolve_scope));
- const AddressRange *addr_range_ptr = NULL;
- AddressRange range;
- if (first_frame_sc.function)
- addr_range_ptr = &first_frame_sc.function->GetAddressRange();
- else if (first_frame_sc.symbol)
- {
- range.GetBaseAddress() = first_frame_sc.symbol->GetAddress();
- range.SetByteSize (first_frame_sc.symbol->GetByteSize());
- addr_range_ptr = ⦥
- }
-
- if (addr_range_ptr)
- {
- if (first_frame->GetFrameCodeAddress() == addr_range_ptr->GetBaseAddress())
- {
- // We are at the first instruction, so we can recover the
- // previous PC by dereferencing the SP
- lldb::addr_t first_frame_sp = reg_ctx->GetSP (0);
- // Read the real second frame return address into frame.pc
- if (process->ReadMemory (first_frame_sp, &frame.pc, sizeof(frame.pc), error) == sizeof(frame.pc))
- {
- cursor.fp = m_cursors.front().fp;
- cursor.pc = frame.pc; // Set the new second frame PC
-
- // Insert the second frame
- m_cursors.insert(m_cursors.begin()+1, cursor);
-
- m_cursors.front().fp = first_frame_sp;
- }
- }
- }
+ m_cursors.front().fp = first_frame_sp;
+ }
}
+ }
}
- return m_cursors.size();
+ }
+ return m_cursors.size();
}
-
Modified: lldb/trunk/source/Plugins/Process/Utility/UnwindMacOSXFrameBackchain.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Utility/UnwindMacOSXFrameBackchain.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/Utility/UnwindMacOSXFrameBackchain.h (original)
+++ lldb/trunk/source/Plugins/Process/Utility/UnwindMacOSXFrameBackchain.h Tue Sep 6 15:57:50 2016
@@ -16,55 +16,45 @@
// Other libraries and framework includes
// Project includes
-#include "lldb/lldb-private.h"
#include "lldb/Target/Unwind.h"
+#include "lldb/lldb-private.h"
-class UnwindMacOSXFrameBackchain : public lldb_private::Unwind
-{
-public:
- UnwindMacOSXFrameBackchain (lldb_private::Thread &thread);
+class UnwindMacOSXFrameBackchain : public lldb_private::Unwind {
+public:
+ UnwindMacOSXFrameBackchain(lldb_private::Thread &thread);
- ~UnwindMacOSXFrameBackchain() override = default;
+ ~UnwindMacOSXFrameBackchain() override = default;
protected:
- void
- DoClear() override
- {
- m_cursors.clear();
- }
-
- uint32_t
- DoGetFrameCount() override;
-
- bool
- DoGetFrameInfoAtIndex(uint32_t frame_idx,
- lldb::addr_t& cfa,
- lldb::addr_t& pc) override;
-
- lldb::RegisterContextSP
- DoCreateRegisterContextForFrame(lldb_private::StackFrame *frame) override;
-
- friend class RegisterContextMacOSXFrameBackchain;
-
- struct Cursor
- {
- lldb::addr_t pc; // Program counter
- lldb::addr_t fp; // Frame pointer for us with backchain
- };
+ void DoClear() override { m_cursors.clear(); }
+
+ uint32_t DoGetFrameCount() override;
+
+ bool DoGetFrameInfoAtIndex(uint32_t frame_idx, lldb::addr_t &cfa,
+ lldb::addr_t &pc) override;
+
+ lldb::RegisterContextSP
+ DoCreateRegisterContextForFrame(lldb_private::StackFrame *frame) override;
+
+ friend class RegisterContextMacOSXFrameBackchain;
+
+ struct Cursor {
+ lldb::addr_t pc; // Program counter
+ lldb::addr_t fp; // Frame pointer for us with backchain
+ };
private:
- std::vector<Cursor> m_cursors;
+ std::vector<Cursor> m_cursors;
- size_t
- GetStackFrameData_i386 (const lldb_private::ExecutionContext &exe_ctx);
+ size_t GetStackFrameData_i386(const lldb_private::ExecutionContext &exe_ctx);
- size_t
- GetStackFrameData_x86_64 (const lldb_private::ExecutionContext &exe_ctx);
+ size_t
+ GetStackFrameData_x86_64(const lldb_private::ExecutionContext &exe_ctx);
- //------------------------------------------------------------------
- // For UnwindMacOSXFrameBackchain only
- //------------------------------------------------------------------
- DISALLOW_COPY_AND_ASSIGN (UnwindMacOSXFrameBackchain);
+ //------------------------------------------------------------------
+ // For UnwindMacOSXFrameBackchain only
+ //------------------------------------------------------------------
+ DISALLOW_COPY_AND_ASSIGN(UnwindMacOSXFrameBackchain);
};
#endif // lldb_UnwindMacOSXFrameBackchain_h_
Modified: lldb/trunk/source/Plugins/Process/Utility/lldb-arm-register-enums.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Utility/lldb-arm-register-enums.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/Utility/lldb-arm-register-enums.h (original)
+++ lldb/trunk/source/Plugins/Process/Utility/lldb-arm-register-enums.h Tue Sep 6 15:57:50 2016
@@ -10,192 +10,193 @@
#ifndef lldb_arm_register_enums_h
#define lldb_arm_register_enums_h
-namespace lldb_private
-{
- // LLDB register codes (e.g. RegisterKind == eRegisterKindLLDB)
-
- //---------------------------------------------------------------------------
- // Internal codes for all ARM registers.
- //---------------------------------------------------------------------------
- enum
- {
- k_first_gpr_arm = 0,
- gpr_r0_arm = k_first_gpr_arm,
- gpr_r1_arm,
- gpr_r2_arm,
- gpr_r3_arm,
- gpr_r4_arm,
- gpr_r5_arm,
- gpr_r6_arm,
- gpr_r7_arm,
- gpr_r8_arm,
- gpr_r9_arm,
- gpr_r10_arm,
- gpr_r11_arm,
- gpr_r12_arm,
- gpr_r13_arm, gpr_sp_arm = gpr_r13_arm,
- gpr_r14_arm, gpr_lr_arm = gpr_r14_arm,
- gpr_r15_arm, gpr_pc_arm = gpr_r15_arm,
- gpr_cpsr_arm,
-
- k_last_gpr_arm = gpr_cpsr_arm,
-
- k_first_fpr_arm,
- fpu_s0_arm = k_first_fpr_arm,
- fpu_s1_arm,
- fpu_s2_arm,
- fpu_s3_arm,
- fpu_s4_arm,
- fpu_s5_arm,
- fpu_s6_arm,
- fpu_s7_arm,
- fpu_s8_arm,
- fpu_s9_arm,
- fpu_s10_arm,
- fpu_s11_arm,
- fpu_s12_arm,
- fpu_s13_arm,
- fpu_s14_arm,
- fpu_s15_arm,
- fpu_s16_arm,
- fpu_s17_arm,
- fpu_s18_arm,
- fpu_s19_arm,
- fpu_s20_arm,
- fpu_s21_arm,
- fpu_s22_arm,
- fpu_s23_arm,
- fpu_s24_arm,
- fpu_s25_arm,
- fpu_s26_arm,
- fpu_s27_arm,
- fpu_s28_arm,
- fpu_s29_arm,
- fpu_s30_arm,
- fpu_s31_arm,
- fpu_fpscr_arm,
- fpu_d0_arm,
- fpu_d1_arm,
- fpu_d2_arm,
- fpu_d3_arm,
- fpu_d4_arm,
- fpu_d5_arm,
- fpu_d6_arm,
- fpu_d7_arm,
- fpu_d8_arm,
- fpu_d9_arm,
- fpu_d10_arm,
- fpu_d11_arm,
- fpu_d12_arm,
- fpu_d13_arm,
- fpu_d14_arm,
- fpu_d15_arm,
- fpu_d16_arm,
- fpu_d17_arm,
- fpu_d18_arm,
- fpu_d19_arm,
- fpu_d20_arm,
- fpu_d21_arm,
- fpu_d22_arm,
- fpu_d23_arm,
- fpu_d24_arm,
- fpu_d25_arm,
- fpu_d26_arm,
- fpu_d27_arm,
- fpu_d28_arm,
- fpu_d29_arm,
- fpu_d30_arm,
- fpu_d31_arm,
- fpu_q0_arm,
- fpu_q1_arm,
- fpu_q2_arm,
- fpu_q3_arm,
- fpu_q4_arm,
- fpu_q5_arm,
- fpu_q6_arm,
- fpu_q7_arm,
- fpu_q8_arm,
- fpu_q9_arm,
- fpu_q10_arm,
- fpu_q11_arm,
- fpu_q12_arm,
- fpu_q13_arm,
- fpu_q14_arm,
- fpu_q15_arm,
- k_last_fpr_arm = fpu_q15_arm,
- exc_exception_arm,
- exc_fsr_arm,
- exc_far_arm,
-
- dbg_bvr0_arm,
- dbg_bvr1_arm,
- dbg_bvr2_arm,
- dbg_bvr3_arm,
- dbg_bvr4_arm,
- dbg_bvr5_arm,
- dbg_bvr6_arm,
- dbg_bvr7_arm,
- dbg_bvr8_arm,
- dbg_bvr9_arm,
- dbg_bvr10_arm,
- dbg_bvr11_arm,
- dbg_bvr12_arm,
- dbg_bvr13_arm,
- dbg_bvr14_arm,
- dbg_bvr15_arm,
- dbg_bcr0_arm,
- dbg_bcr1_arm,
- dbg_bcr2_arm,
- dbg_bcr3_arm,
- dbg_bcr4_arm,
- dbg_bcr5_arm,
- dbg_bcr6_arm,
- dbg_bcr7_arm,
- dbg_bcr8_arm,
- dbg_bcr9_arm,
- dbg_bcr10_arm,
- dbg_bcr11_arm,
- dbg_bcr12_arm,
- dbg_bcr13_arm,
- dbg_bcr14_arm,
- dbg_bcr15_arm,
- dbg_wvr0_arm,
- dbg_wvr1_arm,
- dbg_wvr2_arm,
- dbg_wvr3_arm,
- dbg_wvr4_arm,
- dbg_wvr5_arm,
- dbg_wvr6_arm,
- dbg_wvr7_arm,
- dbg_wvr8_arm,
- dbg_wvr9_arm,
- dbg_wvr10_arm,
- dbg_wvr11_arm,
- dbg_wvr12_arm,
- dbg_wvr13_arm,
- dbg_wvr14_arm,
- dbg_wvr15_arm,
- dbg_wcr0_arm,
- dbg_wcr1_arm,
- dbg_wcr2_arm,
- dbg_wcr3_arm,
- dbg_wcr4_arm,
- dbg_wcr5_arm,
- dbg_wcr6_arm,
- dbg_wcr7_arm,
- dbg_wcr8_arm,
- dbg_wcr9_arm,
- dbg_wcr10_arm,
- dbg_wcr11_arm,
- dbg_wcr12_arm,
- dbg_wcr13_arm,
- dbg_wcr14_arm,
- dbg_wcr15_arm,
-
- k_num_registers_arm,
- k_num_gpr_registers_arm = k_last_gpr_arm - k_first_gpr_arm + 1,
- k_num_fpr_registers_arm = k_last_fpr_arm - k_first_fpr_arm + 1
- };
+namespace lldb_private {
+// LLDB register codes (e.g. RegisterKind == eRegisterKindLLDB)
+
+//---------------------------------------------------------------------------
+// Internal codes for all ARM registers.
+//---------------------------------------------------------------------------
+enum {
+ k_first_gpr_arm = 0,
+ gpr_r0_arm = k_first_gpr_arm,
+ gpr_r1_arm,
+ gpr_r2_arm,
+ gpr_r3_arm,
+ gpr_r4_arm,
+ gpr_r5_arm,
+ gpr_r6_arm,
+ gpr_r7_arm,
+ gpr_r8_arm,
+ gpr_r9_arm,
+ gpr_r10_arm,
+ gpr_r11_arm,
+ gpr_r12_arm,
+ gpr_r13_arm,
+ gpr_sp_arm = gpr_r13_arm,
+ gpr_r14_arm,
+ gpr_lr_arm = gpr_r14_arm,
+ gpr_r15_arm,
+ gpr_pc_arm = gpr_r15_arm,
+ gpr_cpsr_arm,
+
+ k_last_gpr_arm = gpr_cpsr_arm,
+
+ k_first_fpr_arm,
+ fpu_s0_arm = k_first_fpr_arm,
+ fpu_s1_arm,
+ fpu_s2_arm,
+ fpu_s3_arm,
+ fpu_s4_arm,
+ fpu_s5_arm,
+ fpu_s6_arm,
+ fpu_s7_arm,
+ fpu_s8_arm,
+ fpu_s9_arm,
+ fpu_s10_arm,
+ fpu_s11_arm,
+ fpu_s12_arm,
+ fpu_s13_arm,
+ fpu_s14_arm,
+ fpu_s15_arm,
+ fpu_s16_arm,
+ fpu_s17_arm,
+ fpu_s18_arm,
+ fpu_s19_arm,
+ fpu_s20_arm,
+ fpu_s21_arm,
+ fpu_s22_arm,
+ fpu_s23_arm,
+ fpu_s24_arm,
+ fpu_s25_arm,
+ fpu_s26_arm,
+ fpu_s27_arm,
+ fpu_s28_arm,
+ fpu_s29_arm,
+ fpu_s30_arm,
+ fpu_s31_arm,
+ fpu_fpscr_arm,
+ fpu_d0_arm,
+ fpu_d1_arm,
+ fpu_d2_arm,
+ fpu_d3_arm,
+ fpu_d4_arm,
+ fpu_d5_arm,
+ fpu_d6_arm,
+ fpu_d7_arm,
+ fpu_d8_arm,
+ fpu_d9_arm,
+ fpu_d10_arm,
+ fpu_d11_arm,
+ fpu_d12_arm,
+ fpu_d13_arm,
+ fpu_d14_arm,
+ fpu_d15_arm,
+ fpu_d16_arm,
+ fpu_d17_arm,
+ fpu_d18_arm,
+ fpu_d19_arm,
+ fpu_d20_arm,
+ fpu_d21_arm,
+ fpu_d22_arm,
+ fpu_d23_arm,
+ fpu_d24_arm,
+ fpu_d25_arm,
+ fpu_d26_arm,
+ fpu_d27_arm,
+ fpu_d28_arm,
+ fpu_d29_arm,
+ fpu_d30_arm,
+ fpu_d31_arm,
+ fpu_q0_arm,
+ fpu_q1_arm,
+ fpu_q2_arm,
+ fpu_q3_arm,
+ fpu_q4_arm,
+ fpu_q5_arm,
+ fpu_q6_arm,
+ fpu_q7_arm,
+ fpu_q8_arm,
+ fpu_q9_arm,
+ fpu_q10_arm,
+ fpu_q11_arm,
+ fpu_q12_arm,
+ fpu_q13_arm,
+ fpu_q14_arm,
+ fpu_q15_arm,
+ k_last_fpr_arm = fpu_q15_arm,
+ exc_exception_arm,
+ exc_fsr_arm,
+ exc_far_arm,
+
+ dbg_bvr0_arm,
+ dbg_bvr1_arm,
+ dbg_bvr2_arm,
+ dbg_bvr3_arm,
+ dbg_bvr4_arm,
+ dbg_bvr5_arm,
+ dbg_bvr6_arm,
+ dbg_bvr7_arm,
+ dbg_bvr8_arm,
+ dbg_bvr9_arm,
+ dbg_bvr10_arm,
+ dbg_bvr11_arm,
+ dbg_bvr12_arm,
+ dbg_bvr13_arm,
+ dbg_bvr14_arm,
+ dbg_bvr15_arm,
+ dbg_bcr0_arm,
+ dbg_bcr1_arm,
+ dbg_bcr2_arm,
+ dbg_bcr3_arm,
+ dbg_bcr4_arm,
+ dbg_bcr5_arm,
+ dbg_bcr6_arm,
+ dbg_bcr7_arm,
+ dbg_bcr8_arm,
+ dbg_bcr9_arm,
+ dbg_bcr10_arm,
+ dbg_bcr11_arm,
+ dbg_bcr12_arm,
+ dbg_bcr13_arm,
+ dbg_bcr14_arm,
+ dbg_bcr15_arm,
+ dbg_wvr0_arm,
+ dbg_wvr1_arm,
+ dbg_wvr2_arm,
+ dbg_wvr3_arm,
+ dbg_wvr4_arm,
+ dbg_wvr5_arm,
+ dbg_wvr6_arm,
+ dbg_wvr7_arm,
+ dbg_wvr8_arm,
+ dbg_wvr9_arm,
+ dbg_wvr10_arm,
+ dbg_wvr11_arm,
+ dbg_wvr12_arm,
+ dbg_wvr13_arm,
+ dbg_wvr14_arm,
+ dbg_wvr15_arm,
+ dbg_wcr0_arm,
+ dbg_wcr1_arm,
+ dbg_wcr2_arm,
+ dbg_wcr3_arm,
+ dbg_wcr4_arm,
+ dbg_wcr5_arm,
+ dbg_wcr6_arm,
+ dbg_wcr7_arm,
+ dbg_wcr8_arm,
+ dbg_wcr9_arm,
+ dbg_wcr10_arm,
+ dbg_wcr11_arm,
+ dbg_wcr12_arm,
+ dbg_wcr13_arm,
+ dbg_wcr14_arm,
+ dbg_wcr15_arm,
+
+ k_num_registers_arm,
+ k_num_gpr_registers_arm = k_last_gpr_arm - k_first_gpr_arm + 1,
+ k_num_fpr_registers_arm = k_last_fpr_arm - k_first_fpr_arm + 1
+};
}
#endif // #ifndef lldb_arm64_register_enums_h
Modified: lldb/trunk/source/Plugins/Process/Utility/lldb-arm64-register-enums.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Utility/lldb-arm64-register-enums.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/Utility/lldb-arm64-register-enums.h (original)
+++ lldb/trunk/source/Plugins/Process/Utility/lldb-arm64-register-enums.h Tue Sep 6 15:57:50 2016
@@ -10,163 +10,161 @@
#ifndef lldb_arm64_register_enums_h
#define lldb_arm64_register_enums_h
-namespace lldb_private
-{
- // LLDB register codes (e.g. RegisterKind == eRegisterKindLLDB)
-
- //---------------------------------------------------------------------------
- // Internal codes for all ARM64 registers.
- //---------------------------------------------------------------------------
- enum
- {
- k_first_gpr_arm64,
- gpr_x0_arm64 = k_first_gpr_arm64,
- gpr_x1_arm64,
- gpr_x2_arm64,
- gpr_x3_arm64,
- gpr_x4_arm64,
- gpr_x5_arm64,
- gpr_x6_arm64,
- gpr_x7_arm64,
- gpr_x8_arm64,
- gpr_x9_arm64,
- gpr_x10_arm64,
- gpr_x11_arm64,
- gpr_x12_arm64,
- gpr_x13_arm64,
- gpr_x14_arm64,
- gpr_x15_arm64,
- gpr_x16_arm64,
- gpr_x17_arm64,
- gpr_x18_arm64,
- gpr_x19_arm64,
- gpr_x20_arm64,
- gpr_x21_arm64,
- gpr_x22_arm64,
- gpr_x23_arm64,
- gpr_x24_arm64,
- gpr_x25_arm64,
- gpr_x26_arm64,
- gpr_x27_arm64,
- gpr_x28_arm64,
- gpr_fp_arm64,
- gpr_lr_arm64,
- gpr_sp_arm64,
- gpr_pc_arm64,
- gpr_cpsr_arm64,
-
- k_last_gpr_arm64 = gpr_cpsr_arm64,
-
- k_first_fpr_arm64,
- fpu_v0_arm64 = k_first_fpr_arm64,
- fpu_v1_arm64,
- fpu_v2_arm64,
- fpu_v3_arm64,
- fpu_v4_arm64,
- fpu_v5_arm64,
- fpu_v6_arm64,
- fpu_v7_arm64,
- fpu_v8_arm64,
- fpu_v9_arm64,
- fpu_v10_arm64,
- fpu_v11_arm64,
- fpu_v12_arm64,
- fpu_v13_arm64,
- fpu_v14_arm64,
- fpu_v15_arm64,
- fpu_v16_arm64,
- fpu_v17_arm64,
- fpu_v18_arm64,
- fpu_v19_arm64,
- fpu_v20_arm64,
- fpu_v21_arm64,
- fpu_v22_arm64,
- fpu_v23_arm64,
- fpu_v24_arm64,
- fpu_v25_arm64,
- fpu_v26_arm64,
- fpu_v27_arm64,
- fpu_v28_arm64,
- fpu_v29_arm64,
- fpu_v30_arm64,
- fpu_v31_arm64,
- fpu_fpsr_arm64,
- fpu_fpcr_arm64,
- k_last_fpr_arm64 = fpu_fpcr_arm64,
-
- exc_far_arm64,
- exc_esr_arm64,
- exc_exception_arm64,
-
- dbg_bvr0_arm64,
- dbg_bvr1_arm64,
- dbg_bvr2_arm64,
- dbg_bvr3_arm64,
- dbg_bvr4_arm64,
- dbg_bvr5_arm64,
- dbg_bvr6_arm64,
- dbg_bvr7_arm64,
- dbg_bvr8_arm64,
- dbg_bvr9_arm64,
- dbg_bvr10_arm64,
- dbg_bvr11_arm64,
- dbg_bvr12_arm64,
- dbg_bvr13_arm64,
- dbg_bvr14_arm64,
- dbg_bvr15_arm64,
- dbg_bcr0_arm64,
- dbg_bcr1_arm64,
- dbg_bcr2_arm64,
- dbg_bcr3_arm64,
- dbg_bcr4_arm64,
- dbg_bcr5_arm64,
- dbg_bcr6_arm64,
- dbg_bcr7_arm64,
- dbg_bcr8_arm64,
- dbg_bcr9_arm64,
- dbg_bcr10_arm64,
- dbg_bcr11_arm64,
- dbg_bcr12_arm64,
- dbg_bcr13_arm64,
- dbg_bcr14_arm64,
- dbg_bcr15_arm64,
- dbg_wvr0_arm64,
- dbg_wvr1_arm64,
- dbg_wvr2_arm64,
- dbg_wvr3_arm64,
- dbg_wvr4_arm64,
- dbg_wvr5_arm64,
- dbg_wvr6_arm64,
- dbg_wvr7_arm64,
- dbg_wvr8_arm64,
- dbg_wvr9_arm64,
- dbg_wvr10_arm64,
- dbg_wvr11_arm64,
- dbg_wvr12_arm64,
- dbg_wvr13_arm64,
- dbg_wvr14_arm64,
- dbg_wvr15_arm64,
- dbg_wcr0_arm64,
- dbg_wcr1_arm64,
- dbg_wcr2_arm64,
- dbg_wcr3_arm64,
- dbg_wcr4_arm64,
- dbg_wcr5_arm64,
- dbg_wcr6_arm64,
- dbg_wcr7_arm64,
- dbg_wcr8_arm64,
- dbg_wcr9_arm64,
- dbg_wcr10_arm64,
- dbg_wcr11_arm64,
- dbg_wcr12_arm64,
- dbg_wcr13_arm64,
- dbg_wcr14_arm64,
- dbg_wcr15_arm64,
-
- k_num_registers_arm64,
- k_num_gpr_registers_arm64 = k_last_gpr_arm64 - k_first_gpr_arm64 + 1,
- k_num_fpr_registers_arm64 = k_last_fpr_arm64 - k_first_fpr_arm64 + 1
- };
+namespace lldb_private {
+// LLDB register codes (e.g. RegisterKind == eRegisterKindLLDB)
+
+//---------------------------------------------------------------------------
+// Internal codes for all ARM64 registers.
+//---------------------------------------------------------------------------
+enum {
+ k_first_gpr_arm64,
+ gpr_x0_arm64 = k_first_gpr_arm64,
+ gpr_x1_arm64,
+ gpr_x2_arm64,
+ gpr_x3_arm64,
+ gpr_x4_arm64,
+ gpr_x5_arm64,
+ gpr_x6_arm64,
+ gpr_x7_arm64,
+ gpr_x8_arm64,
+ gpr_x9_arm64,
+ gpr_x10_arm64,
+ gpr_x11_arm64,
+ gpr_x12_arm64,
+ gpr_x13_arm64,
+ gpr_x14_arm64,
+ gpr_x15_arm64,
+ gpr_x16_arm64,
+ gpr_x17_arm64,
+ gpr_x18_arm64,
+ gpr_x19_arm64,
+ gpr_x20_arm64,
+ gpr_x21_arm64,
+ gpr_x22_arm64,
+ gpr_x23_arm64,
+ gpr_x24_arm64,
+ gpr_x25_arm64,
+ gpr_x26_arm64,
+ gpr_x27_arm64,
+ gpr_x28_arm64,
+ gpr_fp_arm64,
+ gpr_lr_arm64,
+ gpr_sp_arm64,
+ gpr_pc_arm64,
+ gpr_cpsr_arm64,
+
+ k_last_gpr_arm64 = gpr_cpsr_arm64,
+
+ k_first_fpr_arm64,
+ fpu_v0_arm64 = k_first_fpr_arm64,
+ fpu_v1_arm64,
+ fpu_v2_arm64,
+ fpu_v3_arm64,
+ fpu_v4_arm64,
+ fpu_v5_arm64,
+ fpu_v6_arm64,
+ fpu_v7_arm64,
+ fpu_v8_arm64,
+ fpu_v9_arm64,
+ fpu_v10_arm64,
+ fpu_v11_arm64,
+ fpu_v12_arm64,
+ fpu_v13_arm64,
+ fpu_v14_arm64,
+ fpu_v15_arm64,
+ fpu_v16_arm64,
+ fpu_v17_arm64,
+ fpu_v18_arm64,
+ fpu_v19_arm64,
+ fpu_v20_arm64,
+ fpu_v21_arm64,
+ fpu_v22_arm64,
+ fpu_v23_arm64,
+ fpu_v24_arm64,
+ fpu_v25_arm64,
+ fpu_v26_arm64,
+ fpu_v27_arm64,
+ fpu_v28_arm64,
+ fpu_v29_arm64,
+ fpu_v30_arm64,
+ fpu_v31_arm64,
+ fpu_fpsr_arm64,
+ fpu_fpcr_arm64,
+ k_last_fpr_arm64 = fpu_fpcr_arm64,
+
+ exc_far_arm64,
+ exc_esr_arm64,
+ exc_exception_arm64,
+
+ dbg_bvr0_arm64,
+ dbg_bvr1_arm64,
+ dbg_bvr2_arm64,
+ dbg_bvr3_arm64,
+ dbg_bvr4_arm64,
+ dbg_bvr5_arm64,
+ dbg_bvr6_arm64,
+ dbg_bvr7_arm64,
+ dbg_bvr8_arm64,
+ dbg_bvr9_arm64,
+ dbg_bvr10_arm64,
+ dbg_bvr11_arm64,
+ dbg_bvr12_arm64,
+ dbg_bvr13_arm64,
+ dbg_bvr14_arm64,
+ dbg_bvr15_arm64,
+ dbg_bcr0_arm64,
+ dbg_bcr1_arm64,
+ dbg_bcr2_arm64,
+ dbg_bcr3_arm64,
+ dbg_bcr4_arm64,
+ dbg_bcr5_arm64,
+ dbg_bcr6_arm64,
+ dbg_bcr7_arm64,
+ dbg_bcr8_arm64,
+ dbg_bcr9_arm64,
+ dbg_bcr10_arm64,
+ dbg_bcr11_arm64,
+ dbg_bcr12_arm64,
+ dbg_bcr13_arm64,
+ dbg_bcr14_arm64,
+ dbg_bcr15_arm64,
+ dbg_wvr0_arm64,
+ dbg_wvr1_arm64,
+ dbg_wvr2_arm64,
+ dbg_wvr3_arm64,
+ dbg_wvr4_arm64,
+ dbg_wvr5_arm64,
+ dbg_wvr6_arm64,
+ dbg_wvr7_arm64,
+ dbg_wvr8_arm64,
+ dbg_wvr9_arm64,
+ dbg_wvr10_arm64,
+ dbg_wvr11_arm64,
+ dbg_wvr12_arm64,
+ dbg_wvr13_arm64,
+ dbg_wvr14_arm64,
+ dbg_wvr15_arm64,
+ dbg_wcr0_arm64,
+ dbg_wcr1_arm64,
+ dbg_wcr2_arm64,
+ dbg_wcr3_arm64,
+ dbg_wcr4_arm64,
+ dbg_wcr5_arm64,
+ dbg_wcr6_arm64,
+ dbg_wcr7_arm64,
+ dbg_wcr8_arm64,
+ dbg_wcr9_arm64,
+ dbg_wcr10_arm64,
+ dbg_wcr11_arm64,
+ dbg_wcr12_arm64,
+ dbg_wcr13_arm64,
+ dbg_wcr14_arm64,
+ dbg_wcr15_arm64,
+
+ k_num_registers_arm64,
+ k_num_gpr_registers_arm64 = k_last_gpr_arm64 - k_first_gpr_arm64 + 1,
+ k_num_fpr_registers_arm64 = k_last_fpr_arm64 - k_first_fpr_arm64 + 1
+};
}
#endif // #ifndef lldb_arm64_register_enums_h
Modified: lldb/trunk/source/Plugins/Process/Utility/lldb-mips-freebsd-register-enums.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Utility/lldb-mips-freebsd-register-enums.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/Utility/lldb-mips-freebsd-register-enums.h (original)
+++ lldb/trunk/source/Plugins/Process/Utility/lldb-mips-freebsd-register-enums.h Tue Sep 6 15:57:50 2016
@@ -1,4 +1,5 @@
-//===-- lldb-mips-frebsd-register-enums.h -------------------------------*- C++ -*-===//
+//===-- lldb-mips-frebsd-register-enums.h -------------------------------*- C++
+//-*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -10,61 +11,59 @@
#ifndef lldb_mips_freebsd_register_enums_h
#define lldb_mips_freebsd_register_enums_h
-namespace lldb_private
-{
- // LLDB register codes (e.g. RegisterKind == eRegisterKindLLDB)
+namespace lldb_private {
+// LLDB register codes (e.g. RegisterKind == eRegisterKindLLDB)
- //---------------------------------------------------------------------------
- // Internal codes for all mips registers.
- //---------------------------------------------------------------------------
- enum
- {
- k_first_gpr_mips64,
- gpr_zero_mips64 = k_first_gpr_mips64,
- gpr_r1_mips64,
- gpr_r2_mips64,
- gpr_r3_mips64,
- gpr_r4_mips64,
- gpr_r5_mips64,
- gpr_r6_mips64,
- gpr_r7_mips64,
- gpr_r8_mips64,
- gpr_r9_mips64,
- gpr_r10_mips64,
- gpr_r11_mips64,
- gpr_r12_mips64,
- gpr_r13_mips64,
- gpr_r14_mips64,
- gpr_r15_mips64,
- gpr_r16_mips64,
- gpr_r17_mips64,
- gpr_r18_mips64,
- gpr_r19_mips64,
- gpr_r20_mips64,
- gpr_r21_mips64,
- gpr_r22_mips64,
- gpr_r23_mips64,
- gpr_r24_mips64,
- gpr_r25_mips64,
- gpr_r26_mips64,
- gpr_r27_mips64,
- gpr_gp_mips64,
- gpr_sp_mips64,
- gpr_r30_mips64,
- gpr_ra_mips64,
- gpr_sr_mips64,
- gpr_mullo_mips64,
- gpr_mulhi_mips64,
- gpr_badvaddr_mips64,
- gpr_cause_mips64,
- gpr_pc_mips64,
- gpr_ic_mips64,
- gpr_dummy_mips64,
- k_last_gpr_mips64 = gpr_dummy_mips64,
+//---------------------------------------------------------------------------
+// Internal codes for all mips registers.
+//---------------------------------------------------------------------------
+enum {
+ k_first_gpr_mips64,
+ gpr_zero_mips64 = k_first_gpr_mips64,
+ gpr_r1_mips64,
+ gpr_r2_mips64,
+ gpr_r3_mips64,
+ gpr_r4_mips64,
+ gpr_r5_mips64,
+ gpr_r6_mips64,
+ gpr_r7_mips64,
+ gpr_r8_mips64,
+ gpr_r9_mips64,
+ gpr_r10_mips64,
+ gpr_r11_mips64,
+ gpr_r12_mips64,
+ gpr_r13_mips64,
+ gpr_r14_mips64,
+ gpr_r15_mips64,
+ gpr_r16_mips64,
+ gpr_r17_mips64,
+ gpr_r18_mips64,
+ gpr_r19_mips64,
+ gpr_r20_mips64,
+ gpr_r21_mips64,
+ gpr_r22_mips64,
+ gpr_r23_mips64,
+ gpr_r24_mips64,
+ gpr_r25_mips64,
+ gpr_r26_mips64,
+ gpr_r27_mips64,
+ gpr_gp_mips64,
+ gpr_sp_mips64,
+ gpr_r30_mips64,
+ gpr_ra_mips64,
+ gpr_sr_mips64,
+ gpr_mullo_mips64,
+ gpr_mulhi_mips64,
+ gpr_badvaddr_mips64,
+ gpr_cause_mips64,
+ gpr_pc_mips64,
+ gpr_ic_mips64,
+ gpr_dummy_mips64,
+ k_last_gpr_mips64 = gpr_dummy_mips64,
- k_num_registers_mips64,
+ k_num_registers_mips64,
- k_num_gpr_registers_mips64 = k_last_gpr_mips64 - k_first_gpr_mips64 + 1
- };
+ k_num_gpr_registers_mips64 = k_last_gpr_mips64 - k_first_gpr_mips64 + 1
+};
}
#endif // #ifndef lldb_mips_freebsd_register_enums_h
Modified: lldb/trunk/source/Plugins/Process/Utility/lldb-mips-linux-register-enums.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Utility/lldb-mips-linux-register-enums.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/Utility/lldb-mips-linux-register-enums.h (original)
+++ lldb/trunk/source/Plugins/Process/Utility/lldb-mips-linux-register-enums.h Tue Sep 6 15:57:50 2016
@@ -1,4 +1,5 @@
-//===-- lldb-mips-linux-register-enums.h -------------------------------*- C++ -*-===//
+//===-- lldb-mips-linux-register-enums.h -------------------------------*- C++
+//-*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -10,276 +11,277 @@
#ifndef lldb_mips_linux_register_enums_h
#define lldb_mips_linux_register_enums_h
-namespace lldb_private
-{
- // LLDB register codes (e.g. RegisterKind == eRegisterKindLLDB)
-
- //---------------------------------------------------------------------------
- // Internal codes for all mips registers.
- //---------------------------------------------------------------------------
- enum
- {
- k_first_gpr_mips,
- gpr_zero_mips = k_first_gpr_mips,
- gpr_r1_mips,
- gpr_r2_mips,
- gpr_r3_mips,
- gpr_r4_mips,
- gpr_r5_mips,
- gpr_r6_mips,
- gpr_r7_mips,
- gpr_r8_mips,
- gpr_r9_mips,
- gpr_r10_mips,
- gpr_r11_mips,
- gpr_r12_mips,
- gpr_r13_mips,
- gpr_r14_mips,
- gpr_r15_mips,
- gpr_r16_mips,
- gpr_r17_mips,
- gpr_r18_mips,
- gpr_r19_mips,
- gpr_r20_mips,
- gpr_r21_mips,
- gpr_r22_mips,
- gpr_r23_mips,
- gpr_r24_mips,
- gpr_r25_mips,
- gpr_r26_mips,
- gpr_r27_mips,
- gpr_gp_mips,
- gpr_sp_mips,
- gpr_r30_mips,
- gpr_ra_mips,
- gpr_sr_mips,
- gpr_mullo_mips,
- gpr_mulhi_mips,
- gpr_badvaddr_mips,
- gpr_cause_mips,
- gpr_pc_mips,
- gpr_config5_mips,
-
- k_last_gpr_mips = gpr_config5_mips,
-
- k_first_fpr_mips,
- fpr_f0_mips = k_first_fpr_mips,
- fpr_f1_mips,
- fpr_f2_mips,
- fpr_f3_mips,
- fpr_f4_mips,
- fpr_f5_mips,
- fpr_f6_mips,
- fpr_f7_mips,
- fpr_f8_mips,
- fpr_f9_mips,
- fpr_f10_mips,
- fpr_f11_mips,
- fpr_f12_mips,
- fpr_f13_mips,
- fpr_f14_mips,
- fpr_f15_mips,
- fpr_f16_mips,
- fpr_f17_mips,
- fpr_f18_mips,
- fpr_f19_mips,
- fpr_f20_mips,
- fpr_f21_mips,
- fpr_f22_mips,
- fpr_f23_mips,
- fpr_f24_mips,
- fpr_f25_mips,
- fpr_f26_mips,
- fpr_f27_mips,
- fpr_f28_mips,
- fpr_f29_mips,
- fpr_f30_mips,
- fpr_f31_mips,
- fpr_fcsr_mips,
- fpr_fir_mips,
- fpr_config5_mips,
- k_last_fpr_mips = fpr_config5_mips,
-
- k_first_msa_mips,
- msa_w0_mips = k_first_msa_mips,
- msa_w1_mips,
- msa_w2_mips,
- msa_w3_mips,
- msa_w4_mips,
- msa_w5_mips,
- msa_w6_mips,
- msa_w7_mips,
- msa_w8_mips,
- msa_w9_mips,
- msa_w10_mips,
- msa_w11_mips,
- msa_w12_mips,
- msa_w13_mips,
- msa_w14_mips,
- msa_w15_mips,
- msa_w16_mips,
- msa_w17_mips,
- msa_w18_mips,
- msa_w19_mips,
- msa_w20_mips,
- msa_w21_mips,
- msa_w22_mips,
- msa_w23_mips,
- msa_w24_mips,
- msa_w25_mips,
- msa_w26_mips,
- msa_w27_mips,
- msa_w28_mips,
- msa_w29_mips,
- msa_w30_mips,
- msa_w31_mips,
- msa_fcsr_mips,
- msa_fir_mips,
- msa_mcsr_mips,
- msa_mir_mips,
- msa_config5_mips,
- k_last_msa_mips = msa_config5_mips,
-
- k_num_registers_mips,
-
- k_num_gpr_registers_mips = k_last_gpr_mips - k_first_gpr_mips + 1,
- k_num_fpr_registers_mips = k_last_fpr_mips - k_first_fpr_mips + 1,
- k_num_msa_registers_mips = k_last_msa_mips - k_first_msa_mips + 1,
- k_num_user_registers_mips = k_num_gpr_registers_mips + k_num_fpr_registers_mips + k_num_msa_registers_mips
- };
-
- //---------------------------------------------------------------------------
- // Internal codes for all mips64 registers.
- //---------------------------------------------------------------------------
- enum
- {
- k_first_gpr_mips64,
- gpr_zero_mips64 = k_first_gpr_mips64,
- gpr_r1_mips64,
- gpr_r2_mips64,
- gpr_r3_mips64,
- gpr_r4_mips64,
- gpr_r5_mips64,
- gpr_r6_mips64,
- gpr_r7_mips64,
- gpr_r8_mips64,
- gpr_r9_mips64,
- gpr_r10_mips64,
- gpr_r11_mips64,
- gpr_r12_mips64,
- gpr_r13_mips64,
- gpr_r14_mips64,
- gpr_r15_mips64,
- gpr_r16_mips64,
- gpr_r17_mips64,
- gpr_r18_mips64,
- gpr_r19_mips64,
- gpr_r20_mips64,
- gpr_r21_mips64,
- gpr_r22_mips64,
- gpr_r23_mips64,
- gpr_r24_mips64,
- gpr_r25_mips64,
- gpr_r26_mips64,
- gpr_r27_mips64,
- gpr_gp_mips64,
- gpr_sp_mips64,
- gpr_r30_mips64,
- gpr_ra_mips64,
- gpr_sr_mips64,
- gpr_mullo_mips64,
- gpr_mulhi_mips64,
- gpr_badvaddr_mips64,
- gpr_cause_mips64,
- gpr_pc_mips64,
- gpr_config5_mips64,
- k_last_gpr_mips64 = gpr_config5_mips64,
-
- k_first_fpr_mips64,
- fpr_f0_mips64 = k_first_fpr_mips64,
- fpr_f1_mips64,
- fpr_f2_mips64,
- fpr_f3_mips64,
- fpr_f4_mips64,
- fpr_f5_mips64,
- fpr_f6_mips64,
- fpr_f7_mips64,
- fpr_f8_mips64,
- fpr_f9_mips64,
- fpr_f10_mips64,
- fpr_f11_mips64,
- fpr_f12_mips64,
- fpr_f13_mips64,
- fpr_f14_mips64,
- fpr_f15_mips64,
- fpr_f16_mips64,
- fpr_f17_mips64,
- fpr_f18_mips64,
- fpr_f19_mips64,
- fpr_f20_mips64,
- fpr_f21_mips64,
- fpr_f22_mips64,
- fpr_f23_mips64,
- fpr_f24_mips64,
- fpr_f25_mips64,
- fpr_f26_mips64,
- fpr_f27_mips64,
- fpr_f28_mips64,
- fpr_f29_mips64,
- fpr_f30_mips64,
- fpr_f31_mips64,
- fpr_fcsr_mips64,
- fpr_fir_mips64,
- fpr_config5_mips64,
- k_last_fpr_mips64 = fpr_config5_mips64,
-
- k_first_msa_mips64,
- msa_w0_mips64 = k_first_msa_mips64,
- msa_w1_mips64,
- msa_w2_mips64,
- msa_w3_mips64,
- msa_w4_mips64,
- msa_w5_mips64,
- msa_w6_mips64,
- msa_w7_mips64,
- msa_w8_mips64,
- msa_w9_mips64,
- msa_w10_mips64,
- msa_w11_mips64,
- msa_w12_mips64,
- msa_w13_mips64,
- msa_w14_mips64,
- msa_w15_mips64,
- msa_w16_mips64,
- msa_w17_mips64,
- msa_w18_mips64,
- msa_w19_mips64,
- msa_w20_mips64,
- msa_w21_mips64,
- msa_w22_mips64,
- msa_w23_mips64,
- msa_w24_mips64,
- msa_w25_mips64,
- msa_w26_mips64,
- msa_w27_mips64,
- msa_w28_mips64,
- msa_w29_mips64,
- msa_w30_mips64,
- msa_w31_mips64,
- msa_fcsr_mips64,
- msa_fir_mips64,
- msa_mcsr_mips64,
- msa_mir_mips64,
- msa_config5_mips64,
- k_last_msa_mips64 = msa_config5_mips64,
-
- k_num_registers_mips64,
-
- k_num_gpr_registers_mips64 = k_last_gpr_mips64 - k_first_gpr_mips64 + 1,
- k_num_fpr_registers_mips64 = k_last_fpr_mips64 - k_first_fpr_mips64 + 1,
- k_num_msa_registers_mips64 = k_last_msa_mips64 - k_first_msa_mips64 + 1,
- k_num_user_registers_mips64 = k_num_gpr_registers_mips64 + k_num_fpr_registers_mips64 + k_num_msa_registers_mips64
- };
+namespace lldb_private {
+// LLDB register codes (e.g. RegisterKind == eRegisterKindLLDB)
+
+//---------------------------------------------------------------------------
+// Internal codes for all mips registers.
+//---------------------------------------------------------------------------
+enum {
+ k_first_gpr_mips,
+ gpr_zero_mips = k_first_gpr_mips,
+ gpr_r1_mips,
+ gpr_r2_mips,
+ gpr_r3_mips,
+ gpr_r4_mips,
+ gpr_r5_mips,
+ gpr_r6_mips,
+ gpr_r7_mips,
+ gpr_r8_mips,
+ gpr_r9_mips,
+ gpr_r10_mips,
+ gpr_r11_mips,
+ gpr_r12_mips,
+ gpr_r13_mips,
+ gpr_r14_mips,
+ gpr_r15_mips,
+ gpr_r16_mips,
+ gpr_r17_mips,
+ gpr_r18_mips,
+ gpr_r19_mips,
+ gpr_r20_mips,
+ gpr_r21_mips,
+ gpr_r22_mips,
+ gpr_r23_mips,
+ gpr_r24_mips,
+ gpr_r25_mips,
+ gpr_r26_mips,
+ gpr_r27_mips,
+ gpr_gp_mips,
+ gpr_sp_mips,
+ gpr_r30_mips,
+ gpr_ra_mips,
+ gpr_sr_mips,
+ gpr_mullo_mips,
+ gpr_mulhi_mips,
+ gpr_badvaddr_mips,
+ gpr_cause_mips,
+ gpr_pc_mips,
+ gpr_config5_mips,
+
+ k_last_gpr_mips = gpr_config5_mips,
+
+ k_first_fpr_mips,
+ fpr_f0_mips = k_first_fpr_mips,
+ fpr_f1_mips,
+ fpr_f2_mips,
+ fpr_f3_mips,
+ fpr_f4_mips,
+ fpr_f5_mips,
+ fpr_f6_mips,
+ fpr_f7_mips,
+ fpr_f8_mips,
+ fpr_f9_mips,
+ fpr_f10_mips,
+ fpr_f11_mips,
+ fpr_f12_mips,
+ fpr_f13_mips,
+ fpr_f14_mips,
+ fpr_f15_mips,
+ fpr_f16_mips,
+ fpr_f17_mips,
+ fpr_f18_mips,
+ fpr_f19_mips,
+ fpr_f20_mips,
+ fpr_f21_mips,
+ fpr_f22_mips,
+ fpr_f23_mips,
+ fpr_f24_mips,
+ fpr_f25_mips,
+ fpr_f26_mips,
+ fpr_f27_mips,
+ fpr_f28_mips,
+ fpr_f29_mips,
+ fpr_f30_mips,
+ fpr_f31_mips,
+ fpr_fcsr_mips,
+ fpr_fir_mips,
+ fpr_config5_mips,
+ k_last_fpr_mips = fpr_config5_mips,
+
+ k_first_msa_mips,
+ msa_w0_mips = k_first_msa_mips,
+ msa_w1_mips,
+ msa_w2_mips,
+ msa_w3_mips,
+ msa_w4_mips,
+ msa_w5_mips,
+ msa_w6_mips,
+ msa_w7_mips,
+ msa_w8_mips,
+ msa_w9_mips,
+ msa_w10_mips,
+ msa_w11_mips,
+ msa_w12_mips,
+ msa_w13_mips,
+ msa_w14_mips,
+ msa_w15_mips,
+ msa_w16_mips,
+ msa_w17_mips,
+ msa_w18_mips,
+ msa_w19_mips,
+ msa_w20_mips,
+ msa_w21_mips,
+ msa_w22_mips,
+ msa_w23_mips,
+ msa_w24_mips,
+ msa_w25_mips,
+ msa_w26_mips,
+ msa_w27_mips,
+ msa_w28_mips,
+ msa_w29_mips,
+ msa_w30_mips,
+ msa_w31_mips,
+ msa_fcsr_mips,
+ msa_fir_mips,
+ msa_mcsr_mips,
+ msa_mir_mips,
+ msa_config5_mips,
+ k_last_msa_mips = msa_config5_mips,
+
+ k_num_registers_mips,
+
+ k_num_gpr_registers_mips = k_last_gpr_mips - k_first_gpr_mips + 1,
+ k_num_fpr_registers_mips = k_last_fpr_mips - k_first_fpr_mips + 1,
+ k_num_msa_registers_mips = k_last_msa_mips - k_first_msa_mips + 1,
+ k_num_user_registers_mips = k_num_gpr_registers_mips +
+ k_num_fpr_registers_mips +
+ k_num_msa_registers_mips
+};
+
+//---------------------------------------------------------------------------
+// Internal codes for all mips64 registers.
+//---------------------------------------------------------------------------
+enum {
+ k_first_gpr_mips64,
+ gpr_zero_mips64 = k_first_gpr_mips64,
+ gpr_r1_mips64,
+ gpr_r2_mips64,
+ gpr_r3_mips64,
+ gpr_r4_mips64,
+ gpr_r5_mips64,
+ gpr_r6_mips64,
+ gpr_r7_mips64,
+ gpr_r8_mips64,
+ gpr_r9_mips64,
+ gpr_r10_mips64,
+ gpr_r11_mips64,
+ gpr_r12_mips64,
+ gpr_r13_mips64,
+ gpr_r14_mips64,
+ gpr_r15_mips64,
+ gpr_r16_mips64,
+ gpr_r17_mips64,
+ gpr_r18_mips64,
+ gpr_r19_mips64,
+ gpr_r20_mips64,
+ gpr_r21_mips64,
+ gpr_r22_mips64,
+ gpr_r23_mips64,
+ gpr_r24_mips64,
+ gpr_r25_mips64,
+ gpr_r26_mips64,
+ gpr_r27_mips64,
+ gpr_gp_mips64,
+ gpr_sp_mips64,
+ gpr_r30_mips64,
+ gpr_ra_mips64,
+ gpr_sr_mips64,
+ gpr_mullo_mips64,
+ gpr_mulhi_mips64,
+ gpr_badvaddr_mips64,
+ gpr_cause_mips64,
+ gpr_pc_mips64,
+ gpr_config5_mips64,
+ k_last_gpr_mips64 = gpr_config5_mips64,
+
+ k_first_fpr_mips64,
+ fpr_f0_mips64 = k_first_fpr_mips64,
+ fpr_f1_mips64,
+ fpr_f2_mips64,
+ fpr_f3_mips64,
+ fpr_f4_mips64,
+ fpr_f5_mips64,
+ fpr_f6_mips64,
+ fpr_f7_mips64,
+ fpr_f8_mips64,
+ fpr_f9_mips64,
+ fpr_f10_mips64,
+ fpr_f11_mips64,
+ fpr_f12_mips64,
+ fpr_f13_mips64,
+ fpr_f14_mips64,
+ fpr_f15_mips64,
+ fpr_f16_mips64,
+ fpr_f17_mips64,
+ fpr_f18_mips64,
+ fpr_f19_mips64,
+ fpr_f20_mips64,
+ fpr_f21_mips64,
+ fpr_f22_mips64,
+ fpr_f23_mips64,
+ fpr_f24_mips64,
+ fpr_f25_mips64,
+ fpr_f26_mips64,
+ fpr_f27_mips64,
+ fpr_f28_mips64,
+ fpr_f29_mips64,
+ fpr_f30_mips64,
+ fpr_f31_mips64,
+ fpr_fcsr_mips64,
+ fpr_fir_mips64,
+ fpr_config5_mips64,
+ k_last_fpr_mips64 = fpr_config5_mips64,
+
+ k_first_msa_mips64,
+ msa_w0_mips64 = k_first_msa_mips64,
+ msa_w1_mips64,
+ msa_w2_mips64,
+ msa_w3_mips64,
+ msa_w4_mips64,
+ msa_w5_mips64,
+ msa_w6_mips64,
+ msa_w7_mips64,
+ msa_w8_mips64,
+ msa_w9_mips64,
+ msa_w10_mips64,
+ msa_w11_mips64,
+ msa_w12_mips64,
+ msa_w13_mips64,
+ msa_w14_mips64,
+ msa_w15_mips64,
+ msa_w16_mips64,
+ msa_w17_mips64,
+ msa_w18_mips64,
+ msa_w19_mips64,
+ msa_w20_mips64,
+ msa_w21_mips64,
+ msa_w22_mips64,
+ msa_w23_mips64,
+ msa_w24_mips64,
+ msa_w25_mips64,
+ msa_w26_mips64,
+ msa_w27_mips64,
+ msa_w28_mips64,
+ msa_w29_mips64,
+ msa_w30_mips64,
+ msa_w31_mips64,
+ msa_fcsr_mips64,
+ msa_fir_mips64,
+ msa_mcsr_mips64,
+ msa_mir_mips64,
+ msa_config5_mips64,
+ k_last_msa_mips64 = msa_config5_mips64,
+
+ k_num_registers_mips64,
+
+ k_num_gpr_registers_mips64 = k_last_gpr_mips64 - k_first_gpr_mips64 + 1,
+ k_num_fpr_registers_mips64 = k_last_fpr_mips64 - k_first_fpr_mips64 + 1,
+ k_num_msa_registers_mips64 = k_last_msa_mips64 - k_first_msa_mips64 + 1,
+ k_num_user_registers_mips64 = k_num_gpr_registers_mips64 +
+ k_num_fpr_registers_mips64 +
+ k_num_msa_registers_mips64
+};
}
#endif // #ifndef lldb_mips_linux_register_enums_h
Modified: lldb/trunk/source/Plugins/Process/Utility/lldb-s390x-register-enums.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Utility/lldb-s390x-register-enums.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/Utility/lldb-s390x-register-enums.h (original)
+++ lldb/trunk/source/Plugins/Process/Utility/lldb-s390x-register-enums.h Tue Sep 6 15:57:50 2016
@@ -10,84 +10,83 @@
#ifndef lldb_s390x_register_enums_h
#define lldb_s390x_register_enums_h
-namespace lldb_private
-{
+namespace lldb_private {
// LLDB register codes (e.g. RegisterKind == eRegisterKindLLDB)
//---------------------------------------------------------------------------
// Internal codes for all s390x registers.
//---------------------------------------------------------------------------
-enum
-{
- k_first_gpr_s390x,
- lldb_r0_s390x = k_first_gpr_s390x,
- lldb_r1_s390x,
- lldb_r2_s390x,
- lldb_r3_s390x,
- lldb_r4_s390x,
- lldb_r5_s390x,
- lldb_r6_s390x,
- lldb_r7_s390x,
- lldb_r8_s390x,
- lldb_r9_s390x,
- lldb_r10_s390x,
- lldb_r11_s390x,
- lldb_r12_s390x,
- lldb_r13_s390x,
- lldb_r14_s390x,
- lldb_r15_s390x,
- lldb_acr0_s390x,
- lldb_acr1_s390x,
- lldb_acr2_s390x,
- lldb_acr3_s390x,
- lldb_acr4_s390x,
- lldb_acr5_s390x,
- lldb_acr6_s390x,
- lldb_acr7_s390x,
- lldb_acr8_s390x,
- lldb_acr9_s390x,
- lldb_acr10_s390x,
- lldb_acr11_s390x,
- lldb_acr12_s390x,
- lldb_acr13_s390x,
- lldb_acr14_s390x,
- lldb_acr15_s390x,
- lldb_pswm_s390x,
- lldb_pswa_s390x,
- k_last_gpr_s390x = lldb_pswa_s390x,
-
- k_first_fpr_s390x,
- lldb_f0_s390x = k_first_fpr_s390x,
- lldb_f1_s390x,
- lldb_f2_s390x,
- lldb_f3_s390x,
- lldb_f4_s390x,
- lldb_f5_s390x,
- lldb_f6_s390x,
- lldb_f7_s390x,
- lldb_f8_s390x,
- lldb_f9_s390x,
- lldb_f10_s390x,
- lldb_f11_s390x,
- lldb_f12_s390x,
- lldb_f13_s390x,
- lldb_f14_s390x,
- lldb_f15_s390x,
- lldb_fpc_s390x,
- k_last_fpr_s390x = lldb_fpc_s390x,
-
- // These are only available on Linux.
- k_first_linux_s390x,
- lldb_orig_r2_s390x = k_first_linux_s390x,
- lldb_last_break_s390x,
- lldb_system_call_s390x,
- k_last_linux_s390x = lldb_system_call_s390x,
-
- k_num_registers_s390x,
- k_num_gpr_registers_s390x = k_last_gpr_s390x - k_first_gpr_s390x + 1,
- k_num_fpr_registers_s390x = k_last_fpr_s390x - k_first_fpr_s390x + 1,
- k_num_linux_registers_s390x = k_last_linux_s390x - k_first_linux_s390x + 1,
- k_num_user_registers_s390x = k_num_gpr_registers_s390x + k_num_fpr_registers_s390x,
+enum {
+ k_first_gpr_s390x,
+ lldb_r0_s390x = k_first_gpr_s390x,
+ lldb_r1_s390x,
+ lldb_r2_s390x,
+ lldb_r3_s390x,
+ lldb_r4_s390x,
+ lldb_r5_s390x,
+ lldb_r6_s390x,
+ lldb_r7_s390x,
+ lldb_r8_s390x,
+ lldb_r9_s390x,
+ lldb_r10_s390x,
+ lldb_r11_s390x,
+ lldb_r12_s390x,
+ lldb_r13_s390x,
+ lldb_r14_s390x,
+ lldb_r15_s390x,
+ lldb_acr0_s390x,
+ lldb_acr1_s390x,
+ lldb_acr2_s390x,
+ lldb_acr3_s390x,
+ lldb_acr4_s390x,
+ lldb_acr5_s390x,
+ lldb_acr6_s390x,
+ lldb_acr7_s390x,
+ lldb_acr8_s390x,
+ lldb_acr9_s390x,
+ lldb_acr10_s390x,
+ lldb_acr11_s390x,
+ lldb_acr12_s390x,
+ lldb_acr13_s390x,
+ lldb_acr14_s390x,
+ lldb_acr15_s390x,
+ lldb_pswm_s390x,
+ lldb_pswa_s390x,
+ k_last_gpr_s390x = lldb_pswa_s390x,
+
+ k_first_fpr_s390x,
+ lldb_f0_s390x = k_first_fpr_s390x,
+ lldb_f1_s390x,
+ lldb_f2_s390x,
+ lldb_f3_s390x,
+ lldb_f4_s390x,
+ lldb_f5_s390x,
+ lldb_f6_s390x,
+ lldb_f7_s390x,
+ lldb_f8_s390x,
+ lldb_f9_s390x,
+ lldb_f10_s390x,
+ lldb_f11_s390x,
+ lldb_f12_s390x,
+ lldb_f13_s390x,
+ lldb_f14_s390x,
+ lldb_f15_s390x,
+ lldb_fpc_s390x,
+ k_last_fpr_s390x = lldb_fpc_s390x,
+
+ // These are only available on Linux.
+ k_first_linux_s390x,
+ lldb_orig_r2_s390x = k_first_linux_s390x,
+ lldb_last_break_s390x,
+ lldb_system_call_s390x,
+ k_last_linux_s390x = lldb_system_call_s390x,
+
+ k_num_registers_s390x,
+ k_num_gpr_registers_s390x = k_last_gpr_s390x - k_first_gpr_s390x + 1,
+ k_num_fpr_registers_s390x = k_last_fpr_s390x - k_first_fpr_s390x + 1,
+ k_num_linux_registers_s390x = k_last_linux_s390x - k_first_linux_s390x + 1,
+ k_num_user_registers_s390x =
+ k_num_gpr_registers_s390x + k_num_fpr_registers_s390x,
};
}
Modified: lldb/trunk/source/Plugins/Process/Utility/lldb-x86-register-enums.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Utility/lldb-x86-register-enums.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/Utility/lldb-x86-register-enums.h (original)
+++ lldb/trunk/source/Plugins/Process/Utility/lldb-x86-register-enums.h Tue Sep 6 15:57:50 2016
@@ -10,286 +10,286 @@
#ifndef lldb_x86_register_enums_h
#define lldb_x86_register_enums_h
-namespace lldb_private
-{
- // LLDB register codes (e.g. RegisterKind == eRegisterKindLLDB)
-
- //---------------------------------------------------------------------------
- // Internal codes for all i386 registers.
- //---------------------------------------------------------------------------
- enum
- {
- k_first_gpr_i386,
- lldb_eax_i386 = k_first_gpr_i386,
- lldb_ebx_i386,
- lldb_ecx_i386,
- lldb_edx_i386,
- lldb_edi_i386,
- lldb_esi_i386,
- lldb_ebp_i386,
- lldb_esp_i386,
- lldb_eip_i386,
- lldb_eflags_i386,
- lldb_cs_i386,
- lldb_fs_i386,
- lldb_gs_i386,
- lldb_ss_i386,
- lldb_ds_i386,
- lldb_es_i386,
-
- k_first_alias_i386,
- lldb_ax_i386 = k_first_alias_i386,
- lldb_bx_i386,
- lldb_cx_i386,
- lldb_dx_i386,
- lldb_di_i386,
- lldb_si_i386,
- lldb_bp_i386,
- lldb_sp_i386,
- lldb_ah_i386,
- lldb_bh_i386,
- lldb_ch_i386,
- lldb_dh_i386,
- lldb_al_i386,
- lldb_bl_i386,
- lldb_cl_i386,
- lldb_dl_i386,
- k_last_alias_i386 = lldb_dl_i386,
-
- k_last_gpr_i386 = k_last_alias_i386,
-
- k_first_fpr_i386,
- lldb_fctrl_i386 = k_first_fpr_i386,
- lldb_fstat_i386,
- lldb_ftag_i386,
- lldb_fop_i386,
- lldb_fiseg_i386,
- lldb_fioff_i386,
- lldb_foseg_i386,
- lldb_fooff_i386,
- lldb_mxcsr_i386,
- lldb_mxcsrmask_i386,
- lldb_st0_i386,
- lldb_st1_i386,
- lldb_st2_i386,
- lldb_st3_i386,
- lldb_st4_i386,
- lldb_st5_i386,
- lldb_st6_i386,
- lldb_st7_i386,
- lldb_mm0_i386,
- lldb_mm1_i386,
- lldb_mm2_i386,
- lldb_mm3_i386,
- lldb_mm4_i386,
- lldb_mm5_i386,
- lldb_mm6_i386,
- lldb_mm7_i386,
- lldb_xmm0_i386,
- lldb_xmm1_i386,
- lldb_xmm2_i386,
- lldb_xmm3_i386,
- lldb_xmm4_i386,
- lldb_xmm5_i386,
- lldb_xmm6_i386,
- lldb_xmm7_i386,
- k_last_fpr_i386 = lldb_xmm7_i386,
-
- k_first_avx_i386,
- lldb_ymm0_i386 = k_first_avx_i386,
- lldb_ymm1_i386,
- lldb_ymm2_i386,
- lldb_ymm3_i386,
- lldb_ymm4_i386,
- lldb_ymm5_i386,
- lldb_ymm6_i386,
- lldb_ymm7_i386,
- k_last_avx_i386 = lldb_ymm7_i386,
-
- lldb_dr0_i386,
- lldb_dr1_i386,
- lldb_dr2_i386,
- lldb_dr3_i386,
- lldb_dr4_i386,
- lldb_dr5_i386,
- lldb_dr6_i386,
- lldb_dr7_i386,
-
- k_num_registers_i386,
- k_num_gpr_registers_i386 = k_last_gpr_i386 - k_first_gpr_i386 + 1,
- k_num_fpr_registers_i386 = k_last_fpr_i386 - k_first_fpr_i386 + 1,
- k_num_avx_registers_i386 = k_last_avx_i386 - k_first_avx_i386 + 1,
- k_num_user_registers_i386 = k_num_gpr_registers_i386 + k_num_fpr_registers_i386 + k_num_avx_registers_i386,
- };
-
- //---------------------------------------------------------------------------
- // Internal codes for all x86_64 registers.
- //---------------------------------------------------------------------------
- enum
- {
- k_first_gpr_x86_64,
- lldb_rax_x86_64 = k_first_gpr_x86_64,
- lldb_rbx_x86_64,
- lldb_rcx_x86_64,
- lldb_rdx_x86_64,
- lldb_rdi_x86_64,
- lldb_rsi_x86_64,
- lldb_rbp_x86_64,
- lldb_rsp_x86_64,
- lldb_r8_x86_64,
- lldb_r9_x86_64,
- lldb_r10_x86_64,
- lldb_r11_x86_64,
- lldb_r12_x86_64,
- lldb_r13_x86_64,
- lldb_r14_x86_64,
- lldb_r15_x86_64,
- lldb_rip_x86_64,
- lldb_rflags_x86_64,
- lldb_cs_x86_64,
- lldb_fs_x86_64,
- lldb_gs_x86_64,
- lldb_ss_x86_64,
- lldb_ds_x86_64,
- lldb_es_x86_64,
-
- k_first_alias_x86_64,
- lldb_eax_x86_64 = k_first_alias_x86_64,
- lldb_ebx_x86_64,
- lldb_ecx_x86_64,
- lldb_edx_x86_64,
- lldb_edi_x86_64,
- lldb_esi_x86_64,
- lldb_ebp_x86_64,
- lldb_esp_x86_64,
- lldb_r8d_x86_64, // Low 32 bits of r8
- lldb_r9d_x86_64, // Low 32 bits of r9
- lldb_r10d_x86_64, // Low 32 bits of r10
- lldb_r11d_x86_64, // Low 32 bits of r11
- lldb_r12d_x86_64, // Low 32 bits of r12
- lldb_r13d_x86_64, // Low 32 bits of r13
- lldb_r14d_x86_64, // Low 32 bits of r14
- lldb_r15d_x86_64, // Low 32 bits of r15
- lldb_ax_x86_64,
- lldb_bx_x86_64,
- lldb_cx_x86_64,
- lldb_dx_x86_64,
- lldb_di_x86_64,
- lldb_si_x86_64,
- lldb_bp_x86_64,
- lldb_sp_x86_64,
- lldb_r8w_x86_64, // Low 16 bits of r8
- lldb_r9w_x86_64, // Low 16 bits of r9
- lldb_r10w_x86_64, // Low 16 bits of r10
- lldb_r11w_x86_64, // Low 16 bits of r11
- lldb_r12w_x86_64, // Low 16 bits of r12
- lldb_r13w_x86_64, // Low 16 bits of r13
- lldb_r14w_x86_64, // Low 16 bits of r14
- lldb_r15w_x86_64, // Low 16 bits of r15
- lldb_ah_x86_64,
- lldb_bh_x86_64,
- lldb_ch_x86_64,
- lldb_dh_x86_64,
- lldb_al_x86_64,
- lldb_bl_x86_64,
- lldb_cl_x86_64,
- lldb_dl_x86_64,
- lldb_dil_x86_64,
- lldb_sil_x86_64,
- lldb_bpl_x86_64,
- lldb_spl_x86_64,
- lldb_r8l_x86_64, // Low 8 bits of r8
- lldb_r9l_x86_64, // Low 8 bits of r9
- lldb_r10l_x86_64, // Low 8 bits of r10
- lldb_r11l_x86_64, // Low 8 bits of r11
- lldb_r12l_x86_64, // Low 8 bits of r12
- lldb_r13l_x86_64, // Low 8 bits of r13
- lldb_r14l_x86_64, // Low 8 bits of r14
- lldb_r15l_x86_64, // Low 8 bits of r15
- k_last_alias_x86_64 = lldb_r15l_x86_64,
-
- k_last_gpr_x86_64 = k_last_alias_x86_64,
-
- k_first_fpr_x86_64,
- lldb_fctrl_x86_64 = k_first_fpr_x86_64,
- lldb_fstat_x86_64,
- lldb_ftag_x86_64,
- lldb_fop_x86_64,
- lldb_fiseg_x86_64,
- lldb_fioff_x86_64,
- lldb_foseg_x86_64,
- lldb_fooff_x86_64,
- lldb_mxcsr_x86_64,
- lldb_mxcsrmask_x86_64,
- lldb_st0_x86_64,
- lldb_st1_x86_64,
- lldb_st2_x86_64,
- lldb_st3_x86_64,
- lldb_st4_x86_64,
- lldb_st5_x86_64,
- lldb_st6_x86_64,
- lldb_st7_x86_64,
- lldb_mm0_x86_64,
- lldb_mm1_x86_64,
- lldb_mm2_x86_64,
- lldb_mm3_x86_64,
- lldb_mm4_x86_64,
- lldb_mm5_x86_64,
- lldb_mm6_x86_64,
- lldb_mm7_x86_64,
- lldb_xmm0_x86_64,
- lldb_xmm1_x86_64,
- lldb_xmm2_x86_64,
- lldb_xmm3_x86_64,
- lldb_xmm4_x86_64,
- lldb_xmm5_x86_64,
- lldb_xmm6_x86_64,
- lldb_xmm7_x86_64,
- lldb_xmm8_x86_64,
- lldb_xmm9_x86_64,
- lldb_xmm10_x86_64,
- lldb_xmm11_x86_64,
- lldb_xmm12_x86_64,
- lldb_xmm13_x86_64,
- lldb_xmm14_x86_64,
- lldb_xmm15_x86_64,
- k_last_fpr_x86_64 = lldb_xmm15_x86_64,
-
- k_first_avx_x86_64,
- lldb_ymm0_x86_64 = k_first_avx_x86_64,
- lldb_ymm1_x86_64,
- lldb_ymm2_x86_64,
- lldb_ymm3_x86_64,
- lldb_ymm4_x86_64,
- lldb_ymm5_x86_64,
- lldb_ymm6_x86_64,
- lldb_ymm7_x86_64,
- lldb_ymm8_x86_64,
- lldb_ymm9_x86_64,
- lldb_ymm10_x86_64,
- lldb_ymm11_x86_64,
- lldb_ymm12_x86_64,
- lldb_ymm13_x86_64,
- lldb_ymm14_x86_64,
- lldb_ymm15_x86_64,
- k_last_avx_x86_64 = lldb_ymm15_x86_64,
-
- lldb_dr0_x86_64,
- lldb_dr1_x86_64,
- lldb_dr2_x86_64,
- lldb_dr3_x86_64,
- lldb_dr4_x86_64,
- lldb_dr5_x86_64,
- lldb_dr6_x86_64,
- lldb_dr7_x86_64,
-
- k_num_registers_x86_64,
- k_num_gpr_registers_x86_64 = k_last_gpr_x86_64 - k_first_gpr_x86_64 + 1,
- k_num_fpr_registers_x86_64 = k_last_fpr_x86_64 - k_first_fpr_x86_64 + 1,
- k_num_avx_registers_x86_64 = k_last_avx_x86_64 - k_first_avx_x86_64 + 1,
- k_num_user_registers_x86_64 = k_num_gpr_registers_x86_64 + k_num_fpr_registers_x86_64 + k_num_avx_registers_x86_64,
- };
+namespace lldb_private {
+// LLDB register codes (e.g. RegisterKind == eRegisterKindLLDB)
+//---------------------------------------------------------------------------
+// Internal codes for all i386 registers.
+//---------------------------------------------------------------------------
+enum {
+ k_first_gpr_i386,
+ lldb_eax_i386 = k_first_gpr_i386,
+ lldb_ebx_i386,
+ lldb_ecx_i386,
+ lldb_edx_i386,
+ lldb_edi_i386,
+ lldb_esi_i386,
+ lldb_ebp_i386,
+ lldb_esp_i386,
+ lldb_eip_i386,
+ lldb_eflags_i386,
+ lldb_cs_i386,
+ lldb_fs_i386,
+ lldb_gs_i386,
+ lldb_ss_i386,
+ lldb_ds_i386,
+ lldb_es_i386,
+
+ k_first_alias_i386,
+ lldb_ax_i386 = k_first_alias_i386,
+ lldb_bx_i386,
+ lldb_cx_i386,
+ lldb_dx_i386,
+ lldb_di_i386,
+ lldb_si_i386,
+ lldb_bp_i386,
+ lldb_sp_i386,
+ lldb_ah_i386,
+ lldb_bh_i386,
+ lldb_ch_i386,
+ lldb_dh_i386,
+ lldb_al_i386,
+ lldb_bl_i386,
+ lldb_cl_i386,
+ lldb_dl_i386,
+ k_last_alias_i386 = lldb_dl_i386,
+
+ k_last_gpr_i386 = k_last_alias_i386,
+
+ k_first_fpr_i386,
+ lldb_fctrl_i386 = k_first_fpr_i386,
+ lldb_fstat_i386,
+ lldb_ftag_i386,
+ lldb_fop_i386,
+ lldb_fiseg_i386,
+ lldb_fioff_i386,
+ lldb_foseg_i386,
+ lldb_fooff_i386,
+ lldb_mxcsr_i386,
+ lldb_mxcsrmask_i386,
+ lldb_st0_i386,
+ lldb_st1_i386,
+ lldb_st2_i386,
+ lldb_st3_i386,
+ lldb_st4_i386,
+ lldb_st5_i386,
+ lldb_st6_i386,
+ lldb_st7_i386,
+ lldb_mm0_i386,
+ lldb_mm1_i386,
+ lldb_mm2_i386,
+ lldb_mm3_i386,
+ lldb_mm4_i386,
+ lldb_mm5_i386,
+ lldb_mm6_i386,
+ lldb_mm7_i386,
+ lldb_xmm0_i386,
+ lldb_xmm1_i386,
+ lldb_xmm2_i386,
+ lldb_xmm3_i386,
+ lldb_xmm4_i386,
+ lldb_xmm5_i386,
+ lldb_xmm6_i386,
+ lldb_xmm7_i386,
+ k_last_fpr_i386 = lldb_xmm7_i386,
+
+ k_first_avx_i386,
+ lldb_ymm0_i386 = k_first_avx_i386,
+ lldb_ymm1_i386,
+ lldb_ymm2_i386,
+ lldb_ymm3_i386,
+ lldb_ymm4_i386,
+ lldb_ymm5_i386,
+ lldb_ymm6_i386,
+ lldb_ymm7_i386,
+ k_last_avx_i386 = lldb_ymm7_i386,
+
+ lldb_dr0_i386,
+ lldb_dr1_i386,
+ lldb_dr2_i386,
+ lldb_dr3_i386,
+ lldb_dr4_i386,
+ lldb_dr5_i386,
+ lldb_dr6_i386,
+ lldb_dr7_i386,
+
+ k_num_registers_i386,
+ k_num_gpr_registers_i386 = k_last_gpr_i386 - k_first_gpr_i386 + 1,
+ k_num_fpr_registers_i386 = k_last_fpr_i386 - k_first_fpr_i386 + 1,
+ k_num_avx_registers_i386 = k_last_avx_i386 - k_first_avx_i386 + 1,
+ k_num_user_registers_i386 = k_num_gpr_registers_i386 +
+ k_num_fpr_registers_i386 +
+ k_num_avx_registers_i386,
+};
+
+//---------------------------------------------------------------------------
+// Internal codes for all x86_64 registers.
+//---------------------------------------------------------------------------
+enum {
+ k_first_gpr_x86_64,
+ lldb_rax_x86_64 = k_first_gpr_x86_64,
+ lldb_rbx_x86_64,
+ lldb_rcx_x86_64,
+ lldb_rdx_x86_64,
+ lldb_rdi_x86_64,
+ lldb_rsi_x86_64,
+ lldb_rbp_x86_64,
+ lldb_rsp_x86_64,
+ lldb_r8_x86_64,
+ lldb_r9_x86_64,
+ lldb_r10_x86_64,
+ lldb_r11_x86_64,
+ lldb_r12_x86_64,
+ lldb_r13_x86_64,
+ lldb_r14_x86_64,
+ lldb_r15_x86_64,
+ lldb_rip_x86_64,
+ lldb_rflags_x86_64,
+ lldb_cs_x86_64,
+ lldb_fs_x86_64,
+ lldb_gs_x86_64,
+ lldb_ss_x86_64,
+ lldb_ds_x86_64,
+ lldb_es_x86_64,
+
+ k_first_alias_x86_64,
+ lldb_eax_x86_64 = k_first_alias_x86_64,
+ lldb_ebx_x86_64,
+ lldb_ecx_x86_64,
+ lldb_edx_x86_64,
+ lldb_edi_x86_64,
+ lldb_esi_x86_64,
+ lldb_ebp_x86_64,
+ lldb_esp_x86_64,
+ lldb_r8d_x86_64, // Low 32 bits of r8
+ lldb_r9d_x86_64, // Low 32 bits of r9
+ lldb_r10d_x86_64, // Low 32 bits of r10
+ lldb_r11d_x86_64, // Low 32 bits of r11
+ lldb_r12d_x86_64, // Low 32 bits of r12
+ lldb_r13d_x86_64, // Low 32 bits of r13
+ lldb_r14d_x86_64, // Low 32 bits of r14
+ lldb_r15d_x86_64, // Low 32 bits of r15
+ lldb_ax_x86_64,
+ lldb_bx_x86_64,
+ lldb_cx_x86_64,
+ lldb_dx_x86_64,
+ lldb_di_x86_64,
+ lldb_si_x86_64,
+ lldb_bp_x86_64,
+ lldb_sp_x86_64,
+ lldb_r8w_x86_64, // Low 16 bits of r8
+ lldb_r9w_x86_64, // Low 16 bits of r9
+ lldb_r10w_x86_64, // Low 16 bits of r10
+ lldb_r11w_x86_64, // Low 16 bits of r11
+ lldb_r12w_x86_64, // Low 16 bits of r12
+ lldb_r13w_x86_64, // Low 16 bits of r13
+ lldb_r14w_x86_64, // Low 16 bits of r14
+ lldb_r15w_x86_64, // Low 16 bits of r15
+ lldb_ah_x86_64,
+ lldb_bh_x86_64,
+ lldb_ch_x86_64,
+ lldb_dh_x86_64,
+ lldb_al_x86_64,
+ lldb_bl_x86_64,
+ lldb_cl_x86_64,
+ lldb_dl_x86_64,
+ lldb_dil_x86_64,
+ lldb_sil_x86_64,
+ lldb_bpl_x86_64,
+ lldb_spl_x86_64,
+ lldb_r8l_x86_64, // Low 8 bits of r8
+ lldb_r9l_x86_64, // Low 8 bits of r9
+ lldb_r10l_x86_64, // Low 8 bits of r10
+ lldb_r11l_x86_64, // Low 8 bits of r11
+ lldb_r12l_x86_64, // Low 8 bits of r12
+ lldb_r13l_x86_64, // Low 8 bits of r13
+ lldb_r14l_x86_64, // Low 8 bits of r14
+ lldb_r15l_x86_64, // Low 8 bits of r15
+ k_last_alias_x86_64 = lldb_r15l_x86_64,
+
+ k_last_gpr_x86_64 = k_last_alias_x86_64,
+
+ k_first_fpr_x86_64,
+ lldb_fctrl_x86_64 = k_first_fpr_x86_64,
+ lldb_fstat_x86_64,
+ lldb_ftag_x86_64,
+ lldb_fop_x86_64,
+ lldb_fiseg_x86_64,
+ lldb_fioff_x86_64,
+ lldb_foseg_x86_64,
+ lldb_fooff_x86_64,
+ lldb_mxcsr_x86_64,
+ lldb_mxcsrmask_x86_64,
+ lldb_st0_x86_64,
+ lldb_st1_x86_64,
+ lldb_st2_x86_64,
+ lldb_st3_x86_64,
+ lldb_st4_x86_64,
+ lldb_st5_x86_64,
+ lldb_st6_x86_64,
+ lldb_st7_x86_64,
+ lldb_mm0_x86_64,
+ lldb_mm1_x86_64,
+ lldb_mm2_x86_64,
+ lldb_mm3_x86_64,
+ lldb_mm4_x86_64,
+ lldb_mm5_x86_64,
+ lldb_mm6_x86_64,
+ lldb_mm7_x86_64,
+ lldb_xmm0_x86_64,
+ lldb_xmm1_x86_64,
+ lldb_xmm2_x86_64,
+ lldb_xmm3_x86_64,
+ lldb_xmm4_x86_64,
+ lldb_xmm5_x86_64,
+ lldb_xmm6_x86_64,
+ lldb_xmm7_x86_64,
+ lldb_xmm8_x86_64,
+ lldb_xmm9_x86_64,
+ lldb_xmm10_x86_64,
+ lldb_xmm11_x86_64,
+ lldb_xmm12_x86_64,
+ lldb_xmm13_x86_64,
+ lldb_xmm14_x86_64,
+ lldb_xmm15_x86_64,
+ k_last_fpr_x86_64 = lldb_xmm15_x86_64,
+
+ k_first_avx_x86_64,
+ lldb_ymm0_x86_64 = k_first_avx_x86_64,
+ lldb_ymm1_x86_64,
+ lldb_ymm2_x86_64,
+ lldb_ymm3_x86_64,
+ lldb_ymm4_x86_64,
+ lldb_ymm5_x86_64,
+ lldb_ymm6_x86_64,
+ lldb_ymm7_x86_64,
+ lldb_ymm8_x86_64,
+ lldb_ymm9_x86_64,
+ lldb_ymm10_x86_64,
+ lldb_ymm11_x86_64,
+ lldb_ymm12_x86_64,
+ lldb_ymm13_x86_64,
+ lldb_ymm14_x86_64,
+ lldb_ymm15_x86_64,
+ k_last_avx_x86_64 = lldb_ymm15_x86_64,
+
+ lldb_dr0_x86_64,
+ lldb_dr1_x86_64,
+ lldb_dr2_x86_64,
+ lldb_dr3_x86_64,
+ lldb_dr4_x86_64,
+ lldb_dr5_x86_64,
+ lldb_dr6_x86_64,
+ lldb_dr7_x86_64,
+
+ k_num_registers_x86_64,
+ k_num_gpr_registers_x86_64 = k_last_gpr_x86_64 - k_first_gpr_x86_64 + 1,
+ k_num_fpr_registers_x86_64 = k_last_fpr_x86_64 - k_first_fpr_x86_64 + 1,
+ k_num_avx_registers_x86_64 = k_last_avx_x86_64 - k_first_avx_x86_64 + 1,
+ k_num_user_registers_x86_64 = k_num_gpr_registers_x86_64 +
+ k_num_fpr_registers_x86_64 +
+ k_num_avx_registers_x86_64,
+};
}
#endif // #ifndef lldb_x86_register_enums_h
Modified: lldb/trunk/source/Plugins/Process/Windows/Common/ExceptionRecord.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Windows/Common/ExceptionRecord.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/Windows/Common/ExceptionRecord.h (original)
+++ lldb/trunk/source/Plugins/Process/Windows/Common/ExceptionRecord.h Tue Sep 6 15:57:50 2016
@@ -10,15 +10,14 @@
#ifndef liblldb_Plugins_Process_Windows_ExceptionRecord_H_
#define liblldb_Plugins_Process_Windows_ExceptionRecord_H_
-#include "lldb/lldb-forward.h"
#include "lldb/Host/windows/windows.h"
+#include "lldb/lldb-forward.h"
#include <DbgHelp.h>
#include <memory>
#include <vector>
-namespace lldb_private
-{
+namespace lldb_private {
//----------------------------------------------------------------------
// ExceptionRecord
@@ -26,73 +25,55 @@ namespace lldb_private
// ExceptionRecord defines an interface which allows implementors to receive
// notification of events that happen in a debugged process.
//----------------------------------------------------------------------
-class ExceptionRecord
-{
- public:
- ExceptionRecord(const EXCEPTION_RECORD &record, lldb::tid_t thread_id)
- {
- m_code = record.ExceptionCode;
- m_continuable = (record.ExceptionFlags == 0);
- if (record.ExceptionRecord)
- m_next_exception.reset(new ExceptionRecord(*record.ExceptionRecord, thread_id));
- m_exception_addr = reinterpret_cast<lldb::addr_t>(record.ExceptionAddress);
- m_thread_id = thread_id;
- m_arguments.assign(record.ExceptionInformation, record.ExceptionInformation + record.NumberParameters);
- }
-
- // MINIDUMP_EXCEPTIONs are almost identical to EXCEPTION_RECORDs.
- ExceptionRecord(const MINIDUMP_EXCEPTION &record, lldb::tid_t thread_id) :
- m_code(record.ExceptionCode),
- m_continuable(record.ExceptionFlags == 0),
+class ExceptionRecord {
+public:
+ ExceptionRecord(const EXCEPTION_RECORD &record, lldb::tid_t thread_id) {
+ m_code = record.ExceptionCode;
+ m_continuable = (record.ExceptionFlags == 0);
+ if (record.ExceptionRecord)
+ m_next_exception.reset(
+ new ExceptionRecord(*record.ExceptionRecord, thread_id));
+ m_exception_addr = reinterpret_cast<lldb::addr_t>(record.ExceptionAddress);
+ m_thread_id = thread_id;
+ m_arguments.assign(record.ExceptionInformation,
+ record.ExceptionInformation + record.NumberParameters);
+ }
+
+ // MINIDUMP_EXCEPTIONs are almost identical to EXCEPTION_RECORDs.
+ ExceptionRecord(const MINIDUMP_EXCEPTION &record, lldb::tid_t thread_id)
+ : m_code(record.ExceptionCode), m_continuable(record.ExceptionFlags == 0),
m_next_exception(nullptr),
m_exception_addr(static_cast<lldb::addr_t>(record.ExceptionAddress)),
m_thread_id(thread_id),
- m_arguments(record.ExceptionInformation, record.ExceptionInformation + record.NumberParameters)
- {
- // Set up link to nested exception.
- if (record.ExceptionRecord)
- {
- m_next_exception.reset(new ExceptionRecord(*reinterpret_cast<const MINIDUMP_EXCEPTION *>(record.ExceptionRecord),
- thread_id));
- }
- }
-
- virtual ~ExceptionRecord() {}
-
- DWORD
- GetExceptionCode() const
- {
- return m_code;
- }
- bool
- IsContinuable() const
- {
- return m_continuable;
- }
- const ExceptionRecord *
- GetNextException() const
- {
- return m_next_exception.get();
- }
- lldb::addr_t
- GetExceptionAddress() const
- {
- return m_exception_addr;
- }
-
- lldb::tid_t
- GetThreadID() const
- {
- return m_thread_id;
- }
-
- private:
- DWORD m_code;
- bool m_continuable;
- std::shared_ptr<ExceptionRecord> m_next_exception;
- lldb::addr_t m_exception_addr;
- lldb::tid_t m_thread_id;
- std::vector<ULONG_PTR> m_arguments;
+ m_arguments(record.ExceptionInformation,
+ record.ExceptionInformation + record.NumberParameters) {
+ // Set up link to nested exception.
+ if (record.ExceptionRecord) {
+ m_next_exception.reset(new ExceptionRecord(
+ *reinterpret_cast<const MINIDUMP_EXCEPTION *>(record.ExceptionRecord),
+ thread_id));
+ }
+ }
+
+ virtual ~ExceptionRecord() {}
+
+ DWORD
+ GetExceptionCode() const { return m_code; }
+ bool IsContinuable() const { return m_continuable; }
+ const ExceptionRecord *GetNextException() const {
+ return m_next_exception.get();
+ }
+ lldb::addr_t GetExceptionAddress() const { return m_exception_addr; }
+
+ lldb::tid_t GetThreadID() const { return m_thread_id; }
+
+private:
+ DWORD m_code;
+ bool m_continuable;
+ std::shared_ptr<ExceptionRecord> m_next_exception;
+ lldb::addr_t m_exception_addr;
+ lldb::tid_t m_thread_id;
+ std::vector<ULONG_PTR> m_arguments;
};
}
Modified: lldb/trunk/source/Plugins/Process/Windows/Common/NtStructures.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Windows/Common/NtStructures.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/Windows/Common/NtStructures.h (original)
+++ lldb/trunk/source/Plugins/Process/Windows/Common/NtStructures.h Tue Sep 6 15:57:50 2016
@@ -15,18 +15,17 @@
// This describes the layout of a TEB (Thread Environment Block) for a 64-bit
// process. It's adapted from the 32-bit TEB in winternl.h. Currently, we care
// only about the position of the TlsSlots.
-struct TEB64
-{
- ULONG64 Reserved1[12];
- ULONG64 ProcessEnvironmentBlock;
- ULONG64 Reserved2[399];
- BYTE Reserved3[1952];
- ULONG64 TlsSlots[64];
- BYTE Reserved4[8];
- ULONG64 Reserved5[26];
- ULONG64 ReservedForOle; // Windows 2000 only
- ULONG64 Reserved6[4];
- ULONG64 TlsExpansionSlots;
+struct TEB64 {
+ ULONG64 Reserved1[12];
+ ULONG64 ProcessEnvironmentBlock;
+ ULONG64 Reserved2[399];
+ BYTE Reserved3[1952];
+ ULONG64 TlsSlots[64];
+ BYTE Reserved4[8];
+ ULONG64 Reserved5[26];
+ ULONG64 ReservedForOle; // Windows 2000 only
+ ULONG64 Reserved6[4];
+ ULONG64 TlsExpansionSlots;
};
#endif
Modified: lldb/trunk/source/Plugins/Process/Windows/Common/ProcessWindows.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Windows/Common/ProcessWindows.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/Windows/Common/ProcessWindows.cpp (original)
+++ lldb/trunk/source/Plugins/Process/Windows/Common/ProcessWindows.cpp Tue Sep 6 15:57:50 2016
@@ -23,78 +23,63 @@
using namespace lldb;
using namespace lldb_private;
-namespace lldb_private
-{
+namespace lldb_private {
//------------------------------------------------------------------------------
// Constructors and destructors.
-ProcessWindows::ProcessWindows(lldb::TargetSP target_sp, lldb::ListenerSP listener_sp)
- : lldb_private::Process(target_sp, listener_sp)
-{
-}
+ProcessWindows::ProcessWindows(lldb::TargetSP target_sp,
+ lldb::ListenerSP listener_sp)
+ : lldb_private::Process(target_sp, listener_sp) {}
-ProcessWindows::~ProcessWindows()
-{
-}
+ProcessWindows::~ProcessWindows() {}
-size_t
-ProcessWindows::GetSTDOUT(char *buf, size_t buf_size, Error &error)
-{
- error.SetErrorString("GetSTDOUT unsupported on Windows");
- return 0;
+size_t ProcessWindows::GetSTDOUT(char *buf, size_t buf_size, Error &error) {
+ error.SetErrorString("GetSTDOUT unsupported on Windows");
+ return 0;
}
-size_t
-ProcessWindows::GetSTDERR(char *buf, size_t buf_size, Error &error)
-{
- error.SetErrorString("GetSTDERR unsupported on Windows");
- return 0;
+size_t ProcessWindows::GetSTDERR(char *buf, size_t buf_size, Error &error) {
+ error.SetErrorString("GetSTDERR unsupported on Windows");
+ return 0;
}
-size_t
-ProcessWindows::PutSTDIN(const char *buf, size_t buf_size, Error &error)
-{
- error.SetErrorString("PutSTDIN unsupported on Windows");
- return 0;
+size_t ProcessWindows::PutSTDIN(const char *buf, size_t buf_size,
+ Error &error) {
+ error.SetErrorString("PutSTDIN unsupported on Windows");
+ return 0;
}
//------------------------------------------------------------------------------
// ProcessInterface protocol.
-
-lldb::addr_t
-ProcessWindows::GetImageInfoAddress()
-{
- Target &target = GetTarget();
- ObjectFile *obj_file = target.GetExecutableModule()->GetObjectFile();
- Address addr = obj_file->GetImageInfoAddress(&target);
- if (addr.IsValid())
- return addr.GetLoadAddress(&target);
- else
- return LLDB_INVALID_ADDRESS;
+lldb::addr_t ProcessWindows::GetImageInfoAddress() {
+ Target &target = GetTarget();
+ ObjectFile *obj_file = target.GetExecutableModule()->GetObjectFile();
+ Address addr = obj_file->GetImageInfoAddress(&target);
+ if (addr.IsValid())
+ return addr.GetLoadAddress(&target);
+ else
+ return LLDB_INVALID_ADDRESS;
}
-// The Windows page protection bits are NOT independent masks that can be bitwise-ORed
+// The Windows page protection bits are NOT independent masks that can be
+// bitwise-ORed
// together. For example, PAGE_EXECUTE_READ is not (PAGE_EXECUTE | PAGE_READ).
-// To test for an access type, it's necessary to test for any of the bits that provide
+// To test for an access type, it's necessary to test for any of the bits that
+// provide
// that access type.
-bool
-ProcessWindows::IsPageReadable(uint32_t protect)
-{
- return (protect & PAGE_NOACCESS) == 0;
-}
-
-bool
-ProcessWindows::IsPageWritable(uint32_t protect)
-{
- return (protect & (PAGE_EXECUTE_READWRITE | PAGE_EXECUTE_WRITECOPY | PAGE_READWRITE | PAGE_WRITECOPY)) != 0;
-}
-
-bool
-ProcessWindows::IsPageExecutable(uint32_t protect)
-{
- return (protect & (PAGE_EXECUTE | PAGE_EXECUTE_READ | PAGE_EXECUTE_READWRITE | PAGE_EXECUTE_WRITECOPY)) != 0;
+bool ProcessWindows::IsPageReadable(uint32_t protect) {
+ return (protect & PAGE_NOACCESS) == 0;
}
+bool ProcessWindows::IsPageWritable(uint32_t protect) {
+ return (protect & (PAGE_EXECUTE_READWRITE | PAGE_EXECUTE_WRITECOPY |
+ PAGE_READWRITE | PAGE_WRITECOPY)) != 0;
+}
+
+bool ProcessWindows::IsPageExecutable(uint32_t protect) {
+ return (protect & (PAGE_EXECUTE | PAGE_EXECUTE_READ | PAGE_EXECUTE_READWRITE |
+ PAGE_EXECUTE_WRITECOPY)) != 0;
+}
}
Modified: lldb/trunk/source/Plugins/Process/Windows/Common/ProcessWindows.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Windows/Common/ProcessWindows.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/Windows/Common/ProcessWindows.h (original)
+++ lldb/trunk/source/Plugins/Process/Windows/Common/ProcessWindows.h Tue Sep 6 15:57:50 2016
@@ -11,42 +11,38 @@
#define liblldb_Plugins_Process_Windows_Common_ProcessWindows_H_
// Other libraries and framework includes
-#include "lldb/lldb-forward.h"
#include "lldb/Core/Error.h"
#include "lldb/Target/Process.h"
+#include "lldb/lldb-forward.h"
-namespace lldb_private
-{
+namespace lldb_private {
-class ProcessWindows : public lldb_private::Process
-{
+class ProcessWindows : public lldb_private::Process {
public:
- //------------------------------------------------------------------
- // Constructors and destructors
- //------------------------------------------------------------------
- ProcessWindows(lldb::TargetSP target_sp,
- lldb::ListenerSP listener_sp);
-
- ~ProcessWindows();
-
- size_t GetSTDOUT(char *buf, size_t buf_size, lldb_private::Error &error) override;
- size_t GetSTDERR(char *buf, size_t buf_size, lldb_private::Error &error) override;
- size_t PutSTDIN(const char *buf, size_t buf_size, lldb_private::Error &error) override;
+ //------------------------------------------------------------------
+ // Constructors and destructors
+ //------------------------------------------------------------------
+ ProcessWindows(lldb::TargetSP target_sp, lldb::ListenerSP listener_sp);
+
+ ~ProcessWindows();
+
+ size_t GetSTDOUT(char *buf, size_t buf_size,
+ lldb_private::Error &error) override;
+ size_t GetSTDERR(char *buf, size_t buf_size,
+ lldb_private::Error &error) override;
+ size_t PutSTDIN(const char *buf, size_t buf_size,
+ lldb_private::Error &error) override;
- lldb::addr_t GetImageInfoAddress() override;
+ lldb::addr_t GetImageInfoAddress() override;
protected:
- // These decode the page protection bits.
- static bool
- IsPageReadable(uint32_t protect);
+ // These decode the page protection bits.
+ static bool IsPageReadable(uint32_t protect);
- static bool
- IsPageWritable(uint32_t protect);
+ static bool IsPageWritable(uint32_t protect);
- static bool
- IsPageExecutable(uint32_t protect);
+ static bool IsPageExecutable(uint32_t protect);
};
-
}
-#endif // liblldb_Plugins_Process_Windows_Common_ProcessWindows_H_
+#endif // liblldb_Plugins_Process_Windows_Common_ProcessWindows_H_
Modified: lldb/trunk/source/Plugins/Process/Windows/Common/ProcessWindowsLog.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Windows/Common/ProcessWindowsLog.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/Windows/Common/ProcessWindowsLog.cpp (original)
+++ lldb/trunk/source/Plugins/Process/Windows/Common/ProcessWindowsLog.cpp Tue Sep 6 15:57:50 2016
@@ -18,177 +18,151 @@
using namespace lldb;
using namespace lldb_private;
-
// We want to avoid global constructors where code needs to be run so here we
// control access to our static g_log_sp by hiding it in a singleton function
// that will construct the static g_log_sp the first time this function is
// called.
static bool g_log_enabled = false;
-static Log * g_log = nullptr;
+static Log *g_log = nullptr;
static llvm::ManagedStatic<std::once_flag> g_once_flag;
-void
-ProcessWindowsLog::Initialize()
-{
- static ConstString g_name("windows");
-
- std::call_once(*g_once_flag, [](){
- Log::Callbacks log_callbacks = {
- DisableLog,
- EnableLog,
- ListLogCategories
- };
-
- Log::RegisterLogChannel(g_name, log_callbacks);
- RegisterPluginName(g_name);
- });
-}
-
-void
-ProcessWindowsLog::Terminate()
-{
-}
-
-Log *
-ProcessWindowsLog::GetLog()
-{
- return (g_log_enabled) ? g_log : nullptr;
-}
-
-bool
-ProcessWindowsLog::TestLogFlags(uint32_t mask, LogMaskReq req)
-{
- Log *log = GetLog();
- if (!log)
- return false;
-
- uint32_t log_mask = log->GetMask().Get();
- if (req == LogMaskReq::All)
- return ((log_mask & mask) == mask);
- else
- return (log_mask & mask);
-}
+void ProcessWindowsLog::Initialize() {
+ static ConstString g_name("windows");
-static uint32_t
-GetFlagBits(const char *arg)
-{
- if (::strcasecmp(arg, "all") == 0 ) return WINDOWS_LOG_ALL;
- else if (::strcasecmp(arg, "break") == 0 ) return WINDOWS_LOG_BREAKPOINTS;
- else if (::strcasecmp(arg, "event") == 0 ) return WINDOWS_LOG_EVENT;
- else if (::strcasecmp(arg, "exception") == 0 ) return WINDOWS_LOG_EXCEPTION;
- else if (::strcasecmp(arg, "memory") == 0 ) return WINDOWS_LOG_MEMORY;
- else if (::strcasecmp(arg, "process") == 0 ) return WINDOWS_LOG_PROCESS;
- else if (::strcasecmp(arg, "registers") == 0 ) return WINDOWS_LOG_REGISTERS;
- else if (::strcasecmp(arg, "step") == 0 ) return WINDOWS_LOG_STEP;
- else if (::strcasecmp(arg, "thread") == 0 ) return WINDOWS_LOG_THREAD;
- else if (::strcasecmp(arg, "verbose") == 0 ) return WINDOWS_LOG_VERBOSE;
- return 0;
-}
-
-void
-ProcessWindowsLog::DisableLog(const char **args, Stream *feedback_strm)
-{
- Log *log (GetLog());
- if (log)
- {
- uint32_t flag_bits = 0;
-
- if (args[0] != nullptr)
- {
- flag_bits = log->GetMask().Get();
- for (; args[0]; args++)
- {
- const char *arg = args[0];
- uint32_t bits = GetFlagBits(arg);
-
- if (bits)
- {
- flag_bits &= ~bits;
- }
- else
- {
- feedback_strm->Printf("error: unrecognized log category '%s'\n", arg);
- ListLogCategories(feedback_strm);
- }
- }
- }
+ std::call_once(*g_once_flag, []() {
+ Log::Callbacks log_callbacks = {DisableLog, EnableLog, ListLogCategories};
- log->GetMask().Reset(flag_bits);
- if (flag_bits == 0)
- {
- g_log_enabled = false;
- log->SetStream(lldb::StreamSP());
+ Log::RegisterLogChannel(g_name, log_callbacks);
+ RegisterPluginName(g_name);
+ });
+}
+
+void ProcessWindowsLog::Terminate() {}
+
+Log *ProcessWindowsLog::GetLog() { return (g_log_enabled) ? g_log : nullptr; }
+
+bool ProcessWindowsLog::TestLogFlags(uint32_t mask, LogMaskReq req) {
+ Log *log = GetLog();
+ if (!log)
+ return false;
+
+ uint32_t log_mask = log->GetMask().Get();
+ if (req == LogMaskReq::All)
+ return ((log_mask & mask) == mask);
+ else
+ return (log_mask & mask);
+}
+
+static uint32_t GetFlagBits(const char *arg) {
+ if (::strcasecmp(arg, "all") == 0)
+ return WINDOWS_LOG_ALL;
+ else if (::strcasecmp(arg, "break") == 0)
+ return WINDOWS_LOG_BREAKPOINTS;
+ else if (::strcasecmp(arg, "event") == 0)
+ return WINDOWS_LOG_EVENT;
+ else if (::strcasecmp(arg, "exception") == 0)
+ return WINDOWS_LOG_EXCEPTION;
+ else if (::strcasecmp(arg, "memory") == 0)
+ return WINDOWS_LOG_MEMORY;
+ else if (::strcasecmp(arg, "process") == 0)
+ return WINDOWS_LOG_PROCESS;
+ else if (::strcasecmp(arg, "registers") == 0)
+ return WINDOWS_LOG_REGISTERS;
+ else if (::strcasecmp(arg, "step") == 0)
+ return WINDOWS_LOG_STEP;
+ else if (::strcasecmp(arg, "thread") == 0)
+ return WINDOWS_LOG_THREAD;
+ else if (::strcasecmp(arg, "verbose") == 0)
+ return WINDOWS_LOG_VERBOSE;
+ return 0;
+}
+
+void ProcessWindowsLog::DisableLog(const char **args, Stream *feedback_strm) {
+ Log *log(GetLog());
+ if (log) {
+ uint32_t flag_bits = 0;
+
+ if (args[0] != nullptr) {
+ flag_bits = log->GetMask().Get();
+ for (; args[0]; args++) {
+ const char *arg = args[0];
+ uint32_t bits = GetFlagBits(arg);
+
+ if (bits) {
+ flag_bits &= ~bits;
+ } else {
+ feedback_strm->Printf("error: unrecognized log category '%s'\n", arg);
+ ListLogCategories(feedback_strm);
}
+ }
}
- return;
-}
+ log->GetMask().Reset(flag_bits);
+ if (flag_bits == 0) {
+ g_log_enabled = false;
+ log->SetStream(lldb::StreamSP());
+ }
+ }
-Log *
-ProcessWindowsLog::EnableLog(StreamSP &log_stream_sp, uint32_t log_options, const char **args, Stream *feedback_strm)
-{
- // Try see if there already is a log - that way we can reuse its settings.
- // We could reuse the log in toto, but we don't know that the stream is the same.
- uint32_t flag_bits = 0;
- if (g_log)
- flag_bits = g_log->GetMask().Get();
+ return;
+}
- // Now make a new log with this stream if one was provided
- if (log_stream_sp)
- {
- if (g_log)
- g_log->SetStream(log_stream_sp);
- else
- g_log = new Log(log_stream_sp);
- }
+Log *ProcessWindowsLog::EnableLog(StreamSP &log_stream_sp, uint32_t log_options,
+ const char **args, Stream *feedback_strm) {
+ // Try see if there already is a log - that way we can reuse its settings.
+ // We could reuse the log in toto, but we don't know that the stream is the
+ // same.
+ uint32_t flag_bits = 0;
+ if (g_log)
+ flag_bits = g_log->GetMask().Get();
+ // Now make a new log with this stream if one was provided
+ if (log_stream_sp) {
if (g_log)
- {
- bool got_unknown_category = false;
- for (; args[0]; args++)
- {
- const char *arg = args[0];
- uint32_t bits = GetFlagBits(arg);
-
- if (bits)
- {
- flag_bits |= bits;
- }
- else
- {
- feedback_strm->Printf("error: unrecognized log category '%s'\n", arg);
- if (got_unknown_category == false)
- {
- got_unknown_category = true;
- ListLogCategories (feedback_strm);
- }
- }
+ g_log->SetStream(log_stream_sp);
+ else
+ g_log = new Log(log_stream_sp);
+ }
+
+ if (g_log) {
+ bool got_unknown_category = false;
+ for (; args[0]; args++) {
+ const char *arg = args[0];
+ uint32_t bits = GetFlagBits(arg);
+
+ if (bits) {
+ flag_bits |= bits;
+ } else {
+ feedback_strm->Printf("error: unrecognized log category '%s'\n", arg);
+ if (got_unknown_category == false) {
+ got_unknown_category = true;
+ ListLogCategories(feedback_strm);
}
- if (flag_bits == 0)
- flag_bits = WINDOWS_LOG_ALL;
- g_log->GetMask().Reset(flag_bits);
- g_log->GetOptions().Reset(log_options);
- g_log_enabled = true;
+ }
}
- return g_log;
-}
-
-void
-ProcessWindowsLog::ListLogCategories(Stream *strm)
-{
- strm->Printf("Logging categories for '%s':\n"
- " all - turn on all available logging categories\n"
- " break - log breakpoints\n"
- " event - log low level debugger events\n"
- " exception - log exception information\n"
- " memory - log memory reads and writes\n"
- " process - log process events and activities\n"
- " registers - log register read/writes\n"
- " thread - log thread events and activities\n"
- " step - log step related activities\n"
- " verbose - enable verbose logging\n",
- ProcessWindowsLog::m_pluginname);
+ if (flag_bits == 0)
+ flag_bits = WINDOWS_LOG_ALL;
+ g_log->GetMask().Reset(flag_bits);
+ g_log->GetOptions().Reset(log_options);
+ g_log_enabled = true;
+ }
+ return g_log;
+}
+
+void ProcessWindowsLog::ListLogCategories(Stream *strm) {
+ strm->Printf("Logging categories for '%s':\n"
+ " all - turn on all available logging categories\n"
+ " break - log breakpoints\n"
+ " event - log low level debugger events\n"
+ " exception - log exception information\n"
+ " memory - log memory reads and writes\n"
+ " process - log process events and activities\n"
+ " registers - log register read/writes\n"
+ " thread - log thread events and activities\n"
+ " step - log step related activities\n"
+ " verbose - enable verbose logging\n",
+ ProcessWindowsLog::m_pluginname);
}
const char *ProcessWindowsLog::m_pluginname = "";
Modified: lldb/trunk/source/Plugins/Process/Windows/Common/ProcessWindowsLog.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Windows/Common/ProcessWindowsLog.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/Windows/Common/ProcessWindowsLog.h (original)
+++ lldb/trunk/source/Plugins/Process/Windows/Common/ProcessWindowsLog.h Tue Sep 6 15:57:50 2016
@@ -12,85 +12,80 @@
#include "lldb/Core/Log.h"
-#define WINDOWS_LOG_VERBOSE (1u << 0)
-#define WINDOWS_LOG_PROCESS (1u << 1) // Log process operations
-#define WINDOWS_LOG_EXCEPTION (1u << 1) // Log exceptions
-#define WINDOWS_LOG_THREAD (1u << 2) // Log thread operations
-#define WINDOWS_LOG_MEMORY (1u << 3) // Log memory reads/writes calls
-#define WINDOWS_LOG_BREAKPOINTS (1u << 4) // Log breakpoint operations
-#define WINDOWS_LOG_STEP (1u << 5) // Log step operations
-#define WINDOWS_LOG_REGISTERS (1u << 6) // Log register operations
-#define WINDOWS_LOG_EVENT (1u << 7) // Low level debug events
-#define WINDOWS_LOG_ALL (UINT32_MAX)
-
-enum class LogMaskReq
-{
- All,
- Any
-};
+#define WINDOWS_LOG_VERBOSE (1u << 0)
+#define WINDOWS_LOG_PROCESS (1u << 1) // Log process operations
+#define WINDOWS_LOG_EXCEPTION (1u << 1) // Log exceptions
+#define WINDOWS_LOG_THREAD (1u << 2) // Log thread operations
+#define WINDOWS_LOG_MEMORY (1u << 3) // Log memory reads/writes calls
+#define WINDOWS_LOG_BREAKPOINTS (1u << 4) // Log breakpoint operations
+#define WINDOWS_LOG_STEP (1u << 5) // Log step operations
+#define WINDOWS_LOG_REGISTERS (1u << 6) // Log register operations
+#define WINDOWS_LOG_EVENT (1u << 7) // Low level debug events
+#define WINDOWS_LOG_ALL (UINT32_MAX)
+
+enum class LogMaskReq { All, Any };
-class ProcessWindowsLog
-{
- static const char *m_pluginname;
+class ProcessWindowsLog {
+ static const char *m_pluginname;
public:
- // ---------------------------------------------------------------------
- // Public Static Methods
- // ---------------------------------------------------------------------
- static void
- Initialize();
-
- static void
- Terminate();
-
- static void
- RegisterPluginName(const char *pluginName)
- {
- m_pluginname = pluginName;
- }
-
- static void
- RegisterPluginName(lldb_private::ConstString pluginName)
- {
- m_pluginname = pluginName.GetCString();
- }
-
- static bool
- TestLogFlags(uint32_t mask, LogMaskReq req);
-
- static lldb_private::Log *
- GetLog();
-
- static void
- DisableLog(const char **args, lldb_private::Stream *feedback_strm);
-
- static lldb_private::Log *
- EnableLog(lldb::StreamSP &log_stream_sp, uint32_t log_options,
- const char **args, lldb_private::Stream *feedback_strm);
+ // ---------------------------------------------------------------------
+ // Public Static Methods
+ // ---------------------------------------------------------------------
+ static void Initialize();
+
+ static void Terminate();
+
+ static void RegisterPluginName(const char *pluginName) {
+ m_pluginname = pluginName;
+ }
+
+ static void RegisterPluginName(lldb_private::ConstString pluginName) {
+ m_pluginname = pluginName.GetCString();
+ }
+
+ static bool TestLogFlags(uint32_t mask, LogMaskReq req);
+
+ static lldb_private::Log *GetLog();
+
+ static void DisableLog(const char **args,
+ lldb_private::Stream *feedback_strm);
+
+ static lldb_private::Log *EnableLog(lldb::StreamSP &log_stream_sp,
+ uint32_t log_options, const char **args,
+ lldb_private::Stream *feedback_strm);
- static void
- ListLogCategories(lldb_private::Stream *strm);
+ static void ListLogCategories(lldb_private::Stream *strm);
};
-#define WINLOGF_IF(Flags, Req, Method, ...) \
- { \
- if (ProcessWindowsLog::TestLogFlags(Flags, Req)) \
- { \
- Log *log = ProcessWindowsLog::GetLog(); \
- if (log) \
- log->Method(__VA_ARGS__); \
- } \
- }
-
-#define WINLOG_IFANY(Flags, ...) WINLOGF_IF(Flags, LogMaskReq::Any, Printf, __VA_ARGS__)
-#define WINLOG_IFALL(Flags, ...) WINLOGF_IF(Flags, LogMaskReq::All, Printf, __VA_ARGS__)
-#define WINLOGV_IFANY(Flags, ...) WINLOGF_IF(Flags, LogMaskReq::Any, Verbose, __VA_ARGS__)
-#define WINLOGV_IFALL(Flags, ...) WINLOGF_IF(Flags, LogMaskReq::All, Verbose, __VA_ARGS__)
-#define WINLOGD_IFANY(Flags, ...) WINLOGF_IF(Flags, LogMaskReq::Any, Debug, __VA_ARGS__)
-#define WINLOGD_IFALL(Flags, ...) WINLOGF_IF(Flags, LogMaskReq::All, Debug, __VA_ARGS__)
-#define WINERR_IFANY(Flags, ...) WINLOGF_IF(Flags, LogMaskReq::Any, Error, __VA_ARGS__)
-#define WINERR_IFALL(Flags, ...) WINLOGF_IF(Flags, LogMaskReq::All, Error, __VA_ARGS__)
-#define WINWARN_IFANY(Flags, ...) WINLOGF_IF(Flags, LogMaskReq::Any, Warning, __VA_ARGS__)
-#define WINWARN_IFALL(Flags, ...) WINLOGF_IF(Flags, LogMaskReq::All, Warning, __VA_ARGS__)
+#define WINLOGF_IF(Flags, Req, Method, ...) \
+ { \
+ if (ProcessWindowsLog::TestLogFlags(Flags, Req)) { \
+ Log *log = ProcessWindowsLog::GetLog(); \
+ if (log) \
+ log->Method(__VA_ARGS__); \
+ } \
+ }
+
+#define WINLOG_IFANY(Flags, ...) \
+ WINLOGF_IF(Flags, LogMaskReq::Any, Printf, __VA_ARGS__)
+#define WINLOG_IFALL(Flags, ...) \
+ WINLOGF_IF(Flags, LogMaskReq::All, Printf, __VA_ARGS__)
+#define WINLOGV_IFANY(Flags, ...) \
+ WINLOGF_IF(Flags, LogMaskReq::Any, Verbose, __VA_ARGS__)
+#define WINLOGV_IFALL(Flags, ...) \
+ WINLOGF_IF(Flags, LogMaskReq::All, Verbose, __VA_ARGS__)
+#define WINLOGD_IFANY(Flags, ...) \
+ WINLOGF_IF(Flags, LogMaskReq::Any, Debug, __VA_ARGS__)
+#define WINLOGD_IFALL(Flags, ...) \
+ WINLOGF_IF(Flags, LogMaskReq::All, Debug, __VA_ARGS__)
+#define WINERR_IFANY(Flags, ...) \
+ WINLOGF_IF(Flags, LogMaskReq::Any, Error, __VA_ARGS__)
+#define WINERR_IFALL(Flags, ...) \
+ WINLOGF_IF(Flags, LogMaskReq::All, Error, __VA_ARGS__)
+#define WINWARN_IFANY(Flags, ...) \
+ WINLOGF_IF(Flags, LogMaskReq::Any, Warning, __VA_ARGS__)
+#define WINWARN_IFALL(Flags, ...) \
+ WINLOGF_IF(Flags, LogMaskReq::All, Warning, __VA_ARGS__)
-#endif // liblldb_ProcessWindowsLog_h_
+#endif // liblldb_ProcessWindowsLog_h_
Modified: lldb/trunk/source/Plugins/Process/Windows/Common/RegisterContextWindows.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Windows/Common/RegisterContextWindows.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/Windows/Common/RegisterContextWindows.cpp (original)
+++ lldb/trunk/source/Plugins/Process/Windows/Common/RegisterContextWindows.cpp Tue Sep 6 15:57:50 2016
@@ -7,11 +7,11 @@
//
//===----------------------------------------------------------------------===//
-#include "lldb/lldb-private-types.h"
#include "lldb/Core/DataBufferHeap.h"
#include "lldb/Core/Error.h"
#include "lldb/Host/windows/HostThreadWindows.h"
#include "lldb/Host/windows/windows.h"
+#include "lldb/lldb-private-types.h"
#include "ProcessWindowsLog.h"
#include "RegisterContextWindows.h"
@@ -27,129 +27,110 @@ const DWORD kWinContextFlags = CONTEXT_C
//------------------------------------------------------------------
// Constructors and Destructors
//------------------------------------------------------------------
-RegisterContextWindows::RegisterContextWindows(Thread &thread, uint32_t concrete_frame_idx)
- : RegisterContext(thread, concrete_frame_idx)
- , m_context()
- , m_context_stale(true)
-{
-}
-
-RegisterContextWindows::~RegisterContextWindows()
-{
-}
-
-void
-RegisterContextWindows::InvalidateAllRegisters()
-{
- m_context_stale = true;
-}
-
-bool
-RegisterContextWindows::ReadAllRegisterValues(lldb::DataBufferSP &data_sp)
-{
- if (!CacheAllRegisterValues())
- return false;
- if (data_sp->GetByteSize() < sizeof(m_context))
- {
- data_sp.reset(new DataBufferHeap(sizeof(CONTEXT), 0));
- }
- memcpy(data_sp->GetBytes(), &m_context, sizeof(m_context));
- return true;
+RegisterContextWindows::RegisterContextWindows(Thread &thread,
+ uint32_t concrete_frame_idx)
+ : RegisterContext(thread, concrete_frame_idx), m_context(),
+ m_context_stale(true) {}
+
+RegisterContextWindows::~RegisterContextWindows() {}
+
+void RegisterContextWindows::InvalidateAllRegisters() {
+ m_context_stale = true;
}
-bool
-RegisterContextWindows::WriteAllRegisterValues(const lldb::DataBufferSP &data_sp)
-{
- assert(data_sp->GetByteSize() >= sizeof(m_context));
- memcpy(&m_context, data_sp->GetBytes(), sizeof(m_context));
-
- TargetThreadWindows &wthread = static_cast<TargetThreadWindows &>(m_thread);
- if (!::SetThreadContext(wthread.GetHostThread().GetNativeThread().GetSystemHandle(), &m_context))
- return false;
+bool RegisterContextWindows::ReadAllRegisterValues(
+ lldb::DataBufferSP &data_sp) {
+ if (!CacheAllRegisterValues())
+ return false;
+ if (data_sp->GetByteSize() < sizeof(m_context)) {
+ data_sp.reset(new DataBufferHeap(sizeof(CONTEXT), 0));
+ }
+ memcpy(data_sp->GetBytes(), &m_context, sizeof(m_context));
+ return true;
+}
+
+bool RegisterContextWindows::WriteAllRegisterValues(
+ const lldb::DataBufferSP &data_sp) {
+ assert(data_sp->GetByteSize() >= sizeof(m_context));
+ memcpy(&m_context, data_sp->GetBytes(), sizeof(m_context));
+
+ TargetThreadWindows &wthread = static_cast<TargetThreadWindows &>(m_thread);
+ if (!::SetThreadContext(
+ wthread.GetHostThread().GetNativeThread().GetSystemHandle(),
+ &m_context))
+ return false;
- return true;
+ return true;
}
-uint32_t
-RegisterContextWindows::ConvertRegisterKindToRegisterNumber(lldb::RegisterKind kind, uint32_t num)
-{
- const uint32_t num_regs = GetRegisterCount();
-
- assert(kind < kNumRegisterKinds);
- for (uint32_t reg_idx = 0; reg_idx < num_regs; ++reg_idx)
- {
- const RegisterInfo *reg_info = GetRegisterInfoAtIndex(reg_idx);
-
- if (reg_info->kinds[kind] == num)
- return reg_idx;
- }
+uint32_t RegisterContextWindows::ConvertRegisterKindToRegisterNumber(
+ lldb::RegisterKind kind, uint32_t num) {
+ const uint32_t num_regs = GetRegisterCount();
+
+ assert(kind < kNumRegisterKinds);
+ for (uint32_t reg_idx = 0; reg_idx < num_regs; ++reg_idx) {
+ const RegisterInfo *reg_info = GetRegisterInfoAtIndex(reg_idx);
- return LLDB_INVALID_REGNUM;
+ if (reg_info->kinds[kind] == num)
+ return reg_idx;
+ }
+
+ return LLDB_INVALID_REGNUM;
}
//------------------------------------------------------------------
// Subclasses can these functions if desired
//------------------------------------------------------------------
-uint32_t
-RegisterContextWindows::NumSupportedHardwareBreakpoints()
-{
- // Support for hardware breakpoints not yet implemented.
- return 0;
-}
-
-uint32_t
-RegisterContextWindows::SetHardwareBreakpoint(lldb::addr_t addr, size_t size)
-{
- return 0;
-}
-
-bool
-RegisterContextWindows::ClearHardwareBreakpoint(uint32_t hw_idx)
-{
- return false;
+uint32_t RegisterContextWindows::NumSupportedHardwareBreakpoints() {
+ // Support for hardware breakpoints not yet implemented.
+ return 0;
}
-uint32_t
-RegisterContextWindows::NumSupportedHardwareWatchpoints()
-{
- // Support for hardware watchpoints not yet implemented.
- return 0;
-}
-
-uint32_t
-RegisterContextWindows::SetHardwareWatchpoint(lldb::addr_t addr, size_t size, bool read, bool write)
-{
- return 0;
-}
-
-bool
-RegisterContextWindows::ClearHardwareWatchpoint(uint32_t hw_index)
-{
- return false;
+uint32_t RegisterContextWindows::SetHardwareBreakpoint(lldb::addr_t addr,
+ size_t size) {
+ return 0;
}
-bool
-RegisterContextWindows::HardwareSingleStep(bool enable)
-{
- return false;
+bool RegisterContextWindows::ClearHardwareBreakpoint(uint32_t hw_idx) {
+ return false;
+}
+
+uint32_t RegisterContextWindows::NumSupportedHardwareWatchpoints() {
+ // Support for hardware watchpoints not yet implemented.
+ return 0;
+}
+
+uint32_t RegisterContextWindows::SetHardwareWatchpoint(lldb::addr_t addr,
+ size_t size, bool read,
+ bool write) {
+ return 0;
}
-bool
-RegisterContextWindows::CacheAllRegisterValues()
-{
- if (!m_context_stale)
- return true;
-
- TargetThreadWindows &wthread = static_cast<TargetThreadWindows &>(m_thread);
- memset(&m_context, 0, sizeof(m_context));
- m_context.ContextFlags = kWinContextFlags;
- if (!::GetThreadContext(wthread.GetHostThread().GetNativeThread().GetSystemHandle(), &m_context))
- {
- WINERR_IFALL(WINDOWS_LOG_REGISTERS, "GetThreadContext failed with error %u while caching register values.",
- ::GetLastError());
- return false;
- }
- WINLOG_IFALL(WINDOWS_LOG_REGISTERS, "GetThreadContext successfully updated the register values.", ::GetLastError());
- m_context_stale = false;
+bool RegisterContextWindows::ClearHardwareWatchpoint(uint32_t hw_index) {
+ return false;
+}
+
+bool RegisterContextWindows::HardwareSingleStep(bool enable) { return false; }
+
+bool RegisterContextWindows::CacheAllRegisterValues() {
+ if (!m_context_stale)
return true;
+
+ TargetThreadWindows &wthread = static_cast<TargetThreadWindows &>(m_thread);
+ memset(&m_context, 0, sizeof(m_context));
+ m_context.ContextFlags = kWinContextFlags;
+ if (!::GetThreadContext(
+ wthread.GetHostThread().GetNativeThread().GetSystemHandle(),
+ &m_context)) {
+ WINERR_IFALL(
+ WINDOWS_LOG_REGISTERS,
+ "GetThreadContext failed with error %u while caching register values.",
+ ::GetLastError());
+ return false;
+ }
+ WINLOG_IFALL(WINDOWS_LOG_REGISTERS,
+ "GetThreadContext successfully updated the register values.",
+ ::GetLastError());
+ m_context_stale = false;
+ return true;
}
Modified: lldb/trunk/source/Plugins/Process/Windows/Common/RegisterContextWindows.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Windows/Common/RegisterContextWindows.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/Windows/Common/RegisterContextWindows.h (original)
+++ lldb/trunk/source/Plugins/Process/Windows/Common/RegisterContextWindows.h Tue Sep 6 15:57:50 2016
@@ -10,57 +10,57 @@
#ifndef liblldb_RegisterContextWindows_H_
#define liblldb_RegisterContextWindows_H_
-#include "lldb/lldb-forward.h"
#include "lldb/Target/RegisterContext.h"
+#include "lldb/lldb-forward.h"
-namespace lldb_private
-{
+namespace lldb_private {
class Thread;
-class RegisterContextWindows : public lldb_private::RegisterContext
-{
- public:
- //------------------------------------------------------------------
- // Constructors and Destructors
- //------------------------------------------------------------------
- RegisterContextWindows(Thread &thread, uint32_t concrete_frame_idx);
+class RegisterContextWindows : public lldb_private::RegisterContext {
+public:
+ //------------------------------------------------------------------
+ // Constructors and Destructors
+ //------------------------------------------------------------------
+ RegisterContextWindows(Thread &thread, uint32_t concrete_frame_idx);
- virtual ~RegisterContextWindows();
+ virtual ~RegisterContextWindows();
- //------------------------------------------------------------------
- // Subclasses must override these functions
- //------------------------------------------------------------------
- void InvalidateAllRegisters() override;
+ //------------------------------------------------------------------
+ // Subclasses must override these functions
+ //------------------------------------------------------------------
+ void InvalidateAllRegisters() override;
- bool ReadAllRegisterValues(lldb::DataBufferSP &data_sp) override;
+ bool ReadAllRegisterValues(lldb::DataBufferSP &data_sp) override;
- bool WriteAllRegisterValues(const lldb::DataBufferSP &data_sp) override;
+ bool WriteAllRegisterValues(const lldb::DataBufferSP &data_sp) override;
- uint32_t ConvertRegisterKindToRegisterNumber(lldb::RegisterKind kind, uint32_t num) override;
+ uint32_t ConvertRegisterKindToRegisterNumber(lldb::RegisterKind kind,
+ uint32_t num) override;
- //------------------------------------------------------------------
- // Subclasses can override these functions if desired
- //------------------------------------------------------------------
- uint32_t NumSupportedHardwareBreakpoints() override;
+ //------------------------------------------------------------------
+ // Subclasses can override these functions if desired
+ //------------------------------------------------------------------
+ uint32_t NumSupportedHardwareBreakpoints() override;
- uint32_t SetHardwareBreakpoint(lldb::addr_t addr, size_t size) override;
+ uint32_t SetHardwareBreakpoint(lldb::addr_t addr, size_t size) override;
- bool ClearHardwareBreakpoint(uint32_t hw_idx) override;
+ bool ClearHardwareBreakpoint(uint32_t hw_idx) override;
- uint32_t NumSupportedHardwareWatchpoints() override;
+ uint32_t NumSupportedHardwareWatchpoints() override;
- uint32_t SetHardwareWatchpoint(lldb::addr_t addr, size_t size, bool read, bool write) override;
+ uint32_t SetHardwareWatchpoint(lldb::addr_t addr, size_t size, bool read,
+ bool write) override;
- bool ClearHardwareWatchpoint(uint32_t hw_index) override;
+ bool ClearHardwareWatchpoint(uint32_t hw_index) override;
- bool HardwareSingleStep(bool enable) override;
+ bool HardwareSingleStep(bool enable) override;
- protected:
- virtual bool CacheAllRegisterValues();
+protected:
+ virtual bool CacheAllRegisterValues();
- CONTEXT m_context;
- bool m_context_stale;
+ CONTEXT m_context;
+ bool m_context_stale;
};
}
Modified: lldb/trunk/source/Plugins/Process/Windows/Common/TargetThreadWindows.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Windows/Common/TargetThreadWindows.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/Windows/Common/TargetThreadWindows.cpp (original)
+++ lldb/trunk/source/Plugins/Process/Windows/Common/TargetThreadWindows.cpp Tue Sep 6 15:57:50 2016
@@ -16,83 +16,66 @@
#include "lldb/Host/windows/windows.h"
#include "lldb/Target/RegisterContext.h"
-#include "TargetThreadWindows.h"
#include "ProcessWindows.h"
#include "ProcessWindowsLog.h"
+#include "TargetThreadWindows.h"
#include "UnwindLLDB.h"
using namespace lldb;
using namespace lldb_private;
-TargetThreadWindows::TargetThreadWindows(ProcessWindows &process, const HostThread &thread)
- : Thread(process, thread.GetNativeThread().GetThreadId())
- , m_host_thread(thread)
-{
-}
+TargetThreadWindows::TargetThreadWindows(ProcessWindows &process,
+ const HostThread &thread)
+ : Thread(process, thread.GetNativeThread().GetThreadId()),
+ m_host_thread(thread) {}
-TargetThreadWindows::~TargetThreadWindows()
-{
- DestroyThread();
-}
+TargetThreadWindows::~TargetThreadWindows() { DestroyThread(); }
-void
-TargetThreadWindows::RefreshStateAfterStop()
-{
- ::SuspendThread(m_host_thread.GetNativeThread().GetSystemHandle());
- SetState(eStateStopped);
- GetRegisterContext()->InvalidateIfNeeded(false);
+void TargetThreadWindows::RefreshStateAfterStop() {
+ ::SuspendThread(m_host_thread.GetNativeThread().GetSystemHandle());
+ SetState(eStateStopped);
+ GetRegisterContext()->InvalidateIfNeeded(false);
}
-void
-TargetThreadWindows::WillResume(lldb::StateType resume_state)
-{
-}
+void TargetThreadWindows::WillResume(lldb::StateType resume_state) {}
-void
-TargetThreadWindows::DidStop()
-{
-}
+void TargetThreadWindows::DidStop() {}
-bool
-TargetThreadWindows::CalculateStopInfo()
-{
- SetStopInfo(m_stop_info_sp);
- return true;
+bool TargetThreadWindows::CalculateStopInfo() {
+ SetStopInfo(m_stop_info_sp);
+ return true;
}
-Unwind *
-TargetThreadWindows::GetUnwinder()
-{
- // FIXME: Implement an unwinder based on the Windows unwinder exposed through DIA SDK.
- if (m_unwinder_ap.get() == NULL)
- m_unwinder_ap.reset(new UnwindLLDB(*this));
- return m_unwinder_ap.get();
+Unwind *TargetThreadWindows::GetUnwinder() {
+ // FIXME: Implement an unwinder based on the Windows unwinder exposed through
+ // DIA SDK.
+ if (m_unwinder_ap.get() == NULL)
+ m_unwinder_ap.reset(new UnwindLLDB(*this));
+ return m_unwinder_ap.get();
}
-bool
-TargetThreadWindows::DoResume()
-{
- StateType resume_state = GetTemporaryResumeState();
- StateType current_state = GetState();
- if (resume_state == current_state)
- return true;
-
- if (resume_state == eStateStepping)
- {
- uint32_t flags_index = GetRegisterContext()->ConvertRegisterKindToRegisterNumber(eRegisterKindGeneric, LLDB_REGNUM_GENERIC_FLAGS);
- uint64_t flags_value = GetRegisterContext()->ReadRegisterAsUnsigned(flags_index, 0);
- flags_value |= 0x100; // Set the trap flag on the CPU
- GetRegisterContext()->WriteRegisterFromUnsigned(flags_index, flags_value);
- }
-
- if (resume_state == eStateStepping || resume_state == eStateRunning)
- {
- DWORD previous_suspend_count = 0;
- HANDLE thread_handle = m_host_thread.GetNativeThread().GetSystemHandle();
- do
- {
- previous_suspend_count = ::ResumeThread(thread_handle);
- } while (previous_suspend_count > 0);
- }
+bool TargetThreadWindows::DoResume() {
+ StateType resume_state = GetTemporaryResumeState();
+ StateType current_state = GetState();
+ if (resume_state == current_state)
return true;
+
+ if (resume_state == eStateStepping) {
+ uint32_t flags_index =
+ GetRegisterContext()->ConvertRegisterKindToRegisterNumber(
+ eRegisterKindGeneric, LLDB_REGNUM_GENERIC_FLAGS);
+ uint64_t flags_value =
+ GetRegisterContext()->ReadRegisterAsUnsigned(flags_index, 0);
+ flags_value |= 0x100; // Set the trap flag on the CPU
+ GetRegisterContext()->WriteRegisterFromUnsigned(flags_index, flags_value);
+ }
+
+ if (resume_state == eStateStepping || resume_state == eStateRunning) {
+ DWORD previous_suspend_count = 0;
+ HANDLE thread_handle = m_host_thread.GetNativeThread().GetSystemHandle();
+ do {
+ previous_suspend_count = ::ResumeThread(thread_handle);
+ } while (previous_suspend_count > 0);
+ }
+ return true;
}
Modified: lldb/trunk/source/Plugins/Process/Windows/Common/TargetThreadWindows.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Windows/Common/TargetThreadWindows.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/Windows/Common/TargetThreadWindows.h (original)
+++ lldb/trunk/source/Plugins/Process/Windows/Common/TargetThreadWindows.h Tue Sep 6 15:57:50 2016
@@ -11,39 +11,33 @@
#define liblldb_Plugins_Process_Windows_TargetThreadWindows_H_
//#include "ForwardDecl.h"
-#include "lldb/lldb-forward.h"
#include "lldb/Host/HostThread.h"
#include "lldb/Target/Thread.h"
+#include "lldb/lldb-forward.h"
-namespace lldb_private
-{
+namespace lldb_private {
class ProcessWindows;
class HostThread;
class StackFrame;
-class TargetThreadWindows : public lldb_private::Thread
-{
- public:
- TargetThreadWindows(ProcessWindows &process, const HostThread &thread);
- virtual ~TargetThreadWindows();
-
- // lldb_private::Thread overrides
- void RefreshStateAfterStop() override;
- void WillResume(lldb::StateType resume_state) override;
- void DidStop() override;
- bool CalculateStopInfo() override;
- Unwind *GetUnwinder() override;
-
- bool DoResume();
-
- HostThread
- GetHostThread() const
- {
- return m_host_thread;
- }
+class TargetThreadWindows : public lldb_private::Thread {
+public:
+ TargetThreadWindows(ProcessWindows &process, const HostThread &thread);
+ virtual ~TargetThreadWindows();
+
+ // lldb_private::Thread overrides
+ void RefreshStateAfterStop() override;
+ void WillResume(lldb::StateType resume_state) override;
+ void DidStop() override;
+ bool CalculateStopInfo() override;
+ Unwind *GetUnwinder() override;
+
+ bool DoResume();
+
+ HostThread GetHostThread() const { return m_host_thread; }
- private:
- HostThread m_host_thread;
+private:
+ HostThread m_host_thread;
};
}
Modified: lldb/trunk/source/Plugins/Process/Windows/Common/x64/RegisterContextWindows_x64.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Windows/Common/x64/RegisterContextWindows_x64.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/Windows/Common/x64/RegisterContextWindows_x64.cpp (original)
+++ lldb/trunk/source/Plugins/Process/Windows/Common/x64/RegisterContextWindows_x64.cpp Tue Sep 6 15:57:50 2016
@@ -7,16 +7,16 @@
//
//===----------------------------------------------------------------------===//
-#include "lldb/lldb-private-types.h"
#include "lldb/Core/Error.h"
#include "lldb/Core/RegisterValue.h"
#include "lldb/Host/windows/HostThreadWindows.h"
#include "lldb/Host/windows/windows.h"
+#include "lldb/lldb-private-types.h"
-#include "lldb-x86-register-enums.h"
-#include "RegisterContext_x86.h"
#include "RegisterContextWindows_x64.h"
+#include "RegisterContext_x86.h"
#include "TargetThreadWindows.h"
+#include "lldb-x86-register-enums.h"
#include "llvm/ADT/STLExtras.h"
@@ -26,302 +26,317 @@ using namespace lldb_private;
#define DEFINE_GPR(reg, alt) #reg, alt, 8, 0, eEncodingUint, eFormatHexUppercase
#define DEFINE_GPR_BIN(reg, alt) #reg, alt, 8, 0, eEncodingUint, eFormatBinary
-namespace
-{
+namespace {
-// This enum defines the layout of the global RegisterInfo array. This is necessary because
-// lldb register sets are defined in terms of indices into the register array. As such, the
-// order of RegisterInfos defined in global registers array must match the order defined here.
-// When defining the register set layouts, these values can appear in an arbitrary order, and that
+// This enum defines the layout of the global RegisterInfo array. This is
+// necessary because
+// lldb register sets are defined in terms of indices into the register array.
+// As such, the
+// order of RegisterInfos defined in global registers array must match the order
+// defined here.
+// When defining the register set layouts, these values can appear in an
+// arbitrary order, and that
// determines the order that register values are displayed in a dump.
-enum RegisterIndex
-{
- eRegisterIndexRax,
- eRegisterIndexRbx,
- eRegisterIndexRcx,
- eRegisterIndexRdx,
- eRegisterIndexRdi,
- eRegisterIndexRsi,
- eRegisterIndexR8,
- eRegisterIndexR9,
- eRegisterIndexR10,
- eRegisterIndexR11,
- eRegisterIndexR12,
- eRegisterIndexR13,
- eRegisterIndexR14,
- eRegisterIndexR15,
- eRegisterIndexRbp,
- eRegisterIndexRsp,
- eRegisterIndexRip,
- eRegisterIndexRflags
+enum RegisterIndex {
+ eRegisterIndexRax,
+ eRegisterIndexRbx,
+ eRegisterIndexRcx,
+ eRegisterIndexRdx,
+ eRegisterIndexRdi,
+ eRegisterIndexRsi,
+ eRegisterIndexR8,
+ eRegisterIndexR9,
+ eRegisterIndexR10,
+ eRegisterIndexR11,
+ eRegisterIndexR12,
+ eRegisterIndexR13,
+ eRegisterIndexR14,
+ eRegisterIndexR15,
+ eRegisterIndexRbp,
+ eRegisterIndexRsp,
+ eRegisterIndexRip,
+ eRegisterIndexRflags
};
// Array of all register information supported by Windows x86
RegisterInfo g_register_infos[] = {
- // Macro auto defines most stuff eh_frame DWARF GENERIC
+ // Macro auto defines most stuff eh_frame DWARF
+ // GENERIC
// GDB LLDB VALUE REGS INVALIDATE REGS
- // ================================ ========================= ====================== =========================
+ // ================================ =========================
+ // ====================== =========================
// =================== ================= ========== ===============
{DEFINE_GPR(rax, nullptr),
- {dwarf_rax_x86_64, dwarf_rax_x86_64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, lldb_rax_x86_64},
+ {dwarf_rax_x86_64, dwarf_rax_x86_64, LLDB_INVALID_REGNUM,
+ LLDB_INVALID_REGNUM, lldb_rax_x86_64},
nullptr,
nullptr},
{DEFINE_GPR(rbx, nullptr),
- {dwarf_rbx_x86_64, dwarf_rbx_x86_64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, lldb_rbx_x86_64},
+ {dwarf_rbx_x86_64, dwarf_rbx_x86_64, LLDB_INVALID_REGNUM,
+ LLDB_INVALID_REGNUM, lldb_rbx_x86_64},
nullptr,
nullptr},
{DEFINE_GPR(rcx, nullptr),
- {dwarf_rcx_x86_64, dwarf_rcx_x86_64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, lldb_rcx_x86_64},
+ {dwarf_rcx_x86_64, dwarf_rcx_x86_64, LLDB_INVALID_REGNUM,
+ LLDB_INVALID_REGNUM, lldb_rcx_x86_64},
nullptr,
nullptr},
{DEFINE_GPR(rdx, nullptr),
- {dwarf_rdx_x86_64, dwarf_rdx_x86_64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, lldb_rdx_x86_64},
+ {dwarf_rdx_x86_64, dwarf_rdx_x86_64, LLDB_INVALID_REGNUM,
+ LLDB_INVALID_REGNUM, lldb_rdx_x86_64},
nullptr,
nullptr},
{DEFINE_GPR(rdi, nullptr),
- {dwarf_rdi_x86_64, dwarf_rdi_x86_64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, lldb_rdi_x86_64},
+ {dwarf_rdi_x86_64, dwarf_rdi_x86_64, LLDB_INVALID_REGNUM,
+ LLDB_INVALID_REGNUM, lldb_rdi_x86_64},
nullptr,
nullptr},
{DEFINE_GPR(rsi, nullptr),
- {dwarf_rsi_x86_64, dwarf_rsi_x86_64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, lldb_rsi_x86_64},
+ {dwarf_rsi_x86_64, dwarf_rsi_x86_64, LLDB_INVALID_REGNUM,
+ LLDB_INVALID_REGNUM, lldb_rsi_x86_64},
nullptr,
nullptr},
{DEFINE_GPR(r8, nullptr),
- {dwarf_r8_x86_64, dwarf_r8_x86_64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, lldb_r8_x86_64},
+ {dwarf_r8_x86_64, dwarf_r8_x86_64, LLDB_INVALID_REGNUM,
+ LLDB_INVALID_REGNUM, lldb_r8_x86_64},
nullptr,
nullptr},
{DEFINE_GPR(r9, nullptr),
- {dwarf_r9_x86_64, dwarf_r9_x86_64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, lldb_r9_x86_64},
+ {dwarf_r9_x86_64, dwarf_r9_x86_64, LLDB_INVALID_REGNUM,
+ LLDB_INVALID_REGNUM, lldb_r9_x86_64},
nullptr,
nullptr},
{DEFINE_GPR(r10, nullptr),
- {dwarf_r10_x86_64, dwarf_r10_x86_64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, lldb_r10_x86_64},
+ {dwarf_r10_x86_64, dwarf_r10_x86_64, LLDB_INVALID_REGNUM,
+ LLDB_INVALID_REGNUM, lldb_r10_x86_64},
nullptr,
nullptr},
{DEFINE_GPR(r11, nullptr),
- {dwarf_r11_x86_64, dwarf_r11_x86_64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, lldb_r11_x86_64},
+ {dwarf_r11_x86_64, dwarf_r11_x86_64, LLDB_INVALID_REGNUM,
+ LLDB_INVALID_REGNUM, lldb_r11_x86_64},
nullptr,
nullptr},
{DEFINE_GPR(r12, nullptr),
- {dwarf_r12_x86_64, dwarf_r12_x86_64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, lldb_r12_x86_64},
+ {dwarf_r12_x86_64, dwarf_r12_x86_64, LLDB_INVALID_REGNUM,
+ LLDB_INVALID_REGNUM, lldb_r12_x86_64},
nullptr,
nullptr},
{DEFINE_GPR(r13, nullptr),
- {dwarf_r13_x86_64, dwarf_r13_x86_64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, lldb_r13_x86_64},
+ {dwarf_r13_x86_64, dwarf_r13_x86_64, LLDB_INVALID_REGNUM,
+ LLDB_INVALID_REGNUM, lldb_r13_x86_64},
nullptr,
nullptr},
{DEFINE_GPR(r14, nullptr),
- {dwarf_r14_x86_64, dwarf_r14_x86_64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, lldb_r14_x86_64},
+ {dwarf_r14_x86_64, dwarf_r14_x86_64, LLDB_INVALID_REGNUM,
+ LLDB_INVALID_REGNUM, lldb_r14_x86_64},
nullptr,
nullptr},
{DEFINE_GPR(r15, nullptr),
- {dwarf_r15_x86_64, dwarf_r15_x86_64, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, lldb_r15_x86_64},
+ {dwarf_r15_x86_64, dwarf_r15_x86_64, LLDB_INVALID_REGNUM,
+ LLDB_INVALID_REGNUM, lldb_r15_x86_64},
nullptr,
nullptr},
{DEFINE_GPR(rbp, "fp"),
- {dwarf_rbp_x86_64, dwarf_rbp_x86_64, LLDB_REGNUM_GENERIC_FP, LLDB_INVALID_REGNUM, lldb_rbp_x86_64},
+ {dwarf_rbp_x86_64, dwarf_rbp_x86_64, LLDB_REGNUM_GENERIC_FP,
+ LLDB_INVALID_REGNUM, lldb_rbp_x86_64},
nullptr,
nullptr},
{DEFINE_GPR(rsp, "sp"),
- {dwarf_rsp_x86_64, dwarf_rsp_x86_64, LLDB_REGNUM_GENERIC_SP, LLDB_INVALID_REGNUM, lldb_rsp_x86_64},
+ {dwarf_rsp_x86_64, dwarf_rsp_x86_64, LLDB_REGNUM_GENERIC_SP,
+ LLDB_INVALID_REGNUM, lldb_rsp_x86_64},
nullptr,
nullptr},
{DEFINE_GPR(rip, "pc"),
- {dwarf_rip_x86_64, dwarf_rip_x86_64, LLDB_REGNUM_GENERIC_PC, LLDB_INVALID_REGNUM, lldb_rip_x86_64},
+ {dwarf_rip_x86_64, dwarf_rip_x86_64, LLDB_REGNUM_GENERIC_PC,
+ LLDB_INVALID_REGNUM, lldb_rip_x86_64},
nullptr,
nullptr},
{DEFINE_GPR_BIN(eflags, "flags"),
- {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_REGNUM_GENERIC_FLAGS, LLDB_INVALID_REGNUM, lldb_rflags_x86_64},
+ {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_REGNUM_GENERIC_FLAGS,
+ LLDB_INVALID_REGNUM, lldb_rflags_x86_64},
nullptr,
nullptr},
};
static size_t k_num_register_infos = llvm::array_lengthof(g_register_infos);
-// Array of lldb register numbers used to define the set of all General Purpose Registers
-uint32_t g_gpr_reg_indices[] = {eRegisterIndexRax, eRegisterIndexRbx, eRegisterIndexRcx, eRegisterIndexRdx,
- eRegisterIndexRdi, eRegisterIndexRsi, eRegisterIndexR8, eRegisterIndexR9,
- eRegisterIndexR10, eRegisterIndexR11, eRegisterIndexR12, eRegisterIndexR13,
- eRegisterIndexR14, eRegisterIndexR15, eRegisterIndexRbp, eRegisterIndexRsp,
- eRegisterIndexRip, eRegisterIndexRflags};
+// Array of lldb register numbers used to define the set of all General Purpose
+// Registers
+uint32_t g_gpr_reg_indices[] = {
+ eRegisterIndexRax, eRegisterIndexRbx, eRegisterIndexRcx,
+ eRegisterIndexRdx, eRegisterIndexRdi, eRegisterIndexRsi,
+ eRegisterIndexR8, eRegisterIndexR9, eRegisterIndexR10,
+ eRegisterIndexR11, eRegisterIndexR12, eRegisterIndexR13,
+ eRegisterIndexR14, eRegisterIndexR15, eRegisterIndexRbp,
+ eRegisterIndexRsp, eRegisterIndexRip, eRegisterIndexRflags};
RegisterSet g_register_sets[] = {
- {"General Purpose Registers", "gpr", llvm::array_lengthof(g_gpr_reg_indices), g_gpr_reg_indices},
+ {"General Purpose Registers", "gpr",
+ llvm::array_lengthof(g_gpr_reg_indices), g_gpr_reg_indices},
};
}
//------------------------------------------------------------------
// Constructors and Destructors
//------------------------------------------------------------------
-RegisterContextWindows_x64::RegisterContextWindows_x64(Thread &thread, uint32_t concrete_frame_idx)
- : RegisterContextWindows(thread, concrete_frame_idx)
-{
-}
+RegisterContextWindows_x64::RegisterContextWindows_x64(
+ Thread &thread, uint32_t concrete_frame_idx)
+ : RegisterContextWindows(thread, concrete_frame_idx) {}
-RegisterContextWindows_x64::~RegisterContextWindows_x64()
-{
-}
+RegisterContextWindows_x64::~RegisterContextWindows_x64() {}
-size_t
-RegisterContextWindows_x64::GetRegisterCount()
-{
- return llvm::array_lengthof(g_register_infos);
+size_t RegisterContextWindows_x64::GetRegisterCount() {
+ return llvm::array_lengthof(g_register_infos);
}
const RegisterInfo *
-RegisterContextWindows_x64::GetRegisterInfoAtIndex(size_t reg)
-{
- if (reg < k_num_register_infos)
- return &g_register_infos[reg];
- return NULL;
+RegisterContextWindows_x64::GetRegisterInfoAtIndex(size_t reg) {
+ if (reg < k_num_register_infos)
+ return &g_register_infos[reg];
+ return NULL;
}
-size_t
-RegisterContextWindows_x64::GetRegisterSetCount()
-{
- return llvm::array_lengthof(g_register_sets);
+size_t RegisterContextWindows_x64::GetRegisterSetCount() {
+ return llvm::array_lengthof(g_register_sets);
}
-const RegisterSet *
-RegisterContextWindows_x64::GetRegisterSet(size_t reg_set)
-{
- return &g_register_sets[reg_set];
+const RegisterSet *RegisterContextWindows_x64::GetRegisterSet(size_t reg_set) {
+ return &g_register_sets[reg_set];
}
-bool
-RegisterContextWindows_x64::ReadRegister(const RegisterInfo *reg_info, RegisterValue ®_value)
-{
- if (!CacheAllRegisterValues())
- return false;
-
- switch (reg_info->kinds[eRegisterKindLLDB])
- {
- case lldb_rax_x86_64:
- reg_value.SetUInt64(m_context.Rax);
- break;
- case lldb_rbx_x86_64:
- reg_value.SetUInt64(m_context.Rbx);
- break;
- case lldb_rcx_x86_64:
- reg_value.SetUInt64(m_context.Rcx);
- break;
- case lldb_rdx_x86_64:
- reg_value.SetUInt64(m_context.Rdx);
- break;
- case lldb_rdi_x86_64:
- reg_value.SetUInt64(m_context.Rdi);
- break;
- case lldb_rsi_x86_64:
- reg_value.SetUInt64(m_context.Rsi);
- break;
- case lldb_r8_x86_64:
- reg_value.SetUInt64(m_context.R8);
- break;
- case lldb_r9_x86_64:
- reg_value.SetUInt64(m_context.R9);
- break;
- case lldb_r10_x86_64:
- reg_value.SetUInt64(m_context.R10);
- break;
- case lldb_r11_x86_64:
- reg_value.SetUInt64(m_context.R11);
- break;
- case lldb_r12_x86_64:
- reg_value.SetUInt64(m_context.R12);
- break;
- case lldb_r13_x86_64:
- reg_value.SetUInt64(m_context.R13);
- break;
- case lldb_r14_x86_64:
- reg_value.SetUInt64(m_context.R14);
- break;
- case lldb_r15_x86_64:
- reg_value.SetUInt64(m_context.R15);
- break;
- case lldb_rbp_x86_64:
- reg_value.SetUInt64(m_context.Rbp);
- break;
- case lldb_rsp_x86_64:
- reg_value.SetUInt64(m_context.Rsp);
- break;
- case lldb_rip_x86_64:
- reg_value.SetUInt64(m_context.Rip);
- break;
- case lldb_rflags_x86_64:
- reg_value.SetUInt64(m_context.EFlags);
- break;
- }
- return true;
+bool RegisterContextWindows_x64::ReadRegister(const RegisterInfo *reg_info,
+ RegisterValue ®_value) {
+ if (!CacheAllRegisterValues())
+ return false;
+
+ switch (reg_info->kinds[eRegisterKindLLDB]) {
+ case lldb_rax_x86_64:
+ reg_value.SetUInt64(m_context.Rax);
+ break;
+ case lldb_rbx_x86_64:
+ reg_value.SetUInt64(m_context.Rbx);
+ break;
+ case lldb_rcx_x86_64:
+ reg_value.SetUInt64(m_context.Rcx);
+ break;
+ case lldb_rdx_x86_64:
+ reg_value.SetUInt64(m_context.Rdx);
+ break;
+ case lldb_rdi_x86_64:
+ reg_value.SetUInt64(m_context.Rdi);
+ break;
+ case lldb_rsi_x86_64:
+ reg_value.SetUInt64(m_context.Rsi);
+ break;
+ case lldb_r8_x86_64:
+ reg_value.SetUInt64(m_context.R8);
+ break;
+ case lldb_r9_x86_64:
+ reg_value.SetUInt64(m_context.R9);
+ break;
+ case lldb_r10_x86_64:
+ reg_value.SetUInt64(m_context.R10);
+ break;
+ case lldb_r11_x86_64:
+ reg_value.SetUInt64(m_context.R11);
+ break;
+ case lldb_r12_x86_64:
+ reg_value.SetUInt64(m_context.R12);
+ break;
+ case lldb_r13_x86_64:
+ reg_value.SetUInt64(m_context.R13);
+ break;
+ case lldb_r14_x86_64:
+ reg_value.SetUInt64(m_context.R14);
+ break;
+ case lldb_r15_x86_64:
+ reg_value.SetUInt64(m_context.R15);
+ break;
+ case lldb_rbp_x86_64:
+ reg_value.SetUInt64(m_context.Rbp);
+ break;
+ case lldb_rsp_x86_64:
+ reg_value.SetUInt64(m_context.Rsp);
+ break;
+ case lldb_rip_x86_64:
+ reg_value.SetUInt64(m_context.Rip);
+ break;
+ case lldb_rflags_x86_64:
+ reg_value.SetUInt64(m_context.EFlags);
+ break;
+ }
+ return true;
}
-bool
-RegisterContextWindows_x64::WriteRegister(const RegisterInfo *reg_info, const RegisterValue ®_value)
-{
- // Since we cannot only write a single register value to the inferior, we need to make sure
- // our cached copy of the register values are fresh. Otherwise when writing EAX, for example,
- // we may also overwrite some other register with a stale value.
- if (!CacheAllRegisterValues())
- return false;
-
- switch (reg_info->kinds[eRegisterKindLLDB])
- {
- case lldb_rax_x86_64:
- m_context.Rax = reg_value.GetAsUInt64();
- break;
- case lldb_rbx_x86_64:
- m_context.Rbx = reg_value.GetAsUInt64();
- break;
- case lldb_rcx_x86_64:
- m_context.Rcx = reg_value.GetAsUInt64();
- break;
- case lldb_rdx_x86_64:
- m_context.Rdx = reg_value.GetAsUInt64();
- break;
- case lldb_rdi_x86_64:
- m_context.Rdi = reg_value.GetAsUInt64();
- break;
- case lldb_rsi_x86_64:
- m_context.Rsi = reg_value.GetAsUInt64();
- break;
- case lldb_r8_x86_64:
- m_context.R8 = reg_value.GetAsUInt64();
- break;
- case lldb_r9_x86_64:
- m_context.R9 = reg_value.GetAsUInt64();
- break;
- case lldb_r10_x86_64:
- m_context.R10 = reg_value.GetAsUInt64();
- break;
- case lldb_r11_x86_64:
- m_context.R11 = reg_value.GetAsUInt64();
- break;
- case lldb_r12_x86_64:
- m_context.R12 = reg_value.GetAsUInt64();
- break;
- case lldb_r13_x86_64:
- m_context.R13 = reg_value.GetAsUInt64();
- break;
- case lldb_r14_x86_64:
- m_context.R14 = reg_value.GetAsUInt64();
- break;
- case lldb_r15_x86_64:
- m_context.R15 = reg_value.GetAsUInt64();
- break;
- case lldb_rbp_x86_64:
- m_context.Rbp = reg_value.GetAsUInt64();
- break;
- case lldb_rsp_x86_64:
- m_context.Rsp = reg_value.GetAsUInt64();
- break;
- case lldb_rip_x86_64:
- m_context.Rip = reg_value.GetAsUInt64();
- break;
- case lldb_rflags_x86_64:
- m_context.EFlags = reg_value.GetAsUInt64();
- break;
- }
-
- // Physically update the registers in the target process.
- TargetThreadWindows &wthread = static_cast<TargetThreadWindows &>(m_thread);
- return ::SetThreadContext(wthread.GetHostThread().GetNativeThread().GetSystemHandle(), &m_context);
+bool RegisterContextWindows_x64::WriteRegister(const RegisterInfo *reg_info,
+ const RegisterValue ®_value) {
+ // Since we cannot only write a single register value to the inferior, we need
+ // to make sure
+ // our cached copy of the register values are fresh. Otherwise when writing
+ // EAX, for example,
+ // we may also overwrite some other register with a stale value.
+ if (!CacheAllRegisterValues())
+ return false;
+
+ switch (reg_info->kinds[eRegisterKindLLDB]) {
+ case lldb_rax_x86_64:
+ m_context.Rax = reg_value.GetAsUInt64();
+ break;
+ case lldb_rbx_x86_64:
+ m_context.Rbx = reg_value.GetAsUInt64();
+ break;
+ case lldb_rcx_x86_64:
+ m_context.Rcx = reg_value.GetAsUInt64();
+ break;
+ case lldb_rdx_x86_64:
+ m_context.Rdx = reg_value.GetAsUInt64();
+ break;
+ case lldb_rdi_x86_64:
+ m_context.Rdi = reg_value.GetAsUInt64();
+ break;
+ case lldb_rsi_x86_64:
+ m_context.Rsi = reg_value.GetAsUInt64();
+ break;
+ case lldb_r8_x86_64:
+ m_context.R8 = reg_value.GetAsUInt64();
+ break;
+ case lldb_r9_x86_64:
+ m_context.R9 = reg_value.GetAsUInt64();
+ break;
+ case lldb_r10_x86_64:
+ m_context.R10 = reg_value.GetAsUInt64();
+ break;
+ case lldb_r11_x86_64:
+ m_context.R11 = reg_value.GetAsUInt64();
+ break;
+ case lldb_r12_x86_64:
+ m_context.R12 = reg_value.GetAsUInt64();
+ break;
+ case lldb_r13_x86_64:
+ m_context.R13 = reg_value.GetAsUInt64();
+ break;
+ case lldb_r14_x86_64:
+ m_context.R14 = reg_value.GetAsUInt64();
+ break;
+ case lldb_r15_x86_64:
+ m_context.R15 = reg_value.GetAsUInt64();
+ break;
+ case lldb_rbp_x86_64:
+ m_context.Rbp = reg_value.GetAsUInt64();
+ break;
+ case lldb_rsp_x86_64:
+ m_context.Rsp = reg_value.GetAsUInt64();
+ break;
+ case lldb_rip_x86_64:
+ m_context.Rip = reg_value.GetAsUInt64();
+ break;
+ case lldb_rflags_x86_64:
+ m_context.EFlags = reg_value.GetAsUInt64();
+ break;
+ }
+
+ // Physically update the registers in the target process.
+ TargetThreadWindows &wthread = static_cast<TargetThreadWindows &>(m_thread);
+ return ::SetThreadContext(
+ wthread.GetHostThread().GetNativeThread().GetSystemHandle(), &m_context);
}
Modified: lldb/trunk/source/Plugins/Process/Windows/Common/x64/RegisterContextWindows_x64.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Windows/Common/x64/RegisterContextWindows_x64.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/Windows/Common/x64/RegisterContextWindows_x64.h (original)
+++ lldb/trunk/source/Plugins/Process/Windows/Common/x64/RegisterContextWindows_x64.h Tue Sep 6 15:57:50 2016
@@ -10,38 +10,38 @@
#ifndef liblldb_RegisterContextWindows_x64_H_
#define liblldb_RegisterContextWindows_x64_H_
-#include "lldb/lldb-forward.h"
#include "RegisterContextWindows.h"
+#include "lldb/lldb-forward.h"
-namespace lldb_private
-{
+namespace lldb_private {
class Thread;
-class RegisterContextWindows_x64 : public RegisterContextWindows
-{
- public:
- //------------------------------------------------------------------
- // Constructors and Destructors
- //------------------------------------------------------------------
- RegisterContextWindows_x64(Thread &thread, uint32_t concrete_frame_idx);
+class RegisterContextWindows_x64 : public RegisterContextWindows {
+public:
+ //------------------------------------------------------------------
+ // Constructors and Destructors
+ //------------------------------------------------------------------
+ RegisterContextWindows_x64(Thread &thread, uint32_t concrete_frame_idx);
- virtual ~RegisterContextWindows_x64();
+ virtual ~RegisterContextWindows_x64();
- //------------------------------------------------------------------
- // Subclasses must override these functions
- //------------------------------------------------------------------
- size_t GetRegisterCount() override;
+ //------------------------------------------------------------------
+ // Subclasses must override these functions
+ //------------------------------------------------------------------
+ size_t GetRegisterCount() override;
- const RegisterInfo *GetRegisterInfoAtIndex(size_t reg) override;
+ const RegisterInfo *GetRegisterInfoAtIndex(size_t reg) override;
- size_t GetRegisterSetCount() override;
+ size_t GetRegisterSetCount() override;
- const RegisterSet *GetRegisterSet(size_t reg_set) override;
+ const RegisterSet *GetRegisterSet(size_t reg_set) override;
- bool ReadRegister(const RegisterInfo *reg_info, RegisterValue ®_value) override;
+ bool ReadRegister(const RegisterInfo *reg_info,
+ RegisterValue ®_value) override;
- bool WriteRegister(const RegisterInfo *reg_info, const RegisterValue ®_value) override;
+ bool WriteRegister(const RegisterInfo *reg_info,
+ const RegisterValue ®_value) override;
};
}
Modified: lldb/trunk/source/Plugins/Process/Windows/Common/x86/RegisterContextWindows_x86.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Windows/Common/x86/RegisterContextWindows_x86.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/Windows/Common/x86/RegisterContextWindows_x86.cpp (original)
+++ lldb/trunk/source/Plugins/Process/Windows/Common/x86/RegisterContextWindows_x86.cpp Tue Sep 6 15:57:50 2016
@@ -7,16 +7,16 @@
//
//===----------------------------------------------------------------------===//
-#include "lldb/lldb-private-types.h"
#include "lldb/Core/Error.h"
#include "lldb/Core/RegisterValue.h"
#include "lldb/Host/windows/HostThreadWindows.h"
#include "lldb/Host/windows/windows.h"
+#include "lldb/lldb-private-types.h"
-#include "lldb-x86-register-enums.h"
#include "ProcessWindowsLog.h"
-#include "RegisterContext_x86.h"
#include "RegisterContextWindows_x86.h"
+#include "RegisterContext_x86.h"
+#include "lldb-x86-register-enums.h"
#include "llvm/ADT/STLExtras.h"
@@ -26,150 +26,178 @@ using namespace lldb_private;
#define DEFINE_GPR(reg, alt) #reg, alt, 4, 0, eEncodingUint, eFormatHexUppercase
#define DEFINE_GPR_BIN(reg, alt) #reg, alt, 4, 0, eEncodingUint, eFormatBinary
-namespace
-{
+namespace {
-// This enum defines the layout of the global RegisterInfo array. This is necessary because
-// lldb register sets are defined in terms of indices into the register array. As such, the
-// order of RegisterInfos defined in global registers array must match the order defined here.
-// When defining the register set layouts, these values can appear in an arbitrary order, and that
+// This enum defines the layout of the global RegisterInfo array. This is
+// necessary because
+// lldb register sets are defined in terms of indices into the register array.
+// As such, the
+// order of RegisterInfos defined in global registers array must match the order
+// defined here.
+// When defining the register set layouts, these values can appear in an
+// arbitrary order, and that
// determines the order that register values are displayed in a dump.
-enum RegisterIndex
-{
- eRegisterIndexEax,
- eRegisterIndexEbx,
- eRegisterIndexEcx,
- eRegisterIndexEdx,
- eRegisterIndexEdi,
- eRegisterIndexEsi,
- eRegisterIndexEbp,
- eRegisterIndexEsp,
- eRegisterIndexEip,
- eRegisterIndexEflags
+enum RegisterIndex {
+ eRegisterIndexEax,
+ eRegisterIndexEbx,
+ eRegisterIndexEcx,
+ eRegisterIndexEdx,
+ eRegisterIndexEdi,
+ eRegisterIndexEsi,
+ eRegisterIndexEbp,
+ eRegisterIndexEsp,
+ eRegisterIndexEip,
+ eRegisterIndexEflags
};
// Array of all register information supported by Windows x86
-RegisterInfo g_register_infos[] =
-{
-// Macro auto defines most stuff eh_frame DWARF GENERIC GDB LLDB VALUE REGS INVALIDATE REGS
-// ============================== ======================= =================== ========================= =================== ================= ========== ===============
- { DEFINE_GPR(eax, nullptr), { ehframe_eax_i386, dwarf_eax_i386, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, lldb_eax_i386 }, nullptr, nullptr},
- { DEFINE_GPR(ebx, nullptr), { ehframe_ebx_i386, dwarf_ebx_i386, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, lldb_ebx_i386 }, nullptr, nullptr},
- { DEFINE_GPR(ecx, nullptr), { ehframe_ecx_i386, dwarf_ecx_i386, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, lldb_ecx_i386 }, nullptr, nullptr},
- { DEFINE_GPR(edx, nullptr), { ehframe_edx_i386, dwarf_edx_i386, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, lldb_edx_i386 }, nullptr, nullptr},
- { DEFINE_GPR(edi, nullptr), { ehframe_edi_i386, dwarf_edi_i386, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, lldb_edi_i386 }, nullptr, nullptr},
- { DEFINE_GPR(esi, nullptr), { ehframe_esi_i386, dwarf_esi_i386, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, lldb_esi_i386 }, nullptr, nullptr},
- { DEFINE_GPR(ebp, "fp"), { ehframe_ebp_i386, dwarf_ebp_i386, LLDB_REGNUM_GENERIC_FP, LLDB_INVALID_REGNUM, lldb_ebp_i386 }, nullptr, nullptr},
- { DEFINE_GPR(esp, "sp"), { ehframe_esp_i386, dwarf_esp_i386, LLDB_REGNUM_GENERIC_SP, LLDB_INVALID_REGNUM, lldb_esp_i386 }, nullptr, nullptr},
- { DEFINE_GPR(eip, "pc"), { ehframe_eip_i386, dwarf_eip_i386, LLDB_REGNUM_GENERIC_PC, LLDB_INVALID_REGNUM, lldb_eip_i386 }, nullptr, nullptr},
- { DEFINE_GPR_BIN(eflags, "flags"), { ehframe_eflags_i386, dwarf_eflags_i386, LLDB_REGNUM_GENERIC_FLAGS, LLDB_INVALID_REGNUM, lldb_eflags_i386}, nullptr, nullptr},
+RegisterInfo g_register_infos[] = {
+ // Macro auto defines most stuff eh_frame DWARF
+ // GENERIC GDB LLDB
+ // VALUE REGS INVALIDATE REGS
+ // ============================== =======================
+ // =================== ========================= ===================
+ // ================= ========== ===============
+ {DEFINE_GPR(eax, nullptr),
+ {ehframe_eax_i386, dwarf_eax_i386, LLDB_INVALID_REGNUM,
+ LLDB_INVALID_REGNUM, lldb_eax_i386},
+ nullptr,
+ nullptr},
+ {DEFINE_GPR(ebx, nullptr),
+ {ehframe_ebx_i386, dwarf_ebx_i386, LLDB_INVALID_REGNUM,
+ LLDB_INVALID_REGNUM, lldb_ebx_i386},
+ nullptr,
+ nullptr},
+ {DEFINE_GPR(ecx, nullptr),
+ {ehframe_ecx_i386, dwarf_ecx_i386, LLDB_INVALID_REGNUM,
+ LLDB_INVALID_REGNUM, lldb_ecx_i386},
+ nullptr,
+ nullptr},
+ {DEFINE_GPR(edx, nullptr),
+ {ehframe_edx_i386, dwarf_edx_i386, LLDB_INVALID_REGNUM,
+ LLDB_INVALID_REGNUM, lldb_edx_i386},
+ nullptr,
+ nullptr},
+ {DEFINE_GPR(edi, nullptr),
+ {ehframe_edi_i386, dwarf_edi_i386, LLDB_INVALID_REGNUM,
+ LLDB_INVALID_REGNUM, lldb_edi_i386},
+ nullptr,
+ nullptr},
+ {DEFINE_GPR(esi, nullptr),
+ {ehframe_esi_i386, dwarf_esi_i386, LLDB_INVALID_REGNUM,
+ LLDB_INVALID_REGNUM, lldb_esi_i386},
+ nullptr,
+ nullptr},
+ {DEFINE_GPR(ebp, "fp"),
+ {ehframe_ebp_i386, dwarf_ebp_i386, LLDB_REGNUM_GENERIC_FP,
+ LLDB_INVALID_REGNUM, lldb_ebp_i386},
+ nullptr,
+ nullptr},
+ {DEFINE_GPR(esp, "sp"),
+ {ehframe_esp_i386, dwarf_esp_i386, LLDB_REGNUM_GENERIC_SP,
+ LLDB_INVALID_REGNUM, lldb_esp_i386},
+ nullptr,
+ nullptr},
+ {DEFINE_GPR(eip, "pc"),
+ {ehframe_eip_i386, dwarf_eip_i386, LLDB_REGNUM_GENERIC_PC,
+ LLDB_INVALID_REGNUM, lldb_eip_i386},
+ nullptr,
+ nullptr},
+ {DEFINE_GPR_BIN(eflags, "flags"),
+ {ehframe_eflags_i386, dwarf_eflags_i386, LLDB_REGNUM_GENERIC_FLAGS,
+ LLDB_INVALID_REGNUM, lldb_eflags_i386},
+ nullptr,
+ nullptr},
};
static size_t k_num_register_infos = llvm::array_lengthof(g_register_infos);
-// Array of lldb register numbers used to define the set of all General Purpose Registers
-uint32_t g_gpr_reg_indices[] =
-{
- eRegisterIndexEax,
- eRegisterIndexEbx,
- eRegisterIndexEcx,
- eRegisterIndexEdx,
- eRegisterIndexEdi,
- eRegisterIndexEsi,
- eRegisterIndexEbp,
- eRegisterIndexEsp,
- eRegisterIndexEip,
- eRegisterIndexEflags
-};
+// Array of lldb register numbers used to define the set of all General Purpose
+// Registers
+uint32_t g_gpr_reg_indices[] = {eRegisterIndexEax, eRegisterIndexEbx,
+ eRegisterIndexEcx, eRegisterIndexEdx,
+ eRegisterIndexEdi, eRegisterIndexEsi,
+ eRegisterIndexEbp, eRegisterIndexEsp,
+ eRegisterIndexEip, eRegisterIndexEflags};
RegisterSet g_register_sets[] = {
- {"General Purpose Registers", "gpr", llvm::array_lengthof(g_gpr_reg_indices), g_gpr_reg_indices},
+ {"General Purpose Registers", "gpr",
+ llvm::array_lengthof(g_gpr_reg_indices), g_gpr_reg_indices},
};
}
//------------------------------------------------------------------
// Constructors and Destructors
//------------------------------------------------------------------
-RegisterContextWindows_x86::RegisterContextWindows_x86(Thread &thread, uint32_t concrete_frame_idx)
- : RegisterContextWindows(thread, concrete_frame_idx)
-{
+RegisterContextWindows_x86::RegisterContextWindows_x86(
+ Thread &thread, uint32_t concrete_frame_idx)
+ : RegisterContextWindows(thread, concrete_frame_idx) {}
+
+RegisterContextWindows_x86::~RegisterContextWindows_x86() {}
+
+size_t RegisterContextWindows_x86::GetRegisterCount() {
+ return llvm::array_lengthof(g_register_infos);
}
-RegisterContextWindows_x86::~RegisterContextWindows_x86()
-{
+const RegisterInfo *
+RegisterContextWindows_x86::GetRegisterInfoAtIndex(size_t reg) {
+ if (reg < k_num_register_infos)
+ return &g_register_infos[reg];
+ return NULL;
}
-size_t
-RegisterContextWindows_x86::GetRegisterCount()
-{
- return llvm::array_lengthof(g_register_infos);
+size_t RegisterContextWindows_x86::GetRegisterSetCount() {
+ return llvm::array_lengthof(g_register_sets);
}
-const RegisterInfo *
-RegisterContextWindows_x86::GetRegisterInfoAtIndex(size_t reg)
-{
- if (reg < k_num_register_infos)
- return &g_register_infos[reg];
- return NULL;
-}
-
-size_t
-RegisterContextWindows_x86::GetRegisterSetCount()
-{
- return llvm::array_lengthof(g_register_sets);
-}
-
-const RegisterSet *
-RegisterContextWindows_x86::GetRegisterSet(size_t reg_set)
-{
- return &g_register_sets[reg_set];
-}
-
-bool
-RegisterContextWindows_x86::ReadRegister(const RegisterInfo *reg_info, RegisterValue ®_value)
-{
- if (!CacheAllRegisterValues())
- return false;
-
- uint32_t reg = reg_info->kinds[eRegisterKindLLDB];
- switch (reg)
- {
- case lldb_eax_i386:
- return ReadRegisterHelper(CONTEXT_INTEGER, "EAX", m_context.Eax, reg_value);
- case lldb_ebx_i386:
- return ReadRegisterHelper(CONTEXT_INTEGER, "EBX", m_context.Ebx, reg_value);
- case lldb_ecx_i386:
- return ReadRegisterHelper(CONTEXT_INTEGER, "ECX", m_context.Ecx, reg_value);
- case lldb_edx_i386:
- return ReadRegisterHelper(CONTEXT_INTEGER, "EDX", m_context.Edx, reg_value);
- case lldb_edi_i386:
- return ReadRegisterHelper(CONTEXT_INTEGER, "EDI", m_context.Edi, reg_value);
- case lldb_esi_i386:
- return ReadRegisterHelper(CONTEXT_INTEGER, "ESI", m_context.Esi, reg_value);
- case lldb_ebp_i386:
- return ReadRegisterHelper(CONTEXT_CONTROL, "EBP", m_context.Ebp, reg_value);
- case lldb_esp_i386:
- return ReadRegisterHelper(CONTEXT_CONTROL, "ESP", m_context.Esp, reg_value);
- case lldb_eip_i386:
- return ReadRegisterHelper(CONTEXT_CONTROL, "EIP", m_context.Eip, reg_value);
- case lldb_eflags_i386:
- return ReadRegisterHelper(CONTEXT_CONTROL, "EFLAGS", m_context.EFlags, reg_value);
- default:
- WINWARN_IFALL(WINDOWS_LOG_REGISTERS, "Requested unknown register %u", reg);
- break;
- }
- return false;
+const RegisterSet *RegisterContextWindows_x86::GetRegisterSet(size_t reg_set) {
+ return &g_register_sets[reg_set];
}
-bool
-RegisterContextWindows_x86::ReadRegisterHelper(DWORD flags_required, const char *reg_name, DWORD value,
- RegisterValue ®_value) const
-{
- if ((m_context.ContextFlags & flags_required) != flags_required)
- {
- WINLOG_IFALL(WINDOWS_LOG_REGISTERS, "Thread context doesn't have %s", reg_name);
- return false;
- }
- WINLOG_IFALL(WINDOWS_LOG_REGISTERS, "Read value 0x%x from %s", value, reg_name);
- reg_value.SetUInt32(value);
- return true;
+bool RegisterContextWindows_x86::ReadRegister(const RegisterInfo *reg_info,
+ RegisterValue ®_value) {
+ if (!CacheAllRegisterValues())
+ return false;
+
+ uint32_t reg = reg_info->kinds[eRegisterKindLLDB];
+ switch (reg) {
+ case lldb_eax_i386:
+ return ReadRegisterHelper(CONTEXT_INTEGER, "EAX", m_context.Eax, reg_value);
+ case lldb_ebx_i386:
+ return ReadRegisterHelper(CONTEXT_INTEGER, "EBX", m_context.Ebx, reg_value);
+ case lldb_ecx_i386:
+ return ReadRegisterHelper(CONTEXT_INTEGER, "ECX", m_context.Ecx, reg_value);
+ case lldb_edx_i386:
+ return ReadRegisterHelper(CONTEXT_INTEGER, "EDX", m_context.Edx, reg_value);
+ case lldb_edi_i386:
+ return ReadRegisterHelper(CONTEXT_INTEGER, "EDI", m_context.Edi, reg_value);
+ case lldb_esi_i386:
+ return ReadRegisterHelper(CONTEXT_INTEGER, "ESI", m_context.Esi, reg_value);
+ case lldb_ebp_i386:
+ return ReadRegisterHelper(CONTEXT_CONTROL, "EBP", m_context.Ebp, reg_value);
+ case lldb_esp_i386:
+ return ReadRegisterHelper(CONTEXT_CONTROL, "ESP", m_context.Esp, reg_value);
+ case lldb_eip_i386:
+ return ReadRegisterHelper(CONTEXT_CONTROL, "EIP", m_context.Eip, reg_value);
+ case lldb_eflags_i386:
+ return ReadRegisterHelper(CONTEXT_CONTROL, "EFLAGS", m_context.EFlags,
+ reg_value);
+ default:
+ WINWARN_IFALL(WINDOWS_LOG_REGISTERS, "Requested unknown register %u", reg);
+ break;
+ }
+ return false;
+}
+
+bool RegisterContextWindows_x86::ReadRegisterHelper(
+ DWORD flags_required, const char *reg_name, DWORD value,
+ RegisterValue ®_value) const {
+ if ((m_context.ContextFlags & flags_required) != flags_required) {
+ WINLOG_IFALL(WINDOWS_LOG_REGISTERS, "Thread context doesn't have %s",
+ reg_name);
+ return false;
+ }
+ WINLOG_IFALL(WINDOWS_LOG_REGISTERS, "Read value 0x%x from %s", value,
+ reg_name);
+ reg_value.SetUInt32(value);
+ return true;
}
Modified: lldb/trunk/source/Plugins/Process/Windows/Common/x86/RegisterContextWindows_x86.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Windows/Common/x86/RegisterContextWindows_x86.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/Windows/Common/x86/RegisterContextWindows_x86.h (original)
+++ lldb/trunk/source/Plugins/Process/Windows/Common/x86/RegisterContextWindows_x86.h Tue Sep 6 15:57:50 2016
@@ -10,42 +10,40 @@
#ifndef liblldb_RegisterContextWindows_x86_H_
#define liblldb_RegisterContextWindows_x86_H_
-#include "lldb/lldb-forward.h"
#include "RegisterContextWindows.h"
+#include "lldb/lldb-forward.h"
-namespace lldb_private
-{
+namespace lldb_private {
class Thread;
-class RegisterContextWindows_x86 : public RegisterContextWindows
-{
- public:
- //------------------------------------------------------------------
- // Constructors and Destructors
- //------------------------------------------------------------------
- RegisterContextWindows_x86(Thread &thread, uint32_t concrete_frame_idx);
+class RegisterContextWindows_x86 : public RegisterContextWindows {
+public:
+ //------------------------------------------------------------------
+ // Constructors and Destructors
+ //------------------------------------------------------------------
+ RegisterContextWindows_x86(Thread &thread, uint32_t concrete_frame_idx);
- virtual ~RegisterContextWindows_x86();
+ virtual ~RegisterContextWindows_x86();
- //------------------------------------------------------------------
- // Subclasses must override these functions
- //------------------------------------------------------------------
- size_t GetRegisterCount() override;
+ //------------------------------------------------------------------
+ // Subclasses must override these functions
+ //------------------------------------------------------------------
+ size_t GetRegisterCount() override;
- const RegisterInfo *GetRegisterInfoAtIndex(size_t reg) override;
+ const RegisterInfo *GetRegisterInfoAtIndex(size_t reg) override;
- size_t GetRegisterSetCount() override;
+ size_t GetRegisterSetCount() override;
- const RegisterSet *GetRegisterSet(size_t reg_set) override;
+ const RegisterSet *GetRegisterSet(size_t reg_set) override;
- bool ReadRegister(const RegisterInfo *reg_info, RegisterValue ®_value) override;
+ bool ReadRegister(const RegisterInfo *reg_info,
+ RegisterValue ®_value) override;
private:
- bool
- ReadRegisterHelper(DWORD flags_required, const char *reg_name, DWORD value, RegisterValue ®_value) const;
+ bool ReadRegisterHelper(DWORD flags_required, const char *reg_name,
+ DWORD value, RegisterValue ®_value) const;
};
-
}
#endif // #ifndef liblldb_RegisterContextWindows_x86_H_
Modified: lldb/trunk/source/Plugins/Process/Windows/Live/DebuggerThread.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Windows/Live/DebuggerThread.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/Windows/Live/DebuggerThread.cpp (original)
+++ lldb/trunk/source/Plugins/Process/Windows/Live/DebuggerThread.cpp Tue Sep 6 15:57:50 2016
@@ -1,4 +1,5 @@
-//===-- DebuggerThread.DebuggerThread --------------------------------------*- C++ -*-===//
+//===-- DebuggerThread.DebuggerThread --------------------------------------*-
+//C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -21,8 +22,8 @@
#include "lldb/Host/windows/HostProcessWindows.h"
#include "lldb/Host/windows/HostThreadWindows.h"
#include "lldb/Host/windows/ProcessLauncherWindows.h"
-#include "lldb/Target/ProcessLaunchInfo.h"
#include "lldb/Target/Process.h"
+#include "lldb/Target/ProcessLaunchInfo.h"
#include "Plugins/Process/Windows/Common/ProcessWindowsLog.h"
@@ -33,517 +34,518 @@
using namespace lldb;
using namespace lldb_private;
-namespace
-{
-struct DebugLaunchContext
-{
- DebugLaunchContext(DebuggerThread *thread, const ProcessLaunchInfo &launch_info)
- : m_thread(thread)
- , m_launch_info(launch_info)
- {
- }
- DebuggerThread *m_thread;
- ProcessLaunchInfo m_launch_info;
+namespace {
+struct DebugLaunchContext {
+ DebugLaunchContext(DebuggerThread *thread,
+ const ProcessLaunchInfo &launch_info)
+ : m_thread(thread), m_launch_info(launch_info) {}
+ DebuggerThread *m_thread;
+ ProcessLaunchInfo m_launch_info;
};
-struct DebugAttachContext
-{
- DebugAttachContext(DebuggerThread *thread, lldb::pid_t pid, const ProcessAttachInfo &attach_info)
- : m_thread(thread)
- , m_pid(pid)
- , m_attach_info(attach_info)
- {
- }
- DebuggerThread *m_thread;
- lldb::pid_t m_pid;
- ProcessAttachInfo m_attach_info;
+struct DebugAttachContext {
+ DebugAttachContext(DebuggerThread *thread, lldb::pid_t pid,
+ const ProcessAttachInfo &attach_info)
+ : m_thread(thread), m_pid(pid), m_attach_info(attach_info) {}
+ DebuggerThread *m_thread;
+ lldb::pid_t m_pid;
+ ProcessAttachInfo m_attach_info;
};
}
DebuggerThread::DebuggerThread(DebugDelegateSP debug_delegate)
- : m_debug_delegate(debug_delegate)
- , m_image_file(nullptr)
- , m_debugging_ended_event(nullptr)
- , m_is_shutting_down(false)
- , m_pid_to_detach(0)
- , m_detached(false)
-{
- m_debugging_ended_event = ::CreateEvent(nullptr, TRUE, FALSE, nullptr);
-}
-
-DebuggerThread::~DebuggerThread()
-{
- ::CloseHandle(m_debugging_ended_event);
-}
-
-Error
-DebuggerThread::DebugLaunch(const ProcessLaunchInfo &launch_info)
-{
- WINLOG_IFALL(WINDOWS_LOG_PROCESS,
- "DebuggerThread::DebugLaunch launching '%s'", launch_info.GetExecutableFile().GetPath().c_str());
-
- Error error;
- DebugLaunchContext *context = new DebugLaunchContext(this, launch_info);
- HostThread slave_thread(ThreadLauncher::LaunchThread("lldb.plugin.process-windows.slave[?]",
- DebuggerThreadLaunchRoutine, context, &error));
-
- if (!error.Success())
- {
- WINERR_IFALL(WINDOWS_LOG_PROCESS,
- "DebugLaunch couldn't launch debugger thread. %s", error.AsCString());
- }
-
- return error;
-}
-
-Error
-DebuggerThread::DebugAttach(lldb::pid_t pid, const ProcessAttachInfo &attach_info)
-{
- WINLOG_IFALL(WINDOWS_LOG_PROCESS, "DebuggerThread::DebugAttach attaching to '%u'", (DWORD)pid);
-
- Error error;
- DebugAttachContext *context = new DebugAttachContext(this, pid, attach_info);
- HostThread slave_thread(ThreadLauncher::LaunchThread("lldb.plugin.process-windows.slave[?]",
- DebuggerThreadAttachRoutine, context, &error));
-
- if (!error.Success())
- {
- WINERR_IFALL(WINDOWS_LOG_PROCESS, "DebugAttach couldn't attach to process '%u'. %s", (DWORD)pid,
- error.AsCString());
- }
+ : m_debug_delegate(debug_delegate), m_image_file(nullptr),
+ m_debugging_ended_event(nullptr), m_is_shutting_down(false),
+ m_pid_to_detach(0), m_detached(false) {
+ m_debugging_ended_event = ::CreateEvent(nullptr, TRUE, FALSE, nullptr);
+}
+
+DebuggerThread::~DebuggerThread() { ::CloseHandle(m_debugging_ended_event); }
+
+Error DebuggerThread::DebugLaunch(const ProcessLaunchInfo &launch_info) {
+ WINLOG_IFALL(WINDOWS_LOG_PROCESS,
+ "DebuggerThread::DebugLaunch launching '%s'",
+ launch_info.GetExecutableFile().GetPath().c_str());
+
+ Error error;
+ DebugLaunchContext *context = new DebugLaunchContext(this, launch_info);
+ HostThread slave_thread(ThreadLauncher::LaunchThread(
+ "lldb.plugin.process-windows.slave[?]", DebuggerThreadLaunchRoutine,
+ context, &error));
+
+ if (!error.Success()) {
+ WINERR_IFALL(WINDOWS_LOG_PROCESS,
+ "DebugLaunch couldn't launch debugger thread. %s",
+ error.AsCString());
+ }
+
+ return error;
+}
+
+Error DebuggerThread::DebugAttach(lldb::pid_t pid,
+ const ProcessAttachInfo &attach_info) {
+ WINLOG_IFALL(WINDOWS_LOG_PROCESS,
+ "DebuggerThread::DebugAttach attaching to '%u'", (DWORD)pid);
+
+ Error error;
+ DebugAttachContext *context = new DebugAttachContext(this, pid, attach_info);
+ HostThread slave_thread(ThreadLauncher::LaunchThread(
+ "lldb.plugin.process-windows.slave[?]", DebuggerThreadAttachRoutine,
+ context, &error));
+
+ if (!error.Success()) {
+ WINERR_IFALL(WINDOWS_LOG_PROCESS,
+ "DebugAttach couldn't attach to process '%u'. %s", (DWORD)pid,
+ error.AsCString());
+ }
+
+ return error;
+}
+
+lldb::thread_result_t DebuggerThread::DebuggerThreadLaunchRoutine(void *data) {
+ DebugLaunchContext *context = static_cast<DebugLaunchContext *>(data);
+ lldb::thread_result_t result =
+ context->m_thread->DebuggerThreadLaunchRoutine(context->m_launch_info);
+ delete context;
+ return result;
+}
+
+lldb::thread_result_t DebuggerThread::DebuggerThreadAttachRoutine(void *data) {
+ DebugAttachContext *context = static_cast<DebugAttachContext *>(data);
+ lldb::thread_result_t result = context->m_thread->DebuggerThreadAttachRoutine(
+ context->m_pid, context->m_attach_info);
+ delete context;
+ return result;
+}
+
+lldb::thread_result_t DebuggerThread::DebuggerThreadLaunchRoutine(
+ const ProcessLaunchInfo &launch_info) {
+ // Grab a shared_ptr reference to this so that we know it won't get deleted
+ // until after the
+ // thread routine has exited.
+ std::shared_ptr<DebuggerThread> this_ref(shared_from_this());
+
+ WINLOG_IFALL(WINDOWS_LOG_PROCESS,
+ "DebuggerThread preparing to launch '%s' on background thread.",
+ launch_info.GetExecutableFile().GetPath().c_str());
+
+ Error error;
+ ProcessLauncherWindows launcher;
+ HostProcess process(launcher.LaunchProcess(launch_info, error));
+ // If we couldn't create the process, notify waiters immediately. Otherwise
+ // enter the debug
+ // loop and wait until we get the create process debug notification. Note
+ // that if the process
+ // was created successfully, we can throw away the process handle we got from
+ // CreateProcess
+ // because Windows will give us another (potentially more useful?) handle when
+ // it sends us the
+ // CREATE_PROCESS_DEBUG_EVENT.
+ if (error.Success())
+ DebugLoop();
+ else
+ m_debug_delegate->OnDebuggerError(error, 0);
- return error;
+ return 0;
}
-lldb::thread_result_t
-DebuggerThread::DebuggerThreadLaunchRoutine(void *data)
-{
- DebugLaunchContext *context = static_cast<DebugLaunchContext *>(data);
- lldb::thread_result_t result = context->m_thread->DebuggerThreadLaunchRoutine(context->m_launch_info);
- delete context;
- return result;
-}
-
-lldb::thread_result_t
-DebuggerThread::DebuggerThreadAttachRoutine(void *data)
-{
- DebugAttachContext *context = static_cast<DebugAttachContext *>(data);
- lldb::thread_result_t result =
- context->m_thread->DebuggerThreadAttachRoutine(context->m_pid, context->m_attach_info);
- delete context;
- return result;
-}
-
-lldb::thread_result_t
-DebuggerThread::DebuggerThreadLaunchRoutine(const ProcessLaunchInfo &launch_info)
-{
- // Grab a shared_ptr reference to this so that we know it won't get deleted until after the
- // thread routine has exited.
- std::shared_ptr<DebuggerThread> this_ref(shared_from_this());
-
- WINLOG_IFALL(WINDOWS_LOG_PROCESS, "DebuggerThread preparing to launch '%s' on background thread.",
- launch_info.GetExecutableFile().GetPath().c_str());
-
- Error error;
- ProcessLauncherWindows launcher;
- HostProcess process(launcher.LaunchProcess(launch_info, error));
- // If we couldn't create the process, notify waiters immediately. Otherwise enter the debug
- // loop and wait until we get the create process debug notification. Note that if the process
- // was created successfully, we can throw away the process handle we got from CreateProcess
- // because Windows will give us another (potentially more useful?) handle when it sends us the
- // CREATE_PROCESS_DEBUG_EVENT.
- if (error.Success())
- DebugLoop();
- else
- m_debug_delegate->OnDebuggerError(error, 0);
-
+lldb::thread_result_t DebuggerThread::DebuggerThreadAttachRoutine(
+ lldb::pid_t pid, const ProcessAttachInfo &attach_info) {
+ // Grab a shared_ptr reference to this so that we know it won't get deleted
+ // until after the
+ // thread routine has exited.
+ std::shared_ptr<DebuggerThread> this_ref(shared_from_this());
+
+ WINLOG_IFALL(WINDOWS_LOG_PROCESS, "DebuggerThread preparing to attach to "
+ "process '%u' on background thread.",
+ (DWORD)pid);
+
+ if (!DebugActiveProcess((DWORD)pid)) {
+ Error error(::GetLastError(), eErrorTypeWin32);
+ m_debug_delegate->OnDebuggerError(error, 0);
return 0;
-}
-
-lldb::thread_result_t
-DebuggerThread::DebuggerThreadAttachRoutine(lldb::pid_t pid, const ProcessAttachInfo &attach_info)
-{
- // Grab a shared_ptr reference to this so that we know it won't get deleted until after the
- // thread routine has exited.
- std::shared_ptr<DebuggerThread> this_ref(shared_from_this());
-
- WINLOG_IFALL(WINDOWS_LOG_PROCESS, "DebuggerThread preparing to attach to process '%u' on background thread.",
- (DWORD)pid);
-
- if (!DebugActiveProcess((DWORD)pid))
- {
- Error error(::GetLastError(), eErrorTypeWin32);
- m_debug_delegate->OnDebuggerError(error, 0);
- return 0;
- }
+ }
- // The attach was successful, enter the debug loop. From here on out, this is no different than
- // a create process operation, so all the same comments in DebugLaunch should apply from this
- // point out.
- DebugLoop();
+ // The attach was successful, enter the debug loop. From here on out, this is
+ // no different than
+ // a create process operation, so all the same comments in DebugLaunch should
+ // apply from this
+ // point out.
+ DebugLoop();
- return 0;
+ return 0;
}
-Error
-DebuggerThread::StopDebugging(bool terminate)
-{
- Error error;
-
- lldb::pid_t pid = m_process.GetProcessId();
-
- WINLOG_IFALL(WINDOWS_LOG_PROCESS,
- "StopDebugging('%s') called (inferior=%I64u).",
- (terminate ? "true" : "false"), pid);
-
- // Set m_is_shutting_down to true if it was false. Return if it was already true.
- bool expected = false;
- if (!m_is_shutting_down.compare_exchange_strong(expected, true))
- return error;
-
- // Make a copy of the process, since the termination sequence will reset
- // DebuggerThread's internal copy and it needs to remain open for the Wait operation.
- HostProcess process_copy = m_process;
- lldb::process_t handle = m_process.GetNativeProcess().GetSystemHandle();
-
- if (terminate)
- {
- // Initiate the termination before continuing the exception, so that the next debug
- // event we get is the exit process event, and not some other event.
- BOOL terminate_suceeded = TerminateProcess(handle, 0);
- WINLOG_IFALL(WINDOWS_LOG_PROCESS,
- "StopDebugging called TerminateProcess(0x%p, 0) (inferior=%I64u), success='%s'",
- handle, pid, (terminate_suceeded ? "true" : "false"));
- }
-
- // If we're stuck waiting for an exception to continue (e.g. the user is at a breakpoint
- // messing around in the debugger), continue it now. But only AFTER calling TerminateProcess
- // to make sure that the very next call to WaitForDebugEvent is an exit process event.
- if (m_active_exception.get())
- {
- WINLOG_IFANY(WINDOWS_LOG_PROCESS|WINDOWS_LOG_EXCEPTION,
- "StopDebugging masking active exception");
-
- ContinueAsyncException(ExceptionResult::MaskException);
- }
-
- if (!terminate)
- {
- // Indicate that we want to detach.
- m_pid_to_detach = GetProcess().GetProcessId();
-
- // Force a fresh break so that the detach can happen from the debugger thread.
- if (!::DebugBreakProcess(GetProcess().GetNativeProcess().GetSystemHandle()))
- {
- error.SetError(::GetLastError(), eErrorTypeWin32);
- }
- }
+Error DebuggerThread::StopDebugging(bool terminate) {
+ Error error;
- WINLOG_IFALL(WINDOWS_LOG_PROCESS, "StopDebugging waiting for detach from process %u to complete.", pid);
+ lldb::pid_t pid = m_process.GetProcessId();
- DWORD wait_result = WaitForSingleObject(m_debugging_ended_event, 5000);
- if (wait_result != WAIT_OBJECT_0)
- {
- error.SetError(GetLastError(), eErrorTypeWin32);
- WINERR_IFALL(WINDOWS_LOG_PROCESS, "StopDebugging WaitForSingleObject(0x%p, 5000) returned %u",
- m_debugging_ended_event, wait_result);
- }
- else
- {
- WINLOG_IFALL(WINDOWS_LOG_PROCESS, "StopDebugging detach from process %u completed successfully.", pid);
- }
+ WINLOG_IFALL(WINDOWS_LOG_PROCESS,
+ "StopDebugging('%s') called (inferior=%I64u).",
+ (terminate ? "true" : "false"), pid);
- if (!error.Success())
- {
- WINERR_IFALL(WINDOWS_LOG_PROCESS,
- "StopDebugging encountered an error while trying to stop process %u. %s",
- pid, error.AsCString());
- }
+ // Set m_is_shutting_down to true if it was false. Return if it was already
+ // true.
+ bool expected = false;
+ if (!m_is_shutting_down.compare_exchange_strong(expected, true))
return error;
-}
-void
-DebuggerThread::ContinueAsyncException(ExceptionResult result)
-{
- if (!m_active_exception.get())
- return;
-
- WINLOG_IFANY(WINDOWS_LOG_PROCESS|WINDOWS_LOG_EXCEPTION,
- "ContinueAsyncException called for inferior process %I64u, broadcasting.",
- m_process.GetProcessId());
-
- m_active_exception.reset();
- m_exception_pred.SetValue(result, eBroadcastAlways);
-}
-
-void
-DebuggerThread::FreeProcessHandles()
-{
- m_process = HostProcess();
- m_main_thread = HostThread();
- if (m_image_file)
- {
- ::CloseHandle(m_image_file);
- m_image_file = nullptr;
- }
-}
-
-void
-DebuggerThread::DebugLoop()
-{
- DEBUG_EVENT dbe = {0};
- bool should_debug = true;
- WINLOG_IFALL(WINDOWS_LOG_EVENT, "Entering WaitForDebugEvent loop");
- while (should_debug)
- {
- WINLOGD_IFALL(WINDOWS_LOG_EVENT, "Calling WaitForDebugEvent");
- BOOL wait_result = WaitForDebugEvent(&dbe, INFINITE);
- if (wait_result)
- {
- DWORD continue_status = DBG_CONTINUE;
- switch (dbe.dwDebugEventCode)
- {
- case EXCEPTION_DEBUG_EVENT:
- {
- ExceptionResult status = HandleExceptionEvent(dbe.u.Exception, dbe.dwThreadId);
-
- if (status == ExceptionResult::MaskException)
- continue_status = DBG_CONTINUE;
- else if (status == ExceptionResult::SendToApplication)
- continue_status = DBG_EXCEPTION_NOT_HANDLED;
-
- break;
- }
- case CREATE_THREAD_DEBUG_EVENT:
- continue_status = HandleCreateThreadEvent(dbe.u.CreateThread, dbe.dwThreadId);
- break;
- case CREATE_PROCESS_DEBUG_EVENT:
- continue_status = HandleCreateProcessEvent(dbe.u.CreateProcessInfo, dbe.dwThreadId);
- break;
- case EXIT_THREAD_DEBUG_EVENT:
- continue_status = HandleExitThreadEvent(dbe.u.ExitThread, dbe.dwThreadId);
- break;
- case EXIT_PROCESS_DEBUG_EVENT:
- continue_status = HandleExitProcessEvent(dbe.u.ExitProcess, dbe.dwThreadId);
- should_debug = false;
- break;
- case LOAD_DLL_DEBUG_EVENT:
- continue_status = HandleLoadDllEvent(dbe.u.LoadDll, dbe.dwThreadId);
- break;
- case UNLOAD_DLL_DEBUG_EVENT:
- continue_status = HandleUnloadDllEvent(dbe.u.UnloadDll, dbe.dwThreadId);
- break;
- case OUTPUT_DEBUG_STRING_EVENT:
- continue_status = HandleODSEvent(dbe.u.DebugString, dbe.dwThreadId);
- break;
- case RIP_EVENT:
- continue_status = HandleRipEvent(dbe.u.RipInfo, dbe.dwThreadId);
- if (dbe.u.RipInfo.dwType == SLE_ERROR)
- should_debug = false;
- break;
- }
-
- WINLOGD_IFALL(WINDOWS_LOG_EVENT, "DebugLoop calling ContinueDebugEvent(%u, %u, %u) on thread %u.",
- dbe.dwProcessId, dbe.dwThreadId, continue_status, ::GetCurrentThreadId());
-
- ::ContinueDebugEvent(dbe.dwProcessId, dbe.dwThreadId, continue_status);
-
- if (m_detached)
- {
- should_debug = false;
- }
- }
- else
- {
- WINERR_IFALL(WINDOWS_LOG_EVENT,
- "DebugLoop returned FALSE from WaitForDebugEvent. Error = %u",
- ::GetCurrentThreadId(), ::GetLastError());
+ // Make a copy of the process, since the termination sequence will reset
+ // DebuggerThread's internal copy and it needs to remain open for the Wait
+ // operation.
+ HostProcess process_copy = m_process;
+ lldb::process_t handle = m_process.GetNativeProcess().GetSystemHandle();
+
+ if (terminate) {
+ // Initiate the termination before continuing the exception, so that the
+ // next debug
+ // event we get is the exit process event, and not some other event.
+ BOOL terminate_suceeded = TerminateProcess(handle, 0);
+ WINLOG_IFALL(WINDOWS_LOG_PROCESS, "StopDebugging called "
+ "TerminateProcess(0x%p, 0) "
+ "(inferior=%I64u), success='%s'",
+ handle, pid, (terminate_suceeded ? "true" : "false"));
+ }
+
+ // If we're stuck waiting for an exception to continue (e.g. the user is at a
+ // breakpoint
+ // messing around in the debugger), continue it now. But only AFTER calling
+ // TerminateProcess
+ // to make sure that the very next call to WaitForDebugEvent is an exit
+ // process event.
+ if (m_active_exception.get()) {
+ WINLOG_IFANY(WINDOWS_LOG_PROCESS | WINDOWS_LOG_EXCEPTION,
+ "StopDebugging masking active exception");
+
+ ContinueAsyncException(ExceptionResult::MaskException);
+ }
+
+ if (!terminate) {
+ // Indicate that we want to detach.
+ m_pid_to_detach = GetProcess().GetProcessId();
+
+ // Force a fresh break so that the detach can happen from the debugger
+ // thread.
+ if (!::DebugBreakProcess(
+ GetProcess().GetNativeProcess().GetSystemHandle())) {
+ error.SetError(::GetLastError(), eErrorTypeWin32);
+ }
+ }
+
+ WINLOG_IFALL(WINDOWS_LOG_PROCESS,
+ "StopDebugging waiting for detach from process %u to complete.",
+ pid);
+
+ DWORD wait_result = WaitForSingleObject(m_debugging_ended_event, 5000);
+ if (wait_result != WAIT_OBJECT_0) {
+ error.SetError(GetLastError(), eErrorTypeWin32);
+ WINERR_IFALL(WINDOWS_LOG_PROCESS,
+ "StopDebugging WaitForSingleObject(0x%p, 5000) returned %u",
+ m_debugging_ended_event, wait_result);
+ } else {
+ WINLOG_IFALL(WINDOWS_LOG_PROCESS,
+ "StopDebugging detach from process %u completed successfully.",
+ pid);
+ }
+
+ if (!error.Success()) {
+ WINERR_IFALL(WINDOWS_LOG_PROCESS, "StopDebugging encountered an error "
+ "while trying to stop process %u. %s",
+ pid, error.AsCString());
+ }
+ return error;
+}
+
+void DebuggerThread::ContinueAsyncException(ExceptionResult result) {
+ if (!m_active_exception.get())
+ return;
+
+ WINLOG_IFANY(
+ WINDOWS_LOG_PROCESS | WINDOWS_LOG_EXCEPTION,
+ "ContinueAsyncException called for inferior process %I64u, broadcasting.",
+ m_process.GetProcessId());
+
+ m_active_exception.reset();
+ m_exception_pred.SetValue(result, eBroadcastAlways);
+}
+
+void DebuggerThread::FreeProcessHandles() {
+ m_process = HostProcess();
+ m_main_thread = HostThread();
+ if (m_image_file) {
+ ::CloseHandle(m_image_file);
+ m_image_file = nullptr;
+ }
+}
+
+void DebuggerThread::DebugLoop() {
+ DEBUG_EVENT dbe = {0};
+ bool should_debug = true;
+ WINLOG_IFALL(WINDOWS_LOG_EVENT, "Entering WaitForDebugEvent loop");
+ while (should_debug) {
+ WINLOGD_IFALL(WINDOWS_LOG_EVENT, "Calling WaitForDebugEvent");
+ BOOL wait_result = WaitForDebugEvent(&dbe, INFINITE);
+ if (wait_result) {
+ DWORD continue_status = DBG_CONTINUE;
+ switch (dbe.dwDebugEventCode) {
+ case EXCEPTION_DEBUG_EVENT: {
+ ExceptionResult status =
+ HandleExceptionEvent(dbe.u.Exception, dbe.dwThreadId);
+
+ if (status == ExceptionResult::MaskException)
+ continue_status = DBG_CONTINUE;
+ else if (status == ExceptionResult::SendToApplication)
+ continue_status = DBG_EXCEPTION_NOT_HANDLED;
+
+ break;
+ }
+ case CREATE_THREAD_DEBUG_EVENT:
+ continue_status =
+ HandleCreateThreadEvent(dbe.u.CreateThread, dbe.dwThreadId);
+ break;
+ case CREATE_PROCESS_DEBUG_EVENT:
+ continue_status =
+ HandleCreateProcessEvent(dbe.u.CreateProcessInfo, dbe.dwThreadId);
+ break;
+ case EXIT_THREAD_DEBUG_EVENT:
+ continue_status =
+ HandleExitThreadEvent(dbe.u.ExitThread, dbe.dwThreadId);
+ break;
+ case EXIT_PROCESS_DEBUG_EVENT:
+ continue_status =
+ HandleExitProcessEvent(dbe.u.ExitProcess, dbe.dwThreadId);
+ should_debug = false;
+ break;
+ case LOAD_DLL_DEBUG_EVENT:
+ continue_status = HandleLoadDllEvent(dbe.u.LoadDll, dbe.dwThreadId);
+ break;
+ case UNLOAD_DLL_DEBUG_EVENT:
+ continue_status = HandleUnloadDllEvent(dbe.u.UnloadDll, dbe.dwThreadId);
+ break;
+ case OUTPUT_DEBUG_STRING_EVENT:
+ continue_status = HandleODSEvent(dbe.u.DebugString, dbe.dwThreadId);
+ break;
+ case RIP_EVENT:
+ continue_status = HandleRipEvent(dbe.u.RipInfo, dbe.dwThreadId);
+ if (dbe.u.RipInfo.dwType == SLE_ERROR)
+ should_debug = false;
+ break;
+ }
+
+ WINLOGD_IFALL(
+ WINDOWS_LOG_EVENT,
+ "DebugLoop calling ContinueDebugEvent(%u, %u, %u) on thread %u.",
+ dbe.dwProcessId, dbe.dwThreadId, continue_status,
+ ::GetCurrentThreadId());
+
+ ::ContinueDebugEvent(dbe.dwProcessId, dbe.dwThreadId, continue_status);
+
+ if (m_detached) {
+ should_debug = false;
+ }
+ } else {
+ WINERR_IFALL(
+ WINDOWS_LOG_EVENT,
+ "DebugLoop returned FALSE from WaitForDebugEvent. Error = %u",
+ ::GetCurrentThreadId(), ::GetLastError());
- should_debug = false;
- }
+ should_debug = false;
}
- FreeProcessHandles();
+ }
+ FreeProcessHandles();
- WINLOG_IFALL(WINDOWS_LOG_EVENT, "WaitForDebugEvent loop completed, exiting.");
- SetEvent(m_debugging_ended_event);
+ WINLOG_IFALL(WINDOWS_LOG_EVENT, "WaitForDebugEvent loop completed, exiting.");
+ SetEvent(m_debugging_ended_event);
}
ExceptionResult
-DebuggerThread::HandleExceptionEvent(const EXCEPTION_DEBUG_INFO &info, DWORD thread_id)
-{
- if (m_is_shutting_down)
- {
- // A breakpoint that occurs while `m_pid_to_detach` is non-zero is a magic exception that
- // we use simply to wake up the DebuggerThread so that we can close out the debug loop.
- if (m_pid_to_detach != 0 && info.ExceptionRecord.ExceptionCode == EXCEPTION_BREAKPOINT)
- {
- WINLOG_IFANY(WINDOWS_LOG_EVENT | WINDOWS_LOG_EXCEPTION | WINDOWS_LOG_PROCESS,
- "Breakpoint exception is cue to detach from process 0x%x",
- m_pid_to_detach.load());
- ::DebugActiveProcessStop(m_pid_to_detach);
- m_detached = true;
- }
-
- // Don't perform any blocking operations while we're shutting down. That will
- // cause TerminateProcess -> WaitForSingleObject to time out.
- return ExceptionResult::SendToApplication;
- }
-
- bool first_chance = (info.dwFirstChance != 0);
-
- m_active_exception.reset(new ExceptionRecord(info.ExceptionRecord, thread_id));
- WINLOG_IFANY(WINDOWS_LOG_EVENT | WINDOWS_LOG_EXCEPTION,
- "HandleExceptionEvent encountered %s chance exception 0x%x on thread 0x%x",
- first_chance ? "first" : "second", info.ExceptionRecord.ExceptionCode, thread_id);
-
- ExceptionResult result = m_debug_delegate->OnDebugException(first_chance,
- *m_active_exception);
- m_exception_pred.SetValue(result, eBroadcastNever);
-
- WINLOG_IFANY(WINDOWS_LOG_EVENT|WINDOWS_LOG_EXCEPTION,
- "DebuggerThread::HandleExceptionEvent waiting for ExceptionPred != BreakInDebugger");
-
- m_exception_pred.WaitForValueNotEqualTo(ExceptionResult::BreakInDebugger, result);
-
- WINLOG_IFANY(WINDOWS_LOG_EVENT|WINDOWS_LOG_EXCEPTION,
- "DebuggerThread::HandleExceptionEvent got ExceptionPred = %u",
- m_exception_pred.GetValue());
+DebuggerThread::HandleExceptionEvent(const EXCEPTION_DEBUG_INFO &info,
+ DWORD thread_id) {
+ if (m_is_shutting_down) {
+ // A breakpoint that occurs while `m_pid_to_detach` is non-zero is a magic
+ // exception that
+ // we use simply to wake up the DebuggerThread so that we can close out the
+ // debug loop.
+ if (m_pid_to_detach != 0 &&
+ info.ExceptionRecord.ExceptionCode == EXCEPTION_BREAKPOINT) {
+ WINLOG_IFANY(WINDOWS_LOG_EVENT | WINDOWS_LOG_EXCEPTION |
+ WINDOWS_LOG_PROCESS,
+ "Breakpoint exception is cue to detach from process 0x%x",
+ m_pid_to_detach.load());
+ ::DebugActiveProcessStop(m_pid_to_detach);
+ m_detached = true;
+ }
+
+ // Don't perform any blocking operations while we're shutting down. That
+ // will
+ // cause TerminateProcess -> WaitForSingleObject to time out.
+ return ExceptionResult::SendToApplication;
+ }
+
+ bool first_chance = (info.dwFirstChance != 0);
+
+ m_active_exception.reset(
+ new ExceptionRecord(info.ExceptionRecord, thread_id));
+ WINLOG_IFANY(WINDOWS_LOG_EVENT | WINDOWS_LOG_EXCEPTION,
+ "HandleExceptionEvent encountered %s chance exception 0x%x on "
+ "thread 0x%x",
+ first_chance ? "first" : "second",
+ info.ExceptionRecord.ExceptionCode, thread_id);
+
+ ExceptionResult result =
+ m_debug_delegate->OnDebugException(first_chance, *m_active_exception);
+ m_exception_pred.SetValue(result, eBroadcastNever);
+
+ WINLOG_IFANY(WINDOWS_LOG_EVENT | WINDOWS_LOG_EXCEPTION,
+ "DebuggerThread::HandleExceptionEvent waiting for ExceptionPred "
+ "!= BreakInDebugger");
+
+ m_exception_pred.WaitForValueNotEqualTo(ExceptionResult::BreakInDebugger,
+ result);
+
+ WINLOG_IFANY(WINDOWS_LOG_EVENT | WINDOWS_LOG_EXCEPTION,
+ "DebuggerThread::HandleExceptionEvent got ExceptionPred = %u",
+ m_exception_pred.GetValue());
- return result;
+ return result;
}
DWORD
-DebuggerThread::HandleCreateThreadEvent(const CREATE_THREAD_DEBUG_INFO &info, DWORD thread_id)
-{
- WINLOG_IFANY(WINDOWS_LOG_EVENT|WINDOWS_LOG_THREAD,
- "HandleCreateThreadEvent Thread 0x%x spawned in process %I64u",
- thread_id, m_process.GetProcessId());
- HostThread thread(info.hThread);
- thread.GetNativeThread().SetOwnsHandle(false);
- m_debug_delegate->OnCreateThread(thread);
- return DBG_CONTINUE;
+DebuggerThread::HandleCreateThreadEvent(const CREATE_THREAD_DEBUG_INFO &info,
+ DWORD thread_id) {
+ WINLOG_IFANY(WINDOWS_LOG_EVENT | WINDOWS_LOG_THREAD,
+ "HandleCreateThreadEvent Thread 0x%x spawned in process %I64u",
+ thread_id, m_process.GetProcessId());
+ HostThread thread(info.hThread);
+ thread.GetNativeThread().SetOwnsHandle(false);
+ m_debug_delegate->OnCreateThread(thread);
+ return DBG_CONTINUE;
}
DWORD
-DebuggerThread::HandleCreateProcessEvent(const CREATE_PROCESS_DEBUG_INFO &info, DWORD thread_id)
-{
- uint32_t process_id = ::GetProcessId(info.hProcess);
-
- WINLOG_IFANY(WINDOWS_LOG_EVENT | WINDOWS_LOG_PROCESS, "HandleCreateProcessEvent process %u spawned", process_id);
-
- std::string thread_name;
- llvm::raw_string_ostream name_stream(thread_name);
- name_stream << "lldb.plugin.process-windows.slave[" << process_id << "]";
- name_stream.flush();
- ThisThread::SetName(thread_name.c_str());
-
- // info.hProcess and info.hThread are closed automatically by Windows when
- // EXIT_PROCESS_DEBUG_EVENT is received.
- m_process = HostProcess(info.hProcess);
- ((HostProcessWindows &)m_process.GetNativeProcess()).SetOwnsHandle(false);
- m_main_thread = HostThread(info.hThread);
- m_main_thread.GetNativeThread().SetOwnsHandle(false);
- m_image_file = info.hFile;
+DebuggerThread::HandleCreateProcessEvent(const CREATE_PROCESS_DEBUG_INFO &info,
+ DWORD thread_id) {
+ uint32_t process_id = ::GetProcessId(info.hProcess);
+
+ WINLOG_IFANY(WINDOWS_LOG_EVENT | WINDOWS_LOG_PROCESS,
+ "HandleCreateProcessEvent process %u spawned", process_id);
+
+ std::string thread_name;
+ llvm::raw_string_ostream name_stream(thread_name);
+ name_stream << "lldb.plugin.process-windows.slave[" << process_id << "]";
+ name_stream.flush();
+ ThisThread::SetName(thread_name.c_str());
+
+ // info.hProcess and info.hThread are closed automatically by Windows when
+ // EXIT_PROCESS_DEBUG_EVENT is received.
+ m_process = HostProcess(info.hProcess);
+ ((HostProcessWindows &)m_process.GetNativeProcess()).SetOwnsHandle(false);
+ m_main_thread = HostThread(info.hThread);
+ m_main_thread.GetNativeThread().SetOwnsHandle(false);
+ m_image_file = info.hFile;
- lldb::addr_t load_addr = reinterpret_cast<lldb::addr_t>(info.lpBaseOfImage);
- m_debug_delegate->OnDebuggerConnected(load_addr);
+ lldb::addr_t load_addr = reinterpret_cast<lldb::addr_t>(info.lpBaseOfImage);
+ m_debug_delegate->OnDebuggerConnected(load_addr);
- return DBG_CONTINUE;
+ return DBG_CONTINUE;
}
DWORD
-DebuggerThread::HandleExitThreadEvent(const EXIT_THREAD_DEBUG_INFO &info, DWORD thread_id)
-{
- WINLOG_IFANY(WINDOWS_LOG_EVENT|WINDOWS_LOG_THREAD,
- "HandleExitThreadEvent Thread %u exited with code %u in process %I64u",
- thread_id, info.dwExitCode, m_process.GetProcessId());
- m_debug_delegate->OnExitThread(thread_id, info.dwExitCode);
- return DBG_CONTINUE;
+DebuggerThread::HandleExitThreadEvent(const EXIT_THREAD_DEBUG_INFO &info,
+ DWORD thread_id) {
+ WINLOG_IFANY(
+ WINDOWS_LOG_EVENT | WINDOWS_LOG_THREAD,
+ "HandleExitThreadEvent Thread %u exited with code %u in process %I64u",
+ thread_id, info.dwExitCode, m_process.GetProcessId());
+ m_debug_delegate->OnExitThread(thread_id, info.dwExitCode);
+ return DBG_CONTINUE;
}
DWORD
-DebuggerThread::HandleExitProcessEvent(const EXIT_PROCESS_DEBUG_INFO &info, DWORD thread_id)
-{
- WINLOG_IFANY(WINDOWS_LOG_EVENT|WINDOWS_LOG_THREAD,
- "HandleExitProcessEvent process %I64u exited with code %u",
- m_process.GetProcessId(), info.dwExitCode);
+DebuggerThread::HandleExitProcessEvent(const EXIT_PROCESS_DEBUG_INFO &info,
+ DWORD thread_id) {
+ WINLOG_IFANY(WINDOWS_LOG_EVENT | WINDOWS_LOG_THREAD,
+ "HandleExitProcessEvent process %I64u exited with code %u",
+ m_process.GetProcessId(), info.dwExitCode);
- m_debug_delegate->OnExitProcess(info.dwExitCode);
+ m_debug_delegate->OnExitProcess(info.dwExitCode);
- FreeProcessHandles();
- return DBG_CONTINUE;
+ FreeProcessHandles();
+ return DBG_CONTINUE;
}
DWORD
-DebuggerThread::HandleLoadDllEvent(const LOAD_DLL_DEBUG_INFO &info, DWORD thread_id)
-{
- if (info.hFile == nullptr)
- {
- // Not sure what this is, so just ignore it.
- WINWARN_IFALL(WINDOWS_LOG_EVENT, "Inferior %I64u - HandleLoadDllEvent has a NULL file handle, returning...",
- m_process.GetProcessId());
- return DBG_CONTINUE;
- }
-
- std::vector<wchar_t> buffer(1);
- DWORD required_size = GetFinalPathNameByHandleW(info.hFile, &buffer[0], 0, VOLUME_NAME_DOS);
- if (required_size > 0)
- {
- buffer.resize(required_size + 1);
- required_size = GetFinalPathNameByHandleW(info.hFile, &buffer[0], required_size, VOLUME_NAME_DOS);
- std::string path_str_utf8;
- llvm::convertWideToUTF8(buffer.data(), path_str_utf8);
- llvm::StringRef path_str = path_str_utf8;
- const char *path = path_str.data();
- if (path_str.startswith("\\\\?\\"))
- path += 4;
-
- FileSpec file_spec(path, false);
- ModuleSpec module_spec(file_spec);
- lldb::addr_t load_addr = reinterpret_cast<lldb::addr_t>(info.lpBaseOfDll);
-
- WINLOG_IFALL(WINDOWS_LOG_EVENT, "Inferior %I64u - HandleLoadDllEvent DLL '%s' loaded at address 0x%p...",
- m_process.GetProcessId(), path, info.lpBaseOfDll);
-
- m_debug_delegate->OnLoadDll(module_spec, load_addr);
- }
- else
- {
- WINERR_IFALL(WINDOWS_LOG_EVENT,
- "Inferior %I64u - HandleLoadDllEvent Error %u occurred calling GetFinalPathNameByHandle",
- m_process.GetProcessId(), ::GetLastError());
- }
- // Windows does not automatically close info.hFile, so we need to do it.
- ::CloseHandle(info.hFile);
+DebuggerThread::HandleLoadDllEvent(const LOAD_DLL_DEBUG_INFO &info,
+ DWORD thread_id) {
+ if (info.hFile == nullptr) {
+ // Not sure what this is, so just ignore it.
+ WINWARN_IFALL(WINDOWS_LOG_EVENT, "Inferior %I64u - HandleLoadDllEvent has "
+ "a NULL file handle, returning...",
+ m_process.GetProcessId());
return DBG_CONTINUE;
+ }
+
+ std::vector<wchar_t> buffer(1);
+ DWORD required_size =
+ GetFinalPathNameByHandleW(info.hFile, &buffer[0], 0, VOLUME_NAME_DOS);
+ if (required_size > 0) {
+ buffer.resize(required_size + 1);
+ required_size = GetFinalPathNameByHandleW(info.hFile, &buffer[0],
+ required_size, VOLUME_NAME_DOS);
+ std::string path_str_utf8;
+ llvm::convertWideToUTF8(buffer.data(), path_str_utf8);
+ llvm::StringRef path_str = path_str_utf8;
+ const char *path = path_str.data();
+ if (path_str.startswith("\\\\?\\"))
+ path += 4;
+
+ FileSpec file_spec(path, false);
+ ModuleSpec module_spec(file_spec);
+ lldb::addr_t load_addr = reinterpret_cast<lldb::addr_t>(info.lpBaseOfDll);
+
+ WINLOG_IFALL(WINDOWS_LOG_EVENT, "Inferior %I64u - HandleLoadDllEvent DLL "
+ "'%s' loaded at address 0x%p...",
+ m_process.GetProcessId(), path, info.lpBaseOfDll);
+
+ m_debug_delegate->OnLoadDll(module_spec, load_addr);
+ } else {
+ WINERR_IFALL(WINDOWS_LOG_EVENT, "Inferior %I64u - HandleLoadDllEvent Error "
+ "%u occurred calling "
+ "GetFinalPathNameByHandle",
+ m_process.GetProcessId(), ::GetLastError());
+ }
+ // Windows does not automatically close info.hFile, so we need to do it.
+ ::CloseHandle(info.hFile);
+ return DBG_CONTINUE;
}
DWORD
-DebuggerThread::HandleUnloadDllEvent(const UNLOAD_DLL_DEBUG_INFO &info, DWORD thread_id)
-{
- WINLOG_IFALL(WINDOWS_LOG_EVENT,
- "HandleUnloadDllEvent process %I64u unloading DLL at addr 0x%p.",
- m_process.GetProcessId(), info.lpBaseOfDll);
-
- m_debug_delegate->OnUnloadDll(reinterpret_cast<lldb::addr_t>(info.lpBaseOfDll));
- return DBG_CONTINUE;
+DebuggerThread::HandleUnloadDllEvent(const UNLOAD_DLL_DEBUG_INFO &info,
+ DWORD thread_id) {
+ WINLOG_IFALL(WINDOWS_LOG_EVENT,
+ "HandleUnloadDllEvent process %I64u unloading DLL at addr 0x%p.",
+ m_process.GetProcessId(), info.lpBaseOfDll);
+
+ m_debug_delegate->OnUnloadDll(
+ reinterpret_cast<lldb::addr_t>(info.lpBaseOfDll));
+ return DBG_CONTINUE;
}
DWORD
-DebuggerThread::HandleODSEvent(const OUTPUT_DEBUG_STRING_INFO &info, DWORD thread_id)
-{
- return DBG_CONTINUE;
+DebuggerThread::HandleODSEvent(const OUTPUT_DEBUG_STRING_INFO &info,
+ DWORD thread_id) {
+ return DBG_CONTINUE;
}
DWORD
-DebuggerThread::HandleRipEvent(const RIP_INFO &info, DWORD thread_id)
-{
- WINERR_IFALL(WINDOWS_LOG_EVENT,
- "HandleRipEvent encountered error %u (type=%u) in process %I64u thread %u",
- info.dwError, info.dwType, m_process.GetProcessId(), thread_id);
+DebuggerThread::HandleRipEvent(const RIP_INFO &info, DWORD thread_id) {
+ WINERR_IFALL(WINDOWS_LOG_EVENT, "HandleRipEvent encountered error %u "
+ "(type=%u) in process %I64u thread %u",
+ info.dwError, info.dwType, m_process.GetProcessId(), thread_id);
- Error error(info.dwError, eErrorTypeWin32);
- m_debug_delegate->OnDebuggerError(error, info.dwType);
+ Error error(info.dwError, eErrorTypeWin32);
+ m_debug_delegate->OnDebuggerError(error, info.dwType);
- return DBG_CONTINUE;
+ return DBG_CONTINUE;
}
Modified: lldb/trunk/source/Plugins/Process/Windows/Live/DebuggerThread.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Windows/Live/DebuggerThread.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/Windows/Live/DebuggerThread.h (original)
+++ lldb/trunk/source/Plugins/Process/Windows/Live/DebuggerThread.h Tue Sep 6 15:57:50 2016
@@ -19,8 +19,7 @@
#include "lldb/Host/Predicate.h"
#include "lldb/Host/windows/windows.h"
-namespace lldb_private
-{
+namespace lldb_private {
//----------------------------------------------------------------------
// DebuggerThread
@@ -28,72 +27,76 @@ namespace lldb_private
// Debugs a single process, notifying listeners as appropriate when interesting
// things occur.
//----------------------------------------------------------------------
-class DebuggerThread : public std::enable_shared_from_this<DebuggerThread>
-{
- public:
- DebuggerThread(DebugDelegateSP debug_delegate);
- virtual ~DebuggerThread();
-
- Error DebugLaunch(const ProcessLaunchInfo &launch_info);
- Error DebugAttach(lldb::pid_t pid, const ProcessAttachInfo &attach_info);
-
- HostProcess
- GetProcess() const
- {
- return m_process;
- }
- HostThread
- GetMainThread() const
- {
- return m_main_thread;
- }
- std::weak_ptr<ExceptionRecord>
- GetActiveException()
- {
- return m_active_exception;
- }
-
- Error StopDebugging(bool terminate);
-
- void ContinueAsyncException(ExceptionResult result);
-
- private:
- void FreeProcessHandles();
- void DebugLoop();
- ExceptionResult HandleExceptionEvent(const EXCEPTION_DEBUG_INFO &info, DWORD thread_id);
- DWORD HandleCreateThreadEvent(const CREATE_THREAD_DEBUG_INFO &info, DWORD thread_id);
- DWORD HandleCreateProcessEvent(const CREATE_PROCESS_DEBUG_INFO &info, DWORD thread_id);
- DWORD HandleExitThreadEvent(const EXIT_THREAD_DEBUG_INFO &info, DWORD thread_id);
- DWORD HandleExitProcessEvent(const EXIT_PROCESS_DEBUG_INFO &info, DWORD thread_id);
- DWORD HandleLoadDllEvent(const LOAD_DLL_DEBUG_INFO &info, DWORD thread_id);
- DWORD HandleUnloadDllEvent(const UNLOAD_DLL_DEBUG_INFO &info, DWORD thread_id);
- DWORD HandleODSEvent(const OUTPUT_DEBUG_STRING_INFO &info, DWORD thread_id);
- DWORD HandleRipEvent(const RIP_INFO &info, DWORD thread_id);
-
- DebugDelegateSP m_debug_delegate;
-
- HostProcess m_process; // The process being debugged.
- HostThread m_main_thread; // The main thread of the inferior.
- HANDLE m_image_file; // The image file of the process being debugged.
-
- ExceptionRecordSP m_active_exception; // The current exception waiting to be handled
-
- Predicate<ExceptionResult> m_exception_pred; // A predicate which gets signalled when an exception
- // is finished processing and the debug loop can be
- // continued.
-
- HANDLE m_debugging_ended_event; // An event which gets signalled by the debugger thread when it
- // exits the debugger loop and is detached from the inferior.
-
- std::atomic<DWORD> m_pid_to_detach; // Signals the loop to detach from the process (specified by pid).
- std::atomic<bool> m_is_shutting_down; // Signals the debug loop to stop processing certain types of
- // events that block shutdown.
- bool m_detached; // Indicates we've detached from the inferior process and the debug loop can exit.
-
- static lldb::thread_result_t DebuggerThreadLaunchRoutine(void *data);
- lldb::thread_result_t DebuggerThreadLaunchRoutine(const ProcessLaunchInfo &launch_info);
- static lldb::thread_result_t DebuggerThreadAttachRoutine(void *data);
- lldb::thread_result_t DebuggerThreadAttachRoutine(lldb::pid_t pid, const ProcessAttachInfo &launch_info);
+class DebuggerThread : public std::enable_shared_from_this<DebuggerThread> {
+public:
+ DebuggerThread(DebugDelegateSP debug_delegate);
+ virtual ~DebuggerThread();
+
+ Error DebugLaunch(const ProcessLaunchInfo &launch_info);
+ Error DebugAttach(lldb::pid_t pid, const ProcessAttachInfo &attach_info);
+
+ HostProcess GetProcess() const { return m_process; }
+ HostThread GetMainThread() const { return m_main_thread; }
+ std::weak_ptr<ExceptionRecord> GetActiveException() {
+ return m_active_exception;
+ }
+
+ Error StopDebugging(bool terminate);
+
+ void ContinueAsyncException(ExceptionResult result);
+
+private:
+ void FreeProcessHandles();
+ void DebugLoop();
+ ExceptionResult HandleExceptionEvent(const EXCEPTION_DEBUG_INFO &info,
+ DWORD thread_id);
+ DWORD HandleCreateThreadEvent(const CREATE_THREAD_DEBUG_INFO &info,
+ DWORD thread_id);
+ DWORD HandleCreateProcessEvent(const CREATE_PROCESS_DEBUG_INFO &info,
+ DWORD thread_id);
+ DWORD HandleExitThreadEvent(const EXIT_THREAD_DEBUG_INFO &info,
+ DWORD thread_id);
+ DWORD HandleExitProcessEvent(const EXIT_PROCESS_DEBUG_INFO &info,
+ DWORD thread_id);
+ DWORD HandleLoadDllEvent(const LOAD_DLL_DEBUG_INFO &info, DWORD thread_id);
+ DWORD HandleUnloadDllEvent(const UNLOAD_DLL_DEBUG_INFO &info,
+ DWORD thread_id);
+ DWORD HandleODSEvent(const OUTPUT_DEBUG_STRING_INFO &info, DWORD thread_id);
+ DWORD HandleRipEvent(const RIP_INFO &info, DWORD thread_id);
+
+ DebugDelegateSP m_debug_delegate;
+
+ HostProcess m_process; // The process being debugged.
+ HostThread m_main_thread; // The main thread of the inferior.
+ HANDLE m_image_file; // The image file of the process being debugged.
+
+ ExceptionRecordSP
+ m_active_exception; // The current exception waiting to be handled
+
+ Predicate<ExceptionResult>
+ m_exception_pred; // A predicate which gets signalled when an exception
+ // is finished processing and the debug loop can be
+ // continued.
+
+ HANDLE m_debugging_ended_event; // An event which gets signalled by the
+ // debugger thread when it
+ // exits the debugger loop and is detached from the inferior.
+
+ std::atomic<DWORD> m_pid_to_detach; // Signals the loop to detach from the
+ // process (specified by pid).
+ std::atomic<bool> m_is_shutting_down; // Signals the debug loop to stop
+ // processing certain types of
+ // events that block shutdown.
+ bool m_detached; // Indicates we've detached from the inferior process and the
+ // debug loop can exit.
+
+ static lldb::thread_result_t DebuggerThreadLaunchRoutine(void *data);
+ lldb::thread_result_t
+ DebuggerThreadLaunchRoutine(const ProcessLaunchInfo &launch_info);
+ static lldb::thread_result_t DebuggerThreadAttachRoutine(void *data);
+ lldb::thread_result_t
+ DebuggerThreadAttachRoutine(lldb::pid_t pid,
+ const ProcessAttachInfo &launch_info);
};
}
Modified: lldb/trunk/source/Plugins/Process/Windows/Live/ForwardDecl.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Windows/Live/ForwardDecl.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/Windows/Live/ForwardDecl.h (original)
+++ lldb/trunk/source/Plugins/Process/Windows/Live/ForwardDecl.h Tue Sep 6 15:57:50 2016
@@ -14,17 +14,18 @@
// ExceptionResult is returned by the debug delegate to specify how it processed
// the exception.
-enum class ExceptionResult
-{
- BreakInDebugger, // Break in the debugger and give the user a chance to interact with
- // the program before continuing.
- MaskException, // Eat the exception and don't let the application know it occurred.
- SendToApplication // Send the exception to the application to be handled as if there were
- // no debugger attached.
+enum class ExceptionResult {
+ BreakInDebugger, // Break in the debugger and give the user a chance to
+ // interact with
+ // the program before continuing.
+ MaskException, // Eat the exception and don't let the application know it
+ // occurred.
+ SendToApplication // Send the exception to the application to be handled as if
+ // there were
+ // no debugger attached.
};
-namespace lldb_private
-{
+namespace lldb_private {
class ProcessWindows;
Modified: lldb/trunk/source/Plugins/Process/Windows/Live/IDebugDelegate.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Windows/Live/IDebugDelegate.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/Windows/Live/IDebugDelegate.h (original)
+++ lldb/trunk/source/Plugins/Process/Windows/Live/IDebugDelegate.h Tue Sep 6 15:57:50 2016
@@ -15,8 +15,7 @@
#include "lldb/lldb-types.h"
#include <string>
-namespace lldb_private
-{
+namespace lldb_private {
class Error;
class HostThread;
@@ -26,20 +25,21 @@ class HostThread;
// IDebugDelegate defines an interface which allows implementors to receive
// notification of events that happen in a debugged process.
//----------------------------------------------------------------------
-class IDebugDelegate
-{
- public:
- virtual ~IDebugDelegate() {}
+class IDebugDelegate {
+public:
+ virtual ~IDebugDelegate() {}
- virtual void OnExitProcess(uint32_t exit_code) = 0;
- virtual void OnDebuggerConnected(lldb::addr_t image_base) = 0;
- virtual ExceptionResult OnDebugException(bool first_chance, const ExceptionRecord &record) = 0;
- virtual void OnCreateThread(const HostThread &thread) = 0;
- virtual void OnExitThread(lldb::tid_t thread_id, uint32_t exit_code) = 0;
- virtual void OnLoadDll(const ModuleSpec &module_spec, lldb::addr_t module_addr) = 0;
- virtual void OnUnloadDll(lldb::addr_t module_addr) = 0;
- virtual void OnDebugString(const std::string &string) = 0;
- virtual void OnDebuggerError(const Error &error, uint32_t type) = 0;
+ virtual void OnExitProcess(uint32_t exit_code) = 0;
+ virtual void OnDebuggerConnected(lldb::addr_t image_base) = 0;
+ virtual ExceptionResult OnDebugException(bool first_chance,
+ const ExceptionRecord &record) = 0;
+ virtual void OnCreateThread(const HostThread &thread) = 0;
+ virtual void OnExitThread(lldb::tid_t thread_id, uint32_t exit_code) = 0;
+ virtual void OnLoadDll(const ModuleSpec &module_spec,
+ lldb::addr_t module_addr) = 0;
+ virtual void OnUnloadDll(lldb::addr_t module_addr) = 0;
+ virtual void OnDebugString(const std::string &string) = 0;
+ virtual void OnDebuggerError(const Error &error, uint32_t type) = 0;
};
}
Modified: lldb/trunk/source/Plugins/Process/Windows/Live/LocalDebugDelegate.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Windows/Live/LocalDebugDelegate.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/Windows/Live/LocalDebugDelegate.cpp (original)
+++ lldb/trunk/source/Plugins/Process/Windows/Live/LocalDebugDelegate.cpp Tue Sep 6 15:57:50 2016
@@ -14,78 +14,60 @@ using namespace lldb;
using namespace lldb_private;
LocalDebugDelegate::LocalDebugDelegate(ProcessWP process)
- : m_process(process)
-{
+ : m_process(process) {}
+
+void LocalDebugDelegate::OnExitProcess(uint32_t exit_code) {
+ if (ProcessWindowsLiveSP process = GetProcessPointer())
+ process->OnExitProcess(exit_code);
}
-void
-LocalDebugDelegate::OnExitProcess(uint32_t exit_code)
-{
- if (ProcessWindowsLiveSP process = GetProcessPointer())
- process->OnExitProcess(exit_code);
-}
-
-void
-LocalDebugDelegate::OnDebuggerConnected(lldb::addr_t image_base)
-{
- if (ProcessWindowsLiveSP process = GetProcessPointer())
- process->OnDebuggerConnected(image_base);
+void LocalDebugDelegate::OnDebuggerConnected(lldb::addr_t image_base) {
+ if (ProcessWindowsLiveSP process = GetProcessPointer())
+ process->OnDebuggerConnected(image_base);
}
ExceptionResult
-LocalDebugDelegate::OnDebugException(bool first_chance, const ExceptionRecord &record)
-{
- if (ProcessWindowsLiveSP process = GetProcessPointer())
- return process->OnDebugException(first_chance, record);
- else
- return ExceptionResult::MaskException;
+LocalDebugDelegate::OnDebugException(bool first_chance,
+ const ExceptionRecord &record) {
+ if (ProcessWindowsLiveSP process = GetProcessPointer())
+ return process->OnDebugException(first_chance, record);
+ else
+ return ExceptionResult::MaskException;
}
-void
-LocalDebugDelegate::OnCreateThread(const HostThread &thread)
-{
- if (ProcessWindowsLiveSP process = GetProcessPointer())
- process->OnCreateThread(thread);
+void LocalDebugDelegate::OnCreateThread(const HostThread &thread) {
+ if (ProcessWindowsLiveSP process = GetProcessPointer())
+ process->OnCreateThread(thread);
}
-void
-LocalDebugDelegate::OnExitThread(lldb::tid_t thread_id, uint32_t exit_code)
-{
- if (ProcessWindowsLiveSP process = GetProcessPointer())
- process->OnExitThread(thread_id, exit_code);
+void LocalDebugDelegate::OnExitThread(lldb::tid_t thread_id,
+ uint32_t exit_code) {
+ if (ProcessWindowsLiveSP process = GetProcessPointer())
+ process->OnExitThread(thread_id, exit_code);
}
-void
-LocalDebugDelegate::OnLoadDll(const lldb_private::ModuleSpec &module_spec, lldb::addr_t module_addr)
-{
- if (ProcessWindowsLiveSP process = GetProcessPointer())
- process->OnLoadDll(module_spec, module_addr);
+void LocalDebugDelegate::OnLoadDll(const lldb_private::ModuleSpec &module_spec,
+ lldb::addr_t module_addr) {
+ if (ProcessWindowsLiveSP process = GetProcessPointer())
+ process->OnLoadDll(module_spec, module_addr);
}
-void
-LocalDebugDelegate::OnUnloadDll(lldb::addr_t module_addr)
-{
- if (ProcessWindowsLiveSP process = GetProcessPointer())
- process->OnUnloadDll(module_addr);
+void LocalDebugDelegate::OnUnloadDll(lldb::addr_t module_addr) {
+ if (ProcessWindowsLiveSP process = GetProcessPointer())
+ process->OnUnloadDll(module_addr);
}
-void
-LocalDebugDelegate::OnDebugString(const std::string &string)
-{
- if (ProcessWindowsLiveSP process = GetProcessPointer())
- process->OnDebugString(string);
+void LocalDebugDelegate::OnDebugString(const std::string &string) {
+ if (ProcessWindowsLiveSP process = GetProcessPointer())
+ process->OnDebugString(string);
}
-void
-LocalDebugDelegate::OnDebuggerError(const Error &error, uint32_t type)
-{
- if (ProcessWindowsLiveSP process = GetProcessPointer())
- process->OnDebuggerError(error, type);
+void LocalDebugDelegate::OnDebuggerError(const Error &error, uint32_t type) {
+ if (ProcessWindowsLiveSP process = GetProcessPointer())
+ process->OnDebuggerError(error, type);
}
-ProcessWindowsLiveSP
-LocalDebugDelegate::GetProcessPointer()
-{
- ProcessSP process = m_process.lock();
- return std::static_pointer_cast<ProcessWindowsLive>(process);
+ProcessWindowsLiveSP LocalDebugDelegate::GetProcessPointer() {
+ ProcessSP process = m_process.lock();
+ return std::static_pointer_cast<ProcessWindowsLive>(process);
}
Modified: lldb/trunk/source/Plugins/Process/Windows/Live/LocalDebugDelegate.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Windows/Live/LocalDebugDelegate.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/Windows/Live/LocalDebugDelegate.h (original)
+++ lldb/trunk/source/Plugins/Process/Windows/Live/LocalDebugDelegate.h Tue Sep 6 15:57:50 2016
@@ -16,8 +16,7 @@
#include "lldb/lldb-forward.h"
-namespace lldb_private
-{
+namespace lldb_private {
class ProcessWindowsLive;
typedef std::shared_ptr<ProcessWindowsLive> ProcessWindowsLiveSP;
@@ -26,9 +25,11 @@ typedef std::shared_ptr<ProcessWindowsLi
// LocalDebugDelegate
//
// LocalDebugDelegate creates a connection between a ProcessWindowsLive and the
-// debug driver. This serves to decouple ProcessWindowsLive from the debug driver.
+// debug driver. This serves to decouple ProcessWindowsLive from the debug
+// driver.
// It would be possible to get a similar decoupling by just having
-// ProcessWindowsLive implement this interface directly. There are two reasons why
+// ProcessWindowsLive implement this interface directly. There are two reasons
+// why
// we don't do this:
//
// 1) In the future when we add support for local debugging through LLGS, and we
@@ -42,26 +43,26 @@ typedef std::shared_ptr<ProcessWindowsLi
// driver), so this adapter serves as a way to transparently hold the
// ProcessSP while still keeping it decoupled from the driver.
//----------------------------------------------------------------------
-class LocalDebugDelegate : public IDebugDelegate
-{
- public:
- explicit LocalDebugDelegate(lldb::ProcessWP process);
-
- void OnExitProcess(uint32_t exit_code) override;
- void OnDebuggerConnected(lldb::addr_t image_base) override;
- ExceptionResult OnDebugException(bool first_chance, const ExceptionRecord &record) override;
- void OnCreateThread(const HostThread &thread) override;
- void OnExitThread(lldb::tid_t thread_id, uint32_t exit_code) override;
- void OnLoadDll(const lldb_private::ModuleSpec &module_spec, lldb::addr_t module_addr) override;
- void OnUnloadDll(lldb::addr_t module_addr) override;
- void OnDebugString(const std::string &message) override;
- void OnDebuggerError(const Error &error, uint32_t type) override;
-
- private:
- ProcessWindowsLiveSP
- GetProcessPointer();
+class LocalDebugDelegate : public IDebugDelegate {
+public:
+ explicit LocalDebugDelegate(lldb::ProcessWP process);
+
+ void OnExitProcess(uint32_t exit_code) override;
+ void OnDebuggerConnected(lldb::addr_t image_base) override;
+ ExceptionResult OnDebugException(bool first_chance,
+ const ExceptionRecord &record) override;
+ void OnCreateThread(const HostThread &thread) override;
+ void OnExitThread(lldb::tid_t thread_id, uint32_t exit_code) override;
+ void OnLoadDll(const lldb_private::ModuleSpec &module_spec,
+ lldb::addr_t module_addr) override;
+ void OnUnloadDll(lldb::addr_t module_addr) override;
+ void OnDebugString(const std::string &message) override;
+ void OnDebuggerError(const Error &error, uint32_t type) override;
- lldb::ProcessWP m_process;
+private:
+ ProcessWindowsLiveSP GetProcessPointer();
+
+ lldb::ProcessWP m_process;
};
}
Modified: lldb/trunk/source/Plugins/Process/Windows/Live/ProcessWindowsLive.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Windows/Live/ProcessWindowsLive.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/Windows/Live/ProcessWindowsLive.cpp (original)
+++ lldb/trunk/source/Plugins/Process/Windows/Live/ProcessWindowsLive.cpp Tue Sep 6 15:57:50 2016
@@ -24,9 +24,9 @@
#include "lldb/Core/Section.h"
#include "lldb/Core/State.h"
#include "lldb/Host/Host.h"
-#include "lldb/Host/HostProcess.h"
#include "lldb/Host/HostNativeProcessBase.h"
#include "lldb/Host/HostNativeThreadBase.h"
+#include "lldb/Host/HostProcess.h"
#include "lldb/Host/MonitoringProcessLauncher.h"
#include "lldb/Host/ThreadLauncher.h"
#include "lldb/Host/windows/HostThreadWindows.h"
@@ -56,1014 +56,991 @@ using namespace lldb_private;
#define BOOL_STR(b) ((b) ? "true" : "false")
-namespace
-{
-
-std::string
-GetProcessExecutableName(HANDLE process_handle)
-{
- std::vector<wchar_t> file_name;
- DWORD file_name_size = MAX_PATH; // first guess, not an absolute limit
- DWORD copied = 0;
- do
- {
- file_name_size *= 2;
- file_name.resize(file_name_size);
- copied = ::GetModuleFileNameExW(process_handle, NULL, file_name.data(), file_name_size);
- } while (copied >= file_name_size);
- file_name.resize(copied);
- std::string result;
- llvm::convertWideToUTF8(file_name.data(), result);
- return result;
-}
+namespace {
-std::string
-GetProcessExecutableName(DWORD pid)
-{
- std::string file_name;
- HANDLE process_handle = ::OpenProcess(PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, FALSE, pid);
- if (process_handle != NULL)
- {
- file_name = GetProcessExecutableName(process_handle);
- ::CloseHandle(process_handle);
- }
- return file_name;
+std::string GetProcessExecutableName(HANDLE process_handle) {
+ std::vector<wchar_t> file_name;
+ DWORD file_name_size = MAX_PATH; // first guess, not an absolute limit
+ DWORD copied = 0;
+ do {
+ file_name_size *= 2;
+ file_name.resize(file_name_size);
+ copied = ::GetModuleFileNameExW(process_handle, NULL, file_name.data(),
+ file_name_size);
+ } while (copied >= file_name_size);
+ file_name.resize(copied);
+ std::string result;
+ llvm::convertWideToUTF8(file_name.data(), result);
+ return result;
+}
+
+std::string GetProcessExecutableName(DWORD pid) {
+ std::string file_name;
+ HANDLE process_handle =
+ ::OpenProcess(PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, FALSE, pid);
+ if (process_handle != NULL) {
+ file_name = GetProcessExecutableName(process_handle);
+ ::CloseHandle(process_handle);
+ }
+ return file_name;
}
-} // anonymous namespace
+} // anonymous namespace
-namespace lldb_private
-{
+namespace lldb_private {
-// We store a pointer to this class in the ProcessWindows, so that we don't expose Windows
+// We store a pointer to this class in the ProcessWindows, so that we don't
+// expose Windows
// OS specific types and implementation details from a public header file.
-class ProcessWindowsData
-{
- public:
- ProcessWindowsData(bool stop_at_entry)
- : m_stop_at_entry(stop_at_entry)
- , m_initial_stop_event(nullptr)
- , m_initial_stop_received(false)
- {
- m_initial_stop_event = ::CreateEvent(nullptr, TRUE, FALSE, nullptr);
- }
-
- ~ProcessWindowsData() { ::CloseHandle(m_initial_stop_event); }
-
- lldb_private::Error m_launch_error;
- lldb_private::DebuggerThreadSP m_debugger;
- StopInfoSP m_pending_stop_info;
- HANDLE m_initial_stop_event;
- bool m_stop_at_entry;
- bool m_initial_stop_received;
- std::map<lldb::tid_t, HostThread> m_new_threads;
- std::set<lldb::tid_t> m_exited_threads;
+class ProcessWindowsData {
+public:
+ ProcessWindowsData(bool stop_at_entry)
+ : m_stop_at_entry(stop_at_entry), m_initial_stop_event(nullptr),
+ m_initial_stop_received(false) {
+ m_initial_stop_event = ::CreateEvent(nullptr, TRUE, FALSE, nullptr);
+ }
+
+ ~ProcessWindowsData() { ::CloseHandle(m_initial_stop_event); }
+
+ lldb_private::Error m_launch_error;
+ lldb_private::DebuggerThreadSP m_debugger;
+ StopInfoSP m_pending_stop_info;
+ HANDLE m_initial_stop_event;
+ bool m_stop_at_entry;
+ bool m_initial_stop_received;
+ std::map<lldb::tid_t, HostThread> m_new_threads;
+ std::set<lldb::tid_t> m_exited_threads;
};
}
//------------------------------------------------------------------------------
// Static functions.
-ProcessSP
-ProcessWindowsLive::CreateInstance(lldb::TargetSP target_sp, lldb::ListenerSP listener_sp, const FileSpec *)
-{
- return ProcessSP(new ProcessWindowsLive(target_sp, listener_sp));
-}
-
-void
-ProcessWindowsLive::Initialize()
-{
- static std::once_flag g_once_flag;
-
- std::call_once(g_once_flag, []()
- {
- PluginManager::RegisterPlugin(GetPluginNameStatic(),
- GetPluginDescriptionStatic(),
- CreateInstance);
- });
+ProcessSP ProcessWindowsLive::CreateInstance(lldb::TargetSP target_sp,
+ lldb::ListenerSP listener_sp,
+ const FileSpec *) {
+ return ProcessSP(new ProcessWindowsLive(target_sp, listener_sp));
}
-//------------------------------------------------------------------------------
-// Constructors and destructors.
-
-ProcessWindowsLive::ProcessWindowsLive(lldb::TargetSP target_sp, lldb::ListenerSP listener_sp)
- : lldb_private::ProcessWindows(target_sp, listener_sp)
-{
+void ProcessWindowsLive::Initialize() {
+ static std::once_flag g_once_flag;
+
+ std::call_once(g_once_flag, []() {
+ PluginManager::RegisterPlugin(GetPluginNameStatic(),
+ GetPluginDescriptionStatic(), CreateInstance);
+ });
}
-ProcessWindowsLive::~ProcessWindowsLive()
-{
-}
-
-void
-ProcessWindowsLive::Terminate()
-{
-}
-
-lldb_private::ConstString
-ProcessWindowsLive::GetPluginNameStatic()
-{
- static ConstString g_name("windows");
- return g_name;
-}
-
-const char *
-ProcessWindowsLive::GetPluginDescriptionStatic()
-{
- return "Process plugin for Windows";
-}
-
-Error
-ProcessWindowsLive::EnableBreakpointSite(BreakpointSite *bp_site)
-{
- WINLOG_IFALL(WINDOWS_LOG_BREAKPOINTS, "EnableBreakpointSite called with bp_site 0x%p "
- "(id=%d, addr=0x%x)",
- bp_site->GetID(), bp_site->GetLoadAddress());
-
- Error error = EnableSoftwareBreakpoint(bp_site);
- if (!error.Success())
- {
- WINERR_IFALL(WINDOWS_LOG_BREAKPOINTS, "EnableBreakpointSite failed. %s", error.AsCString());
- }
- return error;
-}
-
-Error
-ProcessWindowsLive::DisableBreakpointSite(BreakpointSite *bp_site)
-{
- WINLOG_IFALL(WINDOWS_LOG_BREAKPOINTS, "DisableBreakpointSite called with bp_site 0x%p "
- "(id=%d, addr=0x%x)",
- bp_site, bp_site->GetID(), bp_site->GetLoadAddress());
-
- Error error = DisableSoftwareBreakpoint(bp_site);
-
- if (!error.Success())
- {
- WINERR_IFALL(WINDOWS_LOG_BREAKPOINTS, "DisableBreakpointSite failed. %s", error.AsCString());
- }
- return error;
-}
-
-bool
-ProcessWindowsLive::UpdateThreadList(ThreadList &old_thread_list, ThreadList &new_thread_list)
-{
- // Add all the threads that were previously running and for which we did not detect a thread
- // exited event.
- int new_size = 0;
- int continued_threads = 0;
- int exited_threads = 0;
- int new_threads = 0;
-
- for (ThreadSP old_thread : old_thread_list.Threads())
- {
- lldb::tid_t old_thread_id = old_thread->GetID();
- auto exited_thread_iter = m_session_data->m_exited_threads.find(old_thread_id);
- if (exited_thread_iter == m_session_data->m_exited_threads.end())
- {
- new_thread_list.AddThread(old_thread);
- ++new_size;
- ++continued_threads;
- WINLOGV_IFALL(WINDOWS_LOG_THREAD, "UpdateThreadList - Thread %u was running and is still running.",
- old_thread_id);
- }
- else
- {
- WINLOGV_IFALL(WINDOWS_LOG_THREAD, "UpdateThreadList - Thread %u was running and has exited.",
- old_thread_id);
- ++exited_threads;
- }
- }
-
- // Also add all the threads that are new since the last time we broke into the debugger.
- for (const auto &thread_info : m_session_data->m_new_threads)
- {
- ThreadSP thread(new TargetThreadWindowsLive(*this, thread_info.second));
- thread->SetID(thread_info.first);
- new_thread_list.AddThread(thread);
- ++new_size;
- ++new_threads;
- WINLOGV_IFALL(WINDOWS_LOG_THREAD, "UpdateThreadList - Thread %u is new since last update.", thread_info.first);
- }
-
- WINLOG_IFALL(WINDOWS_LOG_THREAD, "UpdateThreadList - %d new threads, %d old threads, %d exited threads.",
- new_threads, continued_threads, exited_threads);
-
- m_session_data->m_new_threads.clear();
- m_session_data->m_exited_threads.clear();
-
- return new_size > 0;
-}
-
-Error
-ProcessWindowsLive::DoLaunch(Module *exe_module,
- ProcessLaunchInfo &launch_info)
-{
- // Even though m_session_data is accessed here, it is before a debugger thread has been
- // kicked off. So there's no race conditions, and it shouldn't be necessary to acquire
- // the mutex.
-
- Error result;
- if (!launch_info.GetFlags().Test(eLaunchFlagDebug))
- {
- StreamString stream;
- stream.Printf("ProcessWindows unable to launch '%s'. ProcessWindows can only be used for debug launches.",
- launch_info.GetExecutableFile().GetPath().c_str());
- std::string message = stream.GetString();
- result.SetErrorString(message.c_str());
-
- WINERR_IFALL(WINDOWS_LOG_PROCESS, message.c_str());
- return result;
- }
-
- bool stop_at_entry = launch_info.GetFlags().Test(eLaunchFlagStopAtEntry);
- m_session_data.reset(new ProcessWindowsData(stop_at_entry));
-
- SetPrivateState(eStateLaunching);
- DebugDelegateSP delegate(new LocalDebugDelegate(shared_from_this()));
- m_session_data->m_debugger.reset(new DebuggerThread(delegate));
- DebuggerThreadSP debugger = m_session_data->m_debugger;
-
- // Kick off the DebugLaunch asynchronously and wait for it to complete.
- result = debugger->DebugLaunch(launch_info);
- if (result.Fail())
- {
- WINERR_IFALL(WINDOWS_LOG_PROCESS, "DoLaunch failed launching '%s'. %s",
- launch_info.GetExecutableFile().GetPath().c_str(), result.AsCString());
- return result;
- }
-
- HostProcess process;
- Error error = WaitForDebuggerConnection(debugger, process);
- if (error.Fail())
- {
- WINERR_IFALL(WINDOWS_LOG_PROCESS, "DoLaunch failed launching '%s'. %s",
- launch_info.GetExecutableFile().GetPath().c_str(), error.AsCString());
- return error;
- }
-
- WINLOG_IFALL(WINDOWS_LOG_PROCESS, "DoLaunch successfully launched '%s'",
- launch_info.GetExecutableFile().GetPath().c_str());
+//------------------------------------------------------------------------------
+// Constructors and destructors.
- // We've hit the initial stop. If eLaunchFlagsStopAtEntry was specified, the private state
- // should already be set to eStateStopped as a result of hitting the initial breakpoint. If
- // it was not set, the breakpoint should have already been resumed from and the private state
- // should already be eStateRunning.
- launch_info.SetProcessID(process.GetProcessId());
- SetID(process.GetProcessId());
+ProcessWindowsLive::ProcessWindowsLive(lldb::TargetSP target_sp,
+ lldb::ListenerSP listener_sp)
+ : lldb_private::ProcessWindows(target_sp, listener_sp) {}
+
+ProcessWindowsLive::~ProcessWindowsLive() {}
+
+void ProcessWindowsLive::Terminate() {}
+
+lldb_private::ConstString ProcessWindowsLive::GetPluginNameStatic() {
+ static ConstString g_name("windows");
+ return g_name;
+}
+
+const char *ProcessWindowsLive::GetPluginDescriptionStatic() {
+ return "Process plugin for Windows";
+}
+
+Error ProcessWindowsLive::EnableBreakpointSite(BreakpointSite *bp_site) {
+ WINLOG_IFALL(WINDOWS_LOG_BREAKPOINTS,
+ "EnableBreakpointSite called with bp_site 0x%p "
+ "(id=%d, addr=0x%x)",
+ bp_site->GetID(), bp_site->GetLoadAddress());
+
+ Error error = EnableSoftwareBreakpoint(bp_site);
+ if (!error.Success()) {
+ WINERR_IFALL(WINDOWS_LOG_BREAKPOINTS, "EnableBreakpointSite failed. %s",
+ error.AsCString());
+ }
+ return error;
+}
+
+Error ProcessWindowsLive::DisableBreakpointSite(BreakpointSite *bp_site) {
+ WINLOG_IFALL(WINDOWS_LOG_BREAKPOINTS,
+ "DisableBreakpointSite called with bp_site 0x%p "
+ "(id=%d, addr=0x%x)",
+ bp_site, bp_site->GetID(), bp_site->GetLoadAddress());
+
+ Error error = DisableSoftwareBreakpoint(bp_site);
+
+ if (!error.Success()) {
+ WINERR_IFALL(WINDOWS_LOG_BREAKPOINTS, "DisableBreakpointSite failed. %s",
+ error.AsCString());
+ }
+ return error;
+}
+
+bool ProcessWindowsLive::UpdateThreadList(ThreadList &old_thread_list,
+ ThreadList &new_thread_list) {
+ // Add all the threads that were previously running and for which we did not
+ // detect a thread
+ // exited event.
+ int new_size = 0;
+ int continued_threads = 0;
+ int exited_threads = 0;
+ int new_threads = 0;
+
+ for (ThreadSP old_thread : old_thread_list.Threads()) {
+ lldb::tid_t old_thread_id = old_thread->GetID();
+ auto exited_thread_iter =
+ m_session_data->m_exited_threads.find(old_thread_id);
+ if (exited_thread_iter == m_session_data->m_exited_threads.end()) {
+ new_thread_list.AddThread(old_thread);
+ ++new_size;
+ ++continued_threads;
+ WINLOGV_IFALL(
+ WINDOWS_LOG_THREAD,
+ "UpdateThreadList - Thread %u was running and is still running.",
+ old_thread_id);
+ } else {
+ WINLOGV_IFALL(WINDOWS_LOG_THREAD,
+ "UpdateThreadList - Thread %u was running and has exited.",
+ old_thread_id);
+ ++exited_threads;
+ }
+ }
+
+ // Also add all the threads that are new since the last time we broke into the
+ // debugger.
+ for (const auto &thread_info : m_session_data->m_new_threads) {
+ ThreadSP thread(new TargetThreadWindowsLive(*this, thread_info.second));
+ thread->SetID(thread_info.first);
+ new_thread_list.AddThread(thread);
+ ++new_size;
+ ++new_threads;
+ WINLOGV_IFALL(WINDOWS_LOG_THREAD,
+ "UpdateThreadList - Thread %u is new since last update.",
+ thread_info.first);
+ }
+
+ WINLOG_IFALL(
+ WINDOWS_LOG_THREAD,
+ "UpdateThreadList - %d new threads, %d old threads, %d exited threads.",
+ new_threads, continued_threads, exited_threads);
+
+ m_session_data->m_new_threads.clear();
+ m_session_data->m_exited_threads.clear();
+
+ return new_size > 0;
+}
+
+Error ProcessWindowsLive::DoLaunch(Module *exe_module,
+ ProcessLaunchInfo &launch_info) {
+ // Even though m_session_data is accessed here, it is before a debugger thread
+ // has been
+ // kicked off. So there's no race conditions, and it shouldn't be necessary
+ // to acquire
+ // the mutex.
+
+ Error result;
+ if (!launch_info.GetFlags().Test(eLaunchFlagDebug)) {
+ StreamString stream;
+ stream.Printf("ProcessWindows unable to launch '%s'. ProcessWindows can "
+ "only be used for debug launches.",
+ launch_info.GetExecutableFile().GetPath().c_str());
+ std::string message = stream.GetString();
+ result.SetErrorString(message.c_str());
+ WINERR_IFALL(WINDOWS_LOG_PROCESS, message.c_str());
return result;
-}
+ }
-Error
-ProcessWindowsLive::DoAttachToProcessWithID(lldb::pid_t pid, const ProcessAttachInfo &attach_info)
-{
- m_session_data.reset(new ProcessWindowsData(!attach_info.GetContinueOnceAttached()));
-
- DebugDelegateSP delegate(new LocalDebugDelegate(shared_from_this()));
- DebuggerThreadSP debugger(new DebuggerThread(delegate));
-
- m_session_data->m_debugger = debugger;
-
- DWORD process_id = static_cast<DWORD>(pid);
- Error error = debugger->DebugAttach(process_id, attach_info);
- if (error.Fail())
- {
- WINLOG_IFALL(WINDOWS_LOG_PROCESS,
- "DoAttachToProcessWithID encountered an error occurred initiating the asynchronous attach. %s",
- error.AsCString());
- return error;
- }
-
- HostProcess process;
- error = WaitForDebuggerConnection(debugger, process);
- if (error.Fail())
- {
- WINLOG_IFALL(WINDOWS_LOG_PROCESS,
- "DoAttachToProcessWithID encountered an error waiting for the debugger to connect. %s",
- error.AsCString());
- return error;
- }
+ bool stop_at_entry = launch_info.GetFlags().Test(eLaunchFlagStopAtEntry);
+ m_session_data.reset(new ProcessWindowsData(stop_at_entry));
- WINLOG_IFALL(WINDOWS_LOG_PROCESS, "DoAttachToProcessWithID successfully attached to process with pid=%u",
- process_id);
+ SetPrivateState(eStateLaunching);
+ DebugDelegateSP delegate(new LocalDebugDelegate(shared_from_this()));
+ m_session_data->m_debugger.reset(new DebuggerThread(delegate));
+ DebuggerThreadSP debugger = m_session_data->m_debugger;
+
+ // Kick off the DebugLaunch asynchronously and wait for it to complete.
+ result = debugger->DebugLaunch(launch_info);
+ if (result.Fail()) {
+ WINERR_IFALL(WINDOWS_LOG_PROCESS, "DoLaunch failed launching '%s'. %s",
+ launch_info.GetExecutableFile().GetPath().c_str(),
+ result.AsCString());
+ return result;
+ }
- // We've hit the initial stop. If eLaunchFlagsStopAtEntry was specified, the private state
- // should already be set to eStateStopped as a result of hitting the initial breakpoint. If
- // it was not set, the breakpoint should have already been resumed from and the private state
- // should already be eStateRunning.
- SetID(process.GetProcessId());
+ HostProcess process;
+ Error error = WaitForDebuggerConnection(debugger, process);
+ if (error.Fail()) {
+ WINERR_IFALL(WINDOWS_LOG_PROCESS, "DoLaunch failed launching '%s'. %s",
+ launch_info.GetExecutableFile().GetPath().c_str(),
+ error.AsCString());
return error;
-}
-
-Error
-ProcessWindowsLive::WaitForDebuggerConnection(DebuggerThreadSP debugger, HostProcess &process)
-{
- Error result;
- WINLOG_IFANY(WINDOWS_LOG_PROCESS|WINDOWS_LOG_BREAKPOINTS, "WaitForDebuggerConnection Waiting for loader breakpoint.");
-
- // Block this function until we receive the initial stop from the process.
- if (::WaitForSingleObject(m_session_data->m_initial_stop_event, INFINITE) == WAIT_OBJECT_0)
- {
- WINLOG_IFANY(WINDOWS_LOG_PROCESS|WINDOWS_LOG_BREAKPOINTS, "WaitForDebuggerConnection hit loader breakpoint, returning.");
-
- process = debugger->GetProcess();
- return m_session_data->m_launch_error;
- }
- else
- return Error(::GetLastError(), eErrorTypeWin32);
-}
+ }
-Error
-ProcessWindowsLive::DoResume()
-{
- llvm::sys::ScopedLock lock(m_mutex);
- Error error;
+ WINLOG_IFALL(WINDOWS_LOG_PROCESS, "DoLaunch successfully launched '%s'",
+ launch_info.GetExecutableFile().GetPath().c_str());
- StateType private_state = GetPrivateState();
- if (private_state == eStateStopped || private_state == eStateCrashed)
- {
- WINLOG_IFALL(WINDOWS_LOG_PROCESS, "DoResume called for process %I64u while state is %u. Resuming...",
- m_session_data->m_debugger->GetProcess().GetProcessId(), GetPrivateState());
-
- ExceptionRecordSP active_exception =
- m_session_data->m_debugger->GetActiveException().lock();
- if (active_exception)
- {
- // Resume the process and continue processing debug events. Mask
- // the exception so that from the process's view, there is no
- // indication that anything happened.
- m_session_data->m_debugger->ContinueAsyncException(
- ExceptionResult::MaskException);
- }
-
- WINLOG_IFANY(WINDOWS_LOG_PROCESS | WINDOWS_LOG_THREAD, "DoResume resuming %u threads.",
- m_thread_list.GetSize());
-
- for (int i = 0; i < m_thread_list.GetSize(); ++i)
- {
- auto thread = std::static_pointer_cast<TargetThreadWindowsLive>(
- m_thread_list.GetThreadAtIndex(i));
- thread->DoResume();
- }
+ // We've hit the initial stop. If eLaunchFlagsStopAtEntry was specified, the
+ // private state
+ // should already be set to eStateStopped as a result of hitting the initial
+ // breakpoint. If
+ // it was not set, the breakpoint should have already been resumed from and
+ // the private state
+ // should already be eStateRunning.
+ launch_info.SetProcessID(process.GetProcessId());
+ SetID(process.GetProcessId());
+
+ return result;
+}
+
+Error ProcessWindowsLive::DoAttachToProcessWithID(
+ lldb::pid_t pid, const ProcessAttachInfo &attach_info) {
+ m_session_data.reset(
+ new ProcessWindowsData(!attach_info.GetContinueOnceAttached()));
+
+ DebugDelegateSP delegate(new LocalDebugDelegate(shared_from_this()));
+ DebuggerThreadSP debugger(new DebuggerThread(delegate));
+
+ m_session_data->m_debugger = debugger;
+
+ DWORD process_id = static_cast<DWORD>(pid);
+ Error error = debugger->DebugAttach(process_id, attach_info);
+ if (error.Fail()) {
+ WINLOG_IFALL(WINDOWS_LOG_PROCESS, "DoAttachToProcessWithID encountered an "
+ "error occurred initiating the "
+ "asynchronous attach. %s",
+ error.AsCString());
+ return error;
+ }
- SetPrivateState(eStateRunning);
- }
- else
- {
- WINERR_IFALL(WINDOWS_LOG_PROCESS, "DoResume called for process %I64u but state is %u. Returning...",
- m_session_data->m_debugger->GetProcess().GetProcessId(), GetPrivateState());
- }
+ HostProcess process;
+ error = WaitForDebuggerConnection(debugger, process);
+ if (error.Fail()) {
+ WINLOG_IFALL(WINDOWS_LOG_PROCESS, "DoAttachToProcessWithID encountered an "
+ "error waiting for the debugger to "
+ "connect. %s",
+ error.AsCString());
return error;
-}
+ }
+ WINLOG_IFALL(
+ WINDOWS_LOG_PROCESS,
+ "DoAttachToProcessWithID successfully attached to process with pid=%u",
+ process_id);
+
+ // We've hit the initial stop. If eLaunchFlagsStopAtEntry was specified, the
+ // private state
+ // should already be set to eStateStopped as a result of hitting the initial
+ // breakpoint. If
+ // it was not set, the breakpoint should have already been resumed from and
+ // the private state
+ // should already be eStateRunning.
+ SetID(process.GetProcessId());
+ return error;
+}
+
+Error ProcessWindowsLive::WaitForDebuggerConnection(DebuggerThreadSP debugger,
+ HostProcess &process) {
+ Error result;
+ WINLOG_IFANY(WINDOWS_LOG_PROCESS | WINDOWS_LOG_BREAKPOINTS,
+ "WaitForDebuggerConnection Waiting for loader breakpoint.");
+
+ // Block this function until we receive the initial stop from the process.
+ if (::WaitForSingleObject(m_session_data->m_initial_stop_event, INFINITE) ==
+ WAIT_OBJECT_0) {
+ WINLOG_IFANY(WINDOWS_LOG_PROCESS | WINDOWS_LOG_BREAKPOINTS,
+ "WaitForDebuggerConnection hit loader breakpoint, returning.");
+
+ process = debugger->GetProcess();
+ return m_session_data->m_launch_error;
+ } else
+ return Error(::GetLastError(), eErrorTypeWin32);
+}
+
+Error ProcessWindowsLive::DoResume() {
+ llvm::sys::ScopedLock lock(m_mutex);
+ Error error;
+
+ StateType private_state = GetPrivateState();
+ if (private_state == eStateStopped || private_state == eStateCrashed) {
+ WINLOG_IFALL(
+ WINDOWS_LOG_PROCESS,
+ "DoResume called for process %I64u while state is %u. Resuming...",
+ m_session_data->m_debugger->GetProcess().GetProcessId(),
+ GetPrivateState());
+
+ ExceptionRecordSP active_exception =
+ m_session_data->m_debugger->GetActiveException().lock();
+ if (active_exception) {
+ // Resume the process and continue processing debug events. Mask
+ // the exception so that from the process's view, there is no
+ // indication that anything happened.
+ m_session_data->m_debugger->ContinueAsyncException(
+ ExceptionResult::MaskException);
+ }
+
+ WINLOG_IFANY(WINDOWS_LOG_PROCESS | WINDOWS_LOG_THREAD,
+ "DoResume resuming %u threads.", m_thread_list.GetSize());
+
+ for (int i = 0; i < m_thread_list.GetSize(); ++i) {
+ auto thread = std::static_pointer_cast<TargetThreadWindowsLive>(
+ m_thread_list.GetThreadAtIndex(i));
+ thread->DoResume();
+ }
+
+ SetPrivateState(eStateRunning);
+ } else {
+ WINERR_IFALL(
+ WINDOWS_LOG_PROCESS,
+ "DoResume called for process %I64u but state is %u. Returning...",
+ m_session_data->m_debugger->GetProcess().GetProcessId(),
+ GetPrivateState());
+ }
+ return error;
+}
//------------------------------------------------------------------------------
// ProcessInterface protocol.
-lldb_private::ConstString
-ProcessWindowsLive::GetPluginName()
-{
- return GetPluginNameStatic();
-}
-
-uint32_t
-ProcessWindowsLive::GetPluginVersion()
-{
- return 1;
-}
-
-Error
-ProcessWindowsLive::DoDetach(bool keep_stopped)
-{
- DebuggerThreadSP debugger_thread;
- StateType private_state;
- {
- // Acquire the lock only long enough to get the DebuggerThread.
- // StopDebugging() will trigger a call back into ProcessWindows which
- // will also acquire the lock. Thus we have to release the lock before
- // calling StopDebugging().
- llvm::sys::ScopedLock lock(m_mutex);
-
- private_state = GetPrivateState();
-
- if (!m_session_data)
- {
- WINWARN_IFALL(WINDOWS_LOG_PROCESS, "DoDetach called while state = %u, but there is no active session.",
- private_state);
- return Error();
- }
-
- debugger_thread = m_session_data->m_debugger;
- }
-
- Error error;
- if (private_state != eStateExited && private_state != eStateDetached)
- {
- WINLOG_IFALL(WINDOWS_LOG_PROCESS, "DoDetach called for process %I64u while state = %u. Detaching...",
- debugger_thread->GetProcess().GetNativeProcess().GetSystemHandle(), private_state);
- error = debugger_thread->StopDebugging(false);
- if (error.Success())
- {
- SetPrivateState(eStateDetached);
- }
-
- // By the time StopDebugging returns, there is no more debugger thread, so
- // we can be assured that no other thread will race for the session data.
- m_session_data.reset();
- }
- else
- {
- WINERR_IFALL(WINDOWS_LOG_PROCESS,
- "DoDetach called for process %I64u while state = %u, but cannot destroy in this state.",
- debugger_thread->GetProcess().GetNativeProcess().GetSystemHandle(), private_state);
- }
-
- return error;
-}
-
-Error
-ProcessWindowsLive::DoDestroy()
-{
- DebuggerThreadSP debugger_thread;
- StateType private_state;
- {
- // Acquire this lock inside an inner scope, only long enough to get the DebuggerThread.
- // StopDebugging() will trigger a call back into ProcessWindows which will acquire the lock
- // again, so we need to not deadlock.
- llvm::sys::ScopedLock lock(m_mutex);
-
- private_state = GetPrivateState();
-
- if (!m_session_data)
- {
- WINWARN_IFALL(WINDOWS_LOG_PROCESS, "DoDestroy called while state = %u, but there is no active session.",
- private_state);
- return Error();
- }
-
- debugger_thread = m_session_data->m_debugger;
- }
-
- Error error;
- if (private_state != eStateExited && private_state != eStateDetached)
- {
- WINLOG_IFALL(WINDOWS_LOG_PROCESS, "DoDestroy called for process %I64u while state = %u. Shutting down...",
- debugger_thread->GetProcess().GetNativeProcess().GetSystemHandle(), private_state);
- error = debugger_thread->StopDebugging(true);
-
- // By the time StopDebugging returns, there is no more debugger thread, so
- // we can be assured that no other thread will race for the session data.
- m_session_data.reset();
- }
- else
- {
- WINERR_IFALL(WINDOWS_LOG_PROCESS,
- "DoDestroy called for process %I64u while state = %u, but cannot destroy in this state.",
- debugger_thread->GetProcess().GetNativeProcess().GetSystemHandle(), private_state);
- }
-
- return error;
+lldb_private::ConstString ProcessWindowsLive::GetPluginName() {
+ return GetPluginNameStatic();
}
-void
-ProcessWindowsLive::RefreshStateAfterStop()
-{
- llvm::sys::ScopedLock lock(m_mutex);
-
- if (!m_session_data)
- {
- WINWARN_IFALL(WINDOWS_LOG_PROCESS, "RefreshStateAfterStop called with no active session. Returning...");
- return;
- }
+uint32_t ProcessWindowsLive::GetPluginVersion() { return 1; }
- m_thread_list.RefreshStateAfterStop();
-
- std::weak_ptr<ExceptionRecord> exception_record = m_session_data->m_debugger->GetActiveException();
- ExceptionRecordSP active_exception = exception_record.lock();
- if (!active_exception)
- {
- WINERR_IFALL(WINDOWS_LOG_PROCESS, "RefreshStateAfterStop called for process %I64u but there is no "
- "active exception. Why is the process stopped?",
- m_session_data->m_debugger->GetProcess().GetProcessId());
- return;
- }
-
- StopInfoSP stop_info;
- m_thread_list.SetSelectedThreadByID(active_exception->GetThreadID());
- ThreadSP stop_thread = m_thread_list.GetSelectedThread();
- if (!stop_thread)
- return;
-
- switch (active_exception->GetExceptionCode())
- {
- case EXCEPTION_SINGLE_STEP:
- {
- RegisterContextSP register_context = stop_thread->GetRegisterContext();
- const uint64_t pc = register_context->GetPC();
- BreakpointSiteSP site(GetBreakpointSiteList().FindByAddress(pc));
- if (site && site->ValidForThisThread(stop_thread.get()))
- {
- WINLOG_IFANY(WINDOWS_LOG_BREAKPOINTS | WINDOWS_LOG_EXCEPTION | WINDOWS_LOG_STEP,
- "Single-stepped onto a breakpoint in process %I64u at "
- "address 0x%I64x with breakpoint site %d",
- m_session_data->m_debugger->GetProcess().GetProcessId(), pc, site->GetID());
- stop_info = StopInfo::CreateStopReasonWithBreakpointSiteID(*stop_thread, site->GetID());
- stop_thread->SetStopInfo(stop_info);
- }
- else
- {
- WINLOG_IFANY(WINDOWS_LOG_EXCEPTION | WINDOWS_LOG_STEP,
- "RefreshStateAfterStop single stepping thread %u", stop_thread->GetID());
- stop_info = StopInfo::CreateStopReasonToTrace(*stop_thread);
- stop_thread->SetStopInfo(stop_info);
- }
- return;
- }
-
- case EXCEPTION_BREAKPOINT:
- {
- RegisterContextSP register_context = stop_thread->GetRegisterContext();
-
- // The current EIP is AFTER the BP opcode, which is one byte.
- uint64_t pc = register_context->GetPC() - 1;
-
- BreakpointSiteSP site(GetBreakpointSiteList().FindByAddress(pc));
- if (site)
- {
- WINLOG_IFANY(WINDOWS_LOG_BREAKPOINTS | WINDOWS_LOG_EXCEPTION,
- "RefreshStateAfterStop detected breakpoint in process %I64u at "
- "address 0x%I64x with breakpoint site %d",
- m_session_data->m_debugger->GetProcess().GetProcessId(), pc, site->GetID());
-
- if (site->ValidForThisThread(stop_thread.get()))
- {
- WINLOG_IFALL(WINDOWS_LOG_BREAKPOINTS | WINDOWS_LOG_EXCEPTION,
- "Breakpoint site %d is valid for this thread (0x%I64x), creating stop info.",
- site->GetID(), stop_thread->GetID());
-
- stop_info = StopInfo::CreateStopReasonWithBreakpointSiteID(
- *stop_thread, site->GetID());
- register_context->SetPC(pc);
- }
- else
- {
- WINLOG_IFALL(WINDOWS_LOG_BREAKPOINTS | WINDOWS_LOG_EXCEPTION,
- "Breakpoint site %d is not valid for this thread, creating empty stop info.",
- site->GetID());
- }
- stop_thread->SetStopInfo(stop_info);
- return;
- }
- else
- {
- // The thread hit a hard-coded breakpoint like an `int 3` or `__debugbreak()`.
- WINLOG_IFALL(WINDOWS_LOG_BREAKPOINTS | WINDOWS_LOG_EXCEPTION,
- "No breakpoint site matches for this thread. __debugbreak()? "
- "Creating stop info with the exception.");
- // FALLTHROUGH: We'll treat this as a generic exception record in the default case.
- }
- }
-
- default:
- {
- std::string desc;
- llvm::raw_string_ostream desc_stream(desc);
- desc_stream << "Exception " << llvm::format_hex(active_exception->GetExceptionCode(), 8)
- << " encountered at address "
- << llvm::format_hex(active_exception->GetExceptionAddress(), 8);
- stop_info = StopInfo::CreateStopReasonWithException(*stop_thread, desc_stream.str().c_str());
- stop_thread->SetStopInfo(stop_info);
- WINLOG_IFALL(WINDOWS_LOG_EXCEPTION, desc_stream.str().c_str());
- return;
- }
- }
-}
-
-bool
-ProcessWindowsLive::IsAlive()
-{
- StateType state = GetPrivateState();
- switch (state)
- {
- case eStateCrashed:
- case eStateDetached:
- case eStateUnloaded:
- case eStateExited:
- case eStateInvalid:
- return false;
- default:
- return true;
- }
+Error ProcessWindowsLive::DoDetach(bool keep_stopped) {
+ DebuggerThreadSP debugger_thread;
+ StateType private_state;
+ {
+ // Acquire the lock only long enough to get the DebuggerThread.
+ // StopDebugging() will trigger a call back into ProcessWindows which
+ // will also acquire the lock. Thus we have to release the lock before
+ // calling StopDebugging().
+ llvm::sys::ScopedLock lock(m_mutex);
+
+ private_state = GetPrivateState();
+
+ if (!m_session_data) {
+ WINWARN_IFALL(
+ WINDOWS_LOG_PROCESS,
+ "DoDetach called while state = %u, but there is no active session.",
+ private_state);
+ return Error();
+ }
+
+ debugger_thread = m_session_data->m_debugger;
+ }
+
+ Error error;
+ if (private_state != eStateExited && private_state != eStateDetached) {
+ WINLOG_IFALL(
+ WINDOWS_LOG_PROCESS,
+ "DoDetach called for process %I64u while state = %u. Detaching...",
+ debugger_thread->GetProcess().GetNativeProcess().GetSystemHandle(),
+ private_state);
+ error = debugger_thread->StopDebugging(false);
+ if (error.Success()) {
+ SetPrivateState(eStateDetached);
+ }
+
+ // By the time StopDebugging returns, there is no more debugger thread, so
+ // we can be assured that no other thread will race for the session data.
+ m_session_data.reset();
+ } else {
+ WINERR_IFALL(
+ WINDOWS_LOG_PROCESS, "DoDetach called for process %I64u while state = "
+ "%u, but cannot destroy in this state.",
+ debugger_thread->GetProcess().GetNativeProcess().GetSystemHandle(),
+ private_state);
+ }
+
+ return error;
+}
+
+Error ProcessWindowsLive::DoDestroy() {
+ DebuggerThreadSP debugger_thread;
+ StateType private_state;
+ {
+ // Acquire this lock inside an inner scope, only long enough to get the
+ // DebuggerThread.
+ // StopDebugging() will trigger a call back into ProcessWindows which will
+ // acquire the lock
+ // again, so we need to not deadlock.
+ llvm::sys::ScopedLock lock(m_mutex);
+
+ private_state = GetPrivateState();
+
+ if (!m_session_data) {
+ WINWARN_IFALL(
+ WINDOWS_LOG_PROCESS,
+ "DoDestroy called while state = %u, but there is no active session.",
+ private_state);
+ return Error();
+ }
+
+ debugger_thread = m_session_data->m_debugger;
+ }
+
+ Error error;
+ if (private_state != eStateExited && private_state != eStateDetached) {
+ WINLOG_IFALL(
+ WINDOWS_LOG_PROCESS, "DoDestroy called for process %I64u while state = "
+ "%u. Shutting down...",
+ debugger_thread->GetProcess().GetNativeProcess().GetSystemHandle(),
+ private_state);
+ error = debugger_thread->StopDebugging(true);
+
+ // By the time StopDebugging returns, there is no more debugger thread, so
+ // we can be assured that no other thread will race for the session data.
+ m_session_data.reset();
+ } else {
+ WINERR_IFALL(
+ WINDOWS_LOG_PROCESS, "DoDestroy called for process %I64u while state = "
+ "%u, but cannot destroy in this state.",
+ debugger_thread->GetProcess().GetNativeProcess().GetSystemHandle(),
+ private_state);
+ }
+
+ return error;
+}
+
+void ProcessWindowsLive::RefreshStateAfterStop() {
+ llvm::sys::ScopedLock lock(m_mutex);
+
+ if (!m_session_data) {
+ WINWARN_IFALL(
+ WINDOWS_LOG_PROCESS,
+ "RefreshStateAfterStop called with no active session. Returning...");
+ return;
+ }
+
+ m_thread_list.RefreshStateAfterStop();
+
+ std::weak_ptr<ExceptionRecord> exception_record =
+ m_session_data->m_debugger->GetActiveException();
+ ExceptionRecordSP active_exception = exception_record.lock();
+ if (!active_exception) {
+ WINERR_IFALL(
+ WINDOWS_LOG_PROCESS,
+ "RefreshStateAfterStop called for process %I64u but there is no "
+ "active exception. Why is the process stopped?",
+ m_session_data->m_debugger->GetProcess().GetProcessId());
+ return;
+ }
+
+ StopInfoSP stop_info;
+ m_thread_list.SetSelectedThreadByID(active_exception->GetThreadID());
+ ThreadSP stop_thread = m_thread_list.GetSelectedThread();
+ if (!stop_thread)
+ return;
+
+ switch (active_exception->GetExceptionCode()) {
+ case EXCEPTION_SINGLE_STEP: {
+ RegisterContextSP register_context = stop_thread->GetRegisterContext();
+ const uint64_t pc = register_context->GetPC();
+ BreakpointSiteSP site(GetBreakpointSiteList().FindByAddress(pc));
+ if (site && site->ValidForThisThread(stop_thread.get())) {
+ WINLOG_IFANY(WINDOWS_LOG_BREAKPOINTS | WINDOWS_LOG_EXCEPTION |
+ WINDOWS_LOG_STEP,
+ "Single-stepped onto a breakpoint in process %I64u at "
+ "address 0x%I64x with breakpoint site %d",
+ m_session_data->m_debugger->GetProcess().GetProcessId(), pc,
+ site->GetID());
+ stop_info = StopInfo::CreateStopReasonWithBreakpointSiteID(*stop_thread,
+ site->GetID());
+ stop_thread->SetStopInfo(stop_info);
+ } else {
+ WINLOG_IFANY(WINDOWS_LOG_EXCEPTION | WINDOWS_LOG_STEP,
+ "RefreshStateAfterStop single stepping thread %u",
+ stop_thread->GetID());
+ stop_info = StopInfo::CreateStopReasonToTrace(*stop_thread);
+ stop_thread->SetStopInfo(stop_info);
+ }
+ return;
+ }
+
+ case EXCEPTION_BREAKPOINT: {
+ RegisterContextSP register_context = stop_thread->GetRegisterContext();
+
+ // The current EIP is AFTER the BP opcode, which is one byte.
+ uint64_t pc = register_context->GetPC() - 1;
+
+ BreakpointSiteSP site(GetBreakpointSiteList().FindByAddress(pc));
+ if (site) {
+ WINLOG_IFANY(
+ WINDOWS_LOG_BREAKPOINTS | WINDOWS_LOG_EXCEPTION,
+ "RefreshStateAfterStop detected breakpoint in process %I64u at "
+ "address 0x%I64x with breakpoint site %d",
+ m_session_data->m_debugger->GetProcess().GetProcessId(), pc,
+ site->GetID());
+
+ if (site->ValidForThisThread(stop_thread.get())) {
+ WINLOG_IFALL(WINDOWS_LOG_BREAKPOINTS | WINDOWS_LOG_EXCEPTION,
+ "Breakpoint site %d is valid for this thread (0x%I64x), "
+ "creating stop info.",
+ site->GetID(), stop_thread->GetID());
+
+ stop_info = StopInfo::CreateStopReasonWithBreakpointSiteID(
+ *stop_thread, site->GetID());
+ register_context->SetPC(pc);
+ } else {
+ WINLOG_IFALL(WINDOWS_LOG_BREAKPOINTS | WINDOWS_LOG_EXCEPTION,
+ "Breakpoint site %d is not valid for this thread, "
+ "creating empty stop info.",
+ site->GetID());
+ }
+ stop_thread->SetStopInfo(stop_info);
+ return;
+ } else {
+ // The thread hit a hard-coded breakpoint like an `int 3` or
+ // `__debugbreak()`.
+ WINLOG_IFALL(
+ WINDOWS_LOG_BREAKPOINTS | WINDOWS_LOG_EXCEPTION,
+ "No breakpoint site matches for this thread. __debugbreak()? "
+ "Creating stop info with the exception.");
+ // FALLTHROUGH: We'll treat this as a generic exception record in the
+ // default case.
+ }
+ }
+
+ default: {
+ std::string desc;
+ llvm::raw_string_ostream desc_stream(desc);
+ desc_stream << "Exception "
+ << llvm::format_hex(active_exception->GetExceptionCode(), 8)
+ << " encountered at address "
+ << llvm::format_hex(active_exception->GetExceptionAddress(), 8);
+ stop_info = StopInfo::CreateStopReasonWithException(
+ *stop_thread, desc_stream.str().c_str());
+ stop_thread->SetStopInfo(stop_info);
+ WINLOG_IFALL(WINDOWS_LOG_EXCEPTION, desc_stream.str().c_str());
+ return;
+ }
+ }
+}
+
+bool ProcessWindowsLive::IsAlive() {
+ StateType state = GetPrivateState();
+ switch (state) {
+ case eStateCrashed:
+ case eStateDetached:
+ case eStateUnloaded:
+ case eStateExited:
+ case eStateInvalid:
+ return false;
+ default:
+ return true;
+ }
}
-Error
-ProcessWindowsLive::DoHalt(bool &caused_stop)
-{
- Error error;
- StateType state = GetPrivateState();
- if (state == eStateStopped)
- caused_stop = false;
- else
- {
- llvm::sys::ScopedLock lock(m_mutex);
- caused_stop = ::DebugBreakProcess(m_session_data->m_debugger->GetProcess().GetNativeProcess().GetSystemHandle());
- if (!caused_stop)
- {
- error.SetError(::GetLastError(), eErrorTypeWin32);
- WINERR_IFALL(WINDOWS_LOG_PROCESS, "DoHalt called DebugBreakProcess, but it failed with error %u",
- error.GetError());
- }
- }
+Error ProcessWindowsLive::DoHalt(bool &caused_stop) {
+ Error error;
+ StateType state = GetPrivateState();
+ if (state == eStateStopped)
+ caused_stop = false;
+ else {
+ llvm::sys::ScopedLock lock(m_mutex);
+ caused_stop = ::DebugBreakProcess(m_session_data->m_debugger->GetProcess()
+ .GetNativeProcess()
+ .GetSystemHandle());
+ if (!caused_stop) {
+ error.SetError(::GetLastError(), eErrorTypeWin32);
+ WINERR_IFALL(
+ WINDOWS_LOG_PROCESS,
+ "DoHalt called DebugBreakProcess, but it failed with error %u",
+ error.GetError());
+ }
+ }
+ return error;
+}
+
+void ProcessWindowsLive::DidLaunch() {
+ ArchSpec arch_spec;
+ DidAttach(arch_spec);
+}
+
+void ProcessWindowsLive::DidAttach(ArchSpec &arch_spec) {
+ llvm::sys::ScopedLock lock(m_mutex);
+
+ // The initial stop won't broadcast the state change event, so account for
+ // that here.
+ if (m_session_data && GetPrivateState() == eStateStopped &&
+ m_session_data->m_stop_at_entry)
+ RefreshStateAfterStop();
+}
+
+size_t ProcessWindowsLive::DoReadMemory(lldb::addr_t vm_addr, void *buf,
+ size_t size, Error &error) {
+ llvm::sys::ScopedLock lock(m_mutex);
+
+ if (!m_session_data)
+ return 0;
+
+ WINLOG_IFALL(WINDOWS_LOG_MEMORY,
+ "DoReadMemory attempting to read %u bytes from address 0x%I64x",
+ size, vm_addr);
+
+ HostProcess process = m_session_data->m_debugger->GetProcess();
+ void *addr = reinterpret_cast<void *>(vm_addr);
+ SIZE_T bytes_read = 0;
+ if (!ReadProcessMemory(process.GetNativeProcess().GetSystemHandle(), addr,
+ buf, size, &bytes_read)) {
+ error.SetError(GetLastError(), eErrorTypeWin32);
+ WINERR_IFALL(WINDOWS_LOG_MEMORY, "DoReadMemory failed with error code %u",
+ error.GetError());
+ }
+ return bytes_read;
+}
+
+size_t ProcessWindowsLive::DoWriteMemory(lldb::addr_t vm_addr, const void *buf,
+ size_t size, Error &error) {
+ llvm::sys::ScopedLock lock(m_mutex);
+ WINLOG_IFALL(
+ WINDOWS_LOG_MEMORY,
+ "DoWriteMemory attempting to write %u bytes into address 0x%I64x", size,
+ vm_addr);
+
+ if (!m_session_data) {
+ WINERR_IFANY(
+ WINDOWS_LOG_MEMORY,
+ "DoWriteMemory cannot write, there is no active debugger connection.");
+ return 0;
+ }
+
+ HostProcess process = m_session_data->m_debugger->GetProcess();
+ void *addr = reinterpret_cast<void *>(vm_addr);
+ SIZE_T bytes_written = 0;
+ lldb::process_t handle = process.GetNativeProcess().GetSystemHandle();
+ if (WriteProcessMemory(handle, addr, buf, size, &bytes_written))
+ FlushInstructionCache(handle, addr, bytes_written);
+ else {
+ error.SetError(GetLastError(), eErrorTypeWin32);
+ WINLOG_IFALL(WINDOWS_LOG_MEMORY, "DoWriteMemory failed with error code %u",
+ error.GetError());
+ }
+ return bytes_written;
+}
+
+Error ProcessWindowsLive::GetMemoryRegionInfo(lldb::addr_t vm_addr,
+ MemoryRegionInfo &info) {
+ Error error;
+ llvm::sys::ScopedLock lock(m_mutex);
+ info.Clear();
+
+ if (!m_session_data) {
+ error.SetErrorString(
+ "GetMemoryRegionInfo called with no debugging session.");
+ WINERR_IFALL(WINDOWS_LOG_MEMORY, error.AsCString());
return error;
-}
-
-void
-ProcessWindowsLive::DidLaunch()
-{
- ArchSpec arch_spec;
- DidAttach(arch_spec);
-}
-
-void
-ProcessWindowsLive::DidAttach(ArchSpec &arch_spec)
-{
- llvm::sys::ScopedLock lock(m_mutex);
-
- // The initial stop won't broadcast the state change event, so account for that here.
- if (m_session_data && GetPrivateState() == eStateStopped && m_session_data->m_stop_at_entry)
- RefreshStateAfterStop();
-}
-
-size_t
-ProcessWindowsLive::DoReadMemory(lldb::addr_t vm_addr,
- void *buf,
- size_t size,
- Error &error)
-{
- llvm::sys::ScopedLock lock(m_mutex);
-
- if (!m_session_data)
- return 0;
-
- WINLOG_IFALL(WINDOWS_LOG_MEMORY, "DoReadMemory attempting to read %u bytes from address 0x%I64x", size, vm_addr);
-
- HostProcess process = m_session_data->m_debugger->GetProcess();
- void *addr = reinterpret_cast<void *>(vm_addr);
- SIZE_T bytes_read = 0;
- if (!ReadProcessMemory(process.GetNativeProcess().GetSystemHandle(), addr, buf, size, &bytes_read))
- {
- error.SetError(GetLastError(), eErrorTypeWin32);
- WINERR_IFALL(WINDOWS_LOG_MEMORY, "DoReadMemory failed with error code %u", error.GetError());
- }
- return bytes_read;
-}
-
-size_t
-ProcessWindowsLive::DoWriteMemory(lldb::addr_t vm_addr, const void *buf, size_t size, Error &error)
-{
- llvm::sys::ScopedLock lock(m_mutex);
- WINLOG_IFALL(WINDOWS_LOG_MEMORY, "DoWriteMemory attempting to write %u bytes into address 0x%I64x", size, vm_addr);
-
- if (!m_session_data)
- {
- WINERR_IFANY(WINDOWS_LOG_MEMORY, "DoWriteMemory cannot write, there is no active debugger connection.");
- return 0;
- }
-
- HostProcess process = m_session_data->m_debugger->GetProcess();
- void *addr = reinterpret_cast<void *>(vm_addr);
- SIZE_T bytes_written = 0;
- lldb::process_t handle = process.GetNativeProcess().GetSystemHandle();
- if (WriteProcessMemory(handle, addr, buf, size, &bytes_written))
- FlushInstructionCache(handle, addr, bytes_written);
- else
- {
- error.SetError(GetLastError(), eErrorTypeWin32);
- WINLOG_IFALL(WINDOWS_LOG_MEMORY, "DoWriteMemory failed with error code %u", error.GetError());
- }
- return bytes_written;
-}
-
-Error
-ProcessWindowsLive::GetMemoryRegionInfo(lldb::addr_t vm_addr, MemoryRegionInfo &info)
-{
- Error error;
- llvm::sys::ScopedLock lock(m_mutex);
- info.Clear();
-
- if (!m_session_data)
- {
- error.SetErrorString("GetMemoryRegionInfo called with no debugging session.");
- WINERR_IFALL(WINDOWS_LOG_MEMORY, error.AsCString());
- return error;
- }
- HostProcess process = m_session_data->m_debugger->GetProcess();
- lldb::process_t handle = process.GetNativeProcess().GetSystemHandle();
- if (handle == nullptr || handle == LLDB_INVALID_PROCESS)
- {
- error.SetErrorString("GetMemoryRegionInfo called with an invalid target process.");
- WINERR_IFALL(WINDOWS_LOG_MEMORY, error.AsCString());
- return error;
- }
-
- WINLOG_IFALL(WINDOWS_LOG_MEMORY, "GetMemoryRegionInfo getting info for address 0x%I64x", vm_addr);
-
- void *addr = reinterpret_cast<void *>(vm_addr);
- MEMORY_BASIC_INFORMATION mem_info = {0};
- SIZE_T result = ::VirtualQueryEx(handle, addr, &mem_info, sizeof(mem_info));
- if (result == 0)
- {
- if (::GetLastError() == ERROR_INVALID_PARAMETER)
- {
- // ERROR_INVALID_PARAMETER is returned if VirtualQueryEx is called with an address
- // past the highest accessible address. We should return a range from the vm_addr
- // to LLDB_INVALID_ADDRESS
- info.GetRange().SetRangeBase(vm_addr);
- info.GetRange().SetRangeEnd(LLDB_INVALID_ADDRESS);
- info.SetReadable(MemoryRegionInfo::eNo);
- info.SetExecutable(MemoryRegionInfo::eNo);
- info.SetWritable(MemoryRegionInfo::eNo);
- info.SetMapped(MemoryRegionInfo::eNo);
- return error;
- }
- else
- {
- error.SetError(::GetLastError(), eErrorTypeWin32);
- WINERR_IFALL(WINDOWS_LOG_MEMORY,
- "VirtualQueryEx returned error %u while getting memory region info for address 0x%I64x",
- error.GetError(), vm_addr);
- return error;
- }
- }
-
- // Protect bits are only valid for MEM_COMMIT regions.
- if (mem_info.State == MEM_COMMIT) {
- const bool readable = IsPageReadable(mem_info.Protect);
- const bool executable = IsPageExecutable(mem_info.Protect);
- const bool writable = IsPageWritable(mem_info.Protect);
- info.SetReadable(readable ? MemoryRegionInfo::eYes : MemoryRegionInfo::eNo);
- info.SetExecutable(executable ? MemoryRegionInfo::eYes : MemoryRegionInfo::eNo);
- info.SetWritable(writable ? MemoryRegionInfo::eYes : MemoryRegionInfo::eNo);
- }
- else
- {
- info.SetReadable(MemoryRegionInfo::eNo);
- info.SetExecutable(MemoryRegionInfo::eNo);
- info.SetWritable(MemoryRegionInfo::eNo);
- }
-
- // AllocationBase is defined for MEM_COMMIT and MEM_RESERVE but not MEM_FREE.
- if (mem_info.State != MEM_FREE) {
- info.GetRange().SetRangeBase(reinterpret_cast<addr_t>(mem_info.AllocationBase));
- info.GetRange().SetRangeEnd(reinterpret_cast<addr_t>(mem_info.BaseAddress) + mem_info.RegionSize);
- info.SetMapped(MemoryRegionInfo::eYes);
- }
- else
- {
- // In the unmapped case we need to return the distance to the next block of memory.
- // VirtualQueryEx nearly does that except that it gives the distance from the start
- // of the page containing vm_addr.
- SYSTEM_INFO data;
- GetSystemInfo(&data);
- DWORD page_offset = vm_addr % data.dwPageSize;
- info.GetRange().SetRangeBase(vm_addr);
- info.GetRange().SetByteSize(mem_info.RegionSize - page_offset);
- info.SetMapped(MemoryRegionInfo::eNo);
- }
-
- error.SetError(::GetLastError(), eErrorTypeWin32);
- WINLOGV_IFALL(WINDOWS_LOG_MEMORY, "Memory region info for address 0x%I64u: readable=%s, executable=%s, writable=%s",
- BOOL_STR(info.GetReadable()), BOOL_STR(info.GetExecutable()), BOOL_STR(info.GetWritable()));
+ }
+ HostProcess process = m_session_data->m_debugger->GetProcess();
+ lldb::process_t handle = process.GetNativeProcess().GetSystemHandle();
+ if (handle == nullptr || handle == LLDB_INVALID_PROCESS) {
+ error.SetErrorString(
+ "GetMemoryRegionInfo called with an invalid target process.");
+ WINERR_IFALL(WINDOWS_LOG_MEMORY, error.AsCString());
return error;
-}
-
-bool
-ProcessWindowsLive::CanDebug(lldb::TargetSP target_sp, bool plugin_specified_by_name)
-{
- if (plugin_specified_by_name)
- return true;
-
- // For now we are just making sure the file exists for a given module
- ModuleSP exe_module_sp(target_sp->GetExecutableModule());
- if (exe_module_sp.get())
- return exe_module_sp->GetFileSpec().Exists();
- // However, if there is no executable module, we return true since we might be preparing to attach.
- return true;
-}
+ }
-void
-ProcessWindowsLive::OnExitProcess(uint32_t exit_code)
-{
- // No need to acquire the lock since m_session_data isn't accessed.
- WINLOG_IFALL(WINDOWS_LOG_PROCESS, "Process %u exited with code %u", GetID(), exit_code);
-
- TargetSP target = m_target_sp.lock();
- if (target)
- {
- ModuleSP executable_module = target->GetExecutableModule();
- ModuleList unloaded_modules;
- unloaded_modules.Append(executable_module);
- target->ModulesDidUnload(unloaded_modules, true);
- }
-
- SetProcessExitStatus(GetID(), true, 0, exit_code);
- SetPrivateState(eStateExited);
-}
+ WINLOG_IFALL(WINDOWS_LOG_MEMORY,
+ "GetMemoryRegionInfo getting info for address 0x%I64x", vm_addr);
-void
-ProcessWindowsLive::OnDebuggerConnected(lldb::addr_t image_base)
-{
- DebuggerThreadSP debugger = m_session_data->m_debugger;
-
- WINLOG_IFALL(WINDOWS_LOG_PROCESS, "Debugger connected to process %I64u. Image base = 0x%I64x",
- debugger->GetProcess().GetProcessId(), image_base);
-
- ModuleSP module = GetTarget().GetExecutableModule();
- if (!module)
- {
- // During attach, we won't have the executable module, so find it now.
- const DWORD pid = debugger->GetProcess().GetProcessId();
- const std::string file_name = GetProcessExecutableName(pid);
- if (file_name.empty())
- {
- return;
- }
-
- FileSpec executable_file(file_name, true);
- ModuleSpec module_spec(executable_file);
- Error error;
- module = GetTarget().GetSharedModule(module_spec, &error);
- if (!module)
- {
- return;
- }
+ void *addr = reinterpret_cast<void *>(vm_addr);
+ MEMORY_BASIC_INFORMATION mem_info = {0};
+ SIZE_T result = ::VirtualQueryEx(handle, addr, &mem_info, sizeof(mem_info));
+ if (result == 0) {
+ if (::GetLastError() == ERROR_INVALID_PARAMETER) {
+ // ERROR_INVALID_PARAMETER is returned if VirtualQueryEx is called with an
+ // address
+ // past the highest accessible address. We should return a range from the
+ // vm_addr
+ // to LLDB_INVALID_ADDRESS
+ info.GetRange().SetRangeBase(vm_addr);
+ info.GetRange().SetRangeEnd(LLDB_INVALID_ADDRESS);
+ info.SetReadable(MemoryRegionInfo::eNo);
+ info.SetExecutable(MemoryRegionInfo::eNo);
+ info.SetWritable(MemoryRegionInfo::eNo);
+ info.SetMapped(MemoryRegionInfo::eNo);
+ return error;
+ } else {
+ error.SetError(::GetLastError(), eErrorTypeWin32);
+ WINERR_IFALL(WINDOWS_LOG_MEMORY, "VirtualQueryEx returned error %u while "
+ "getting memory region info for address "
+ "0x%I64x",
+ error.GetError(), vm_addr);
+ return error;
+ }
+ }
+
+ // Protect bits are only valid for MEM_COMMIT regions.
+ if (mem_info.State == MEM_COMMIT) {
+ const bool readable = IsPageReadable(mem_info.Protect);
+ const bool executable = IsPageExecutable(mem_info.Protect);
+ const bool writable = IsPageWritable(mem_info.Protect);
+ info.SetReadable(readable ? MemoryRegionInfo::eYes : MemoryRegionInfo::eNo);
+ info.SetExecutable(executable ? MemoryRegionInfo::eYes
+ : MemoryRegionInfo::eNo);
+ info.SetWritable(writable ? MemoryRegionInfo::eYes : MemoryRegionInfo::eNo);
+ } else {
+ info.SetReadable(MemoryRegionInfo::eNo);
+ info.SetExecutable(MemoryRegionInfo::eNo);
+ info.SetWritable(MemoryRegionInfo::eNo);
+ }
+
+ // AllocationBase is defined for MEM_COMMIT and MEM_RESERVE but not MEM_FREE.
+ if (mem_info.State != MEM_FREE) {
+ info.GetRange().SetRangeBase(
+ reinterpret_cast<addr_t>(mem_info.AllocationBase));
+ info.GetRange().SetRangeEnd(reinterpret_cast<addr_t>(mem_info.BaseAddress) +
+ mem_info.RegionSize);
+ info.SetMapped(MemoryRegionInfo::eYes);
+ } else {
+ // In the unmapped case we need to return the distance to the next block of
+ // memory.
+ // VirtualQueryEx nearly does that except that it gives the distance from
+ // the start
+ // of the page containing vm_addr.
+ SYSTEM_INFO data;
+ GetSystemInfo(&data);
+ DWORD page_offset = vm_addr % data.dwPageSize;
+ info.GetRange().SetRangeBase(vm_addr);
+ info.GetRange().SetByteSize(mem_info.RegionSize - page_offset);
+ info.SetMapped(MemoryRegionInfo::eNo);
+ }
+
+ error.SetError(::GetLastError(), eErrorTypeWin32);
+ WINLOGV_IFALL(WINDOWS_LOG_MEMORY, "Memory region info for address 0x%I64u: "
+ "readable=%s, executable=%s, writable=%s",
+ BOOL_STR(info.GetReadable()), BOOL_STR(info.GetExecutable()),
+ BOOL_STR(info.GetWritable()));
+ return error;
+}
+
+bool ProcessWindowsLive::CanDebug(lldb::TargetSP target_sp,
+ bool plugin_specified_by_name) {
+ if (plugin_specified_by_name)
+ return true;
- GetTarget().SetExecutableModule(module, false);
+ // For now we are just making sure the file exists for a given module
+ ModuleSP exe_module_sp(target_sp->GetExecutableModule());
+ if (exe_module_sp.get())
+ return exe_module_sp->GetFileSpec().Exists();
+ // However, if there is no executable module, we return true since we might be
+ // preparing to attach.
+ return true;
+}
+
+void ProcessWindowsLive::OnExitProcess(uint32_t exit_code) {
+ // No need to acquire the lock since m_session_data isn't accessed.
+ WINLOG_IFALL(WINDOWS_LOG_PROCESS, "Process %u exited with code %u", GetID(),
+ exit_code);
+
+ TargetSP target = m_target_sp.lock();
+ if (target) {
+ ModuleSP executable_module = target->GetExecutableModule();
+ ModuleList unloaded_modules;
+ unloaded_modules.Append(executable_module);
+ target->ModulesDidUnload(unloaded_modules, true);
+ }
+
+ SetProcessExitStatus(GetID(), true, 0, exit_code);
+ SetPrivateState(eStateExited);
+}
+
+void ProcessWindowsLive::OnDebuggerConnected(lldb::addr_t image_base) {
+ DebuggerThreadSP debugger = m_session_data->m_debugger;
+
+ WINLOG_IFALL(WINDOWS_LOG_PROCESS,
+ "Debugger connected to process %I64u. Image base = 0x%I64x",
+ debugger->GetProcess().GetProcessId(), image_base);
+
+ ModuleSP module = GetTarget().GetExecutableModule();
+ if (!module) {
+ // During attach, we won't have the executable module, so find it now.
+ const DWORD pid = debugger->GetProcess().GetProcessId();
+ const std::string file_name = GetProcessExecutableName(pid);
+ if (file_name.empty()) {
+ return;
}
- bool load_addr_changed;
- module->SetLoadAddress(GetTarget(), image_base, false, load_addr_changed);
-
- ModuleList loaded_modules;
- loaded_modules.Append(module);
- GetTarget().ModulesDidLoad(loaded_modules);
-
- // Add the main executable module to the list of pending module loads. We can't call
- // GetTarget().ModulesDidLoad() here because we still haven't returned from DoLaunch() / DoAttach() yet
- // so the target may not have set the process instance to `this` yet.
- llvm::sys::ScopedLock lock(m_mutex);
- const HostThreadWindows &wmain_thread = debugger->GetMainThread().GetNativeThread();
- m_session_data->m_new_threads[wmain_thread.GetThreadId()] = debugger->GetMainThread();
+ FileSpec executable_file(file_name, true);
+ ModuleSpec module_spec(executable_file);
+ Error error;
+ module = GetTarget().GetSharedModule(module_spec, &error);
+ if (!module) {
+ return;
+ }
+
+ GetTarget().SetExecutableModule(module, false);
+ }
+
+ bool load_addr_changed;
+ module->SetLoadAddress(GetTarget(), image_base, false, load_addr_changed);
+
+ ModuleList loaded_modules;
+ loaded_modules.Append(module);
+ GetTarget().ModulesDidLoad(loaded_modules);
+
+ // Add the main executable module to the list of pending module loads. We
+ // can't call
+ // GetTarget().ModulesDidLoad() here because we still haven't returned from
+ // DoLaunch() / DoAttach() yet
+ // so the target may not have set the process instance to `this` yet.
+ llvm::sys::ScopedLock lock(m_mutex);
+ const HostThreadWindows &wmain_thread =
+ debugger->GetMainThread().GetNativeThread();
+ m_session_data->m_new_threads[wmain_thread.GetThreadId()] =
+ debugger->GetMainThread();
}
ExceptionResult
-ProcessWindowsLive::OnDebugException(bool first_chance, const ExceptionRecord &record)
-{
- llvm::sys::ScopedLock lock(m_mutex);
-
- // FIXME: Without this check, occasionally when running the test suite there is
- // an issue where m_session_data can be null. It's not clear how this could happen
- // but it only surfaces while running the test suite. In order to properly diagnose
- // this, we probably need to first figure allow the test suite to print out full
- // lldb logs, and then add logging to the process plugin.
- if (!m_session_data)
- {
- WINERR_IFANY(WINDOWS_LOG_EXCEPTION,
- "Debugger thread reported exception 0x%x at address 0x%I64x, but there is no session.",
- record.GetExceptionCode(), record.GetExceptionAddress());
- return ExceptionResult::SendToApplication;
- }
-
- if (!first_chance)
- {
- // Any second chance exception is an application crash by definition.
- SetPrivateState(eStateCrashed);
- }
-
- ExceptionResult result = ExceptionResult::SendToApplication;
- switch (record.GetExceptionCode())
- {
- case EXCEPTION_BREAKPOINT:
- // Handle breakpoints at the first chance.
- result = ExceptionResult::BreakInDebugger;
-
- if (!m_session_data->m_initial_stop_received)
- {
- WINLOG_IFANY(WINDOWS_LOG_BREAKPOINTS,
- "Hit loader breakpoint at address 0x%I64x, setting initial stop event.",
- record.GetExceptionAddress());
- m_session_data->m_initial_stop_received = true;
- ::SetEvent(m_session_data->m_initial_stop_event);
- }
- else
- {
- WINLOG_IFANY(WINDOWS_LOG_BREAKPOINTS,
- "Hit non-loader breakpoint at address 0x%I64x.",
- record.GetExceptionAddress());
- }
- SetPrivateState(eStateStopped);
- break;
- case EXCEPTION_SINGLE_STEP:
- result = ExceptionResult::BreakInDebugger;
- SetPrivateState(eStateStopped);
- break;
- default:
- WINLOG_IFANY(WINDOWS_LOG_EXCEPTION,
- "Debugger thread reported exception 0x%x at address 0x%I64x (first_chance=%s)",
- record.GetExceptionCode(), record.GetExceptionAddress(), BOOL_STR(first_chance));
- // For non-breakpoints, give the application a chance to handle the exception first.
- if (first_chance)
- result = ExceptionResult::SendToApplication;
- else
- result = ExceptionResult::BreakInDebugger;
- }
-
- return result;
-}
-
-void
-ProcessWindowsLive::OnCreateThread(const HostThread &new_thread)
-{
- llvm::sys::ScopedLock lock(m_mutex);
- const HostThreadWindows &wnew_thread = new_thread.GetNativeThread();
- m_session_data->m_new_threads[wnew_thread.GetThreadId()] = new_thread;
-}
-
-void
-ProcessWindowsLive::OnExitThread(lldb::tid_t thread_id, uint32_t exit_code)
-{
- llvm::sys::ScopedLock lock(m_mutex);
-
- // On a forced termination, we may get exit thread events after the session
- // data has been cleaned up.
- if (!m_session_data)
- return;
-
- // A thread may have started and exited before the debugger stopped allowing a refresh.
- // Just remove it from the new threads list in that case.
- auto iter = m_session_data->m_new_threads.find(thread_id);
- if (iter != m_session_data->m_new_threads.end())
- m_session_data->m_new_threads.erase(iter);
+ProcessWindowsLive::OnDebugException(bool first_chance,
+ const ExceptionRecord &record) {
+ llvm::sys::ScopedLock lock(m_mutex);
+
+ // FIXME: Without this check, occasionally when running the test suite there
+ // is
+ // an issue where m_session_data can be null. It's not clear how this could
+ // happen
+ // but it only surfaces while running the test suite. In order to properly
+ // diagnose
+ // this, we probably need to first figure allow the test suite to print out
+ // full
+ // lldb logs, and then add logging to the process plugin.
+ if (!m_session_data) {
+ WINERR_IFANY(WINDOWS_LOG_EXCEPTION, "Debugger thread reported exception "
+ "0x%x at address 0x%I64x, but there is "
+ "no session.",
+ record.GetExceptionCode(), record.GetExceptionAddress());
+ return ExceptionResult::SendToApplication;
+ }
+
+ if (!first_chance) {
+ // Any second chance exception is an application crash by definition.
+ SetPrivateState(eStateCrashed);
+ }
+
+ ExceptionResult result = ExceptionResult::SendToApplication;
+ switch (record.GetExceptionCode()) {
+ case EXCEPTION_BREAKPOINT:
+ // Handle breakpoints at the first chance.
+ result = ExceptionResult::BreakInDebugger;
+
+ if (!m_session_data->m_initial_stop_received) {
+ WINLOG_IFANY(WINDOWS_LOG_BREAKPOINTS, "Hit loader breakpoint at address "
+ "0x%I64x, setting initial stop "
+ "event.",
+ record.GetExceptionAddress());
+ m_session_data->m_initial_stop_received = true;
+ ::SetEvent(m_session_data->m_initial_stop_event);
+ } else {
+ WINLOG_IFANY(WINDOWS_LOG_BREAKPOINTS,
+ "Hit non-loader breakpoint at address 0x%I64x.",
+ record.GetExceptionAddress());
+ }
+ SetPrivateState(eStateStopped);
+ break;
+ case EXCEPTION_SINGLE_STEP:
+ result = ExceptionResult::BreakInDebugger;
+ SetPrivateState(eStateStopped);
+ break;
+ default:
+ WINLOG_IFANY(WINDOWS_LOG_EXCEPTION, "Debugger thread reported exception "
+ "0x%x at address 0x%I64x "
+ "(first_chance=%s)",
+ record.GetExceptionCode(), record.GetExceptionAddress(),
+ BOOL_STR(first_chance));
+ // For non-breakpoints, give the application a chance to handle the
+ // exception first.
+ if (first_chance)
+ result = ExceptionResult::SendToApplication;
else
- m_session_data->m_exited_threads.insert(thread_id);
-}
-
-void
-ProcessWindowsLive::OnLoadDll(const ModuleSpec &module_spec, lldb::addr_t module_addr)
-{
- // Confusingly, there is no Target::AddSharedModule. Instead, calling GetSharedModule() with
- // a new module will add it to the module list and return a corresponding ModuleSP.
- Error error;
- ModuleSP module = GetTarget().GetSharedModule(module_spec, &error);
- bool load_addr_changed = false;
- module->SetLoadAddress(GetTarget(), module_addr, false, load_addr_changed);
-
- ModuleList loaded_modules;
- loaded_modules.Append(module);
- GetTarget().ModulesDidLoad(loaded_modules);
-}
-
-void
-ProcessWindowsLive::OnUnloadDll(lldb::addr_t module_addr)
-{
- Address resolved_addr;
- if (GetTarget().ResolveLoadAddress(module_addr, resolved_addr))
- {
- ModuleSP module = resolved_addr.GetModule();
- if (module)
- {
- ModuleList unloaded_modules;
- unloaded_modules.Append(module);
- GetTarget().ModulesDidUnload(unloaded_modules, false);
- }
- }
-}
+ result = ExceptionResult::BreakInDebugger;
+ }
-void
-ProcessWindowsLive::OnDebugString(const std::string &string)
-{
+ return result;
}
-void
-ProcessWindowsLive::OnDebuggerError(const Error &error, uint32_t type)
-{
- llvm::sys::ScopedLock lock(m_mutex);
-
- if (m_session_data->m_initial_stop_received)
- {
- // This happened while debugging. Do we shutdown the debugging session, try to continue,
- // or do something else?
- WINERR_IFALL(WINDOWS_LOG_PROCESS, "Error %u occurred during debugging. Unexpected behavior may result. %s",
- error.GetError(), error.AsCString());
- }
- else
- {
- // If we haven't actually launched the process yet, this was an error launching the
- // process. Set the internal error and signal the initial stop event so that the DoLaunch
- // method wakes up and returns a failure.
- m_session_data->m_launch_error = error;
- ::SetEvent(m_session_data->m_initial_stop_event);
- WINERR_IFALL(WINDOWS_LOG_PROCESS, "Error %u occurred launching the process before the initial stop. %s",
- error.GetError(), error.AsCString());
- return;
- }
+void ProcessWindowsLive::OnCreateThread(const HostThread &new_thread) {
+ llvm::sys::ScopedLock lock(m_mutex);
+ const HostThreadWindows &wnew_thread = new_thread.GetNativeThread();
+ m_session_data->m_new_threads[wnew_thread.GetThreadId()] = new_thread;
+}
+
+void ProcessWindowsLive::OnExitThread(lldb::tid_t thread_id,
+ uint32_t exit_code) {
+ llvm::sys::ScopedLock lock(m_mutex);
+
+ // On a forced termination, we may get exit thread events after the session
+ // data has been cleaned up.
+ if (!m_session_data)
+ return;
+
+ // A thread may have started and exited before the debugger stopped allowing a
+ // refresh.
+ // Just remove it from the new threads list in that case.
+ auto iter = m_session_data->m_new_threads.find(thread_id);
+ if (iter != m_session_data->m_new_threads.end())
+ m_session_data->m_new_threads.erase(iter);
+ else
+ m_session_data->m_exited_threads.insert(thread_id);
+}
+
+void ProcessWindowsLive::OnLoadDll(const ModuleSpec &module_spec,
+ lldb::addr_t module_addr) {
+ // Confusingly, there is no Target::AddSharedModule. Instead, calling
+ // GetSharedModule() with
+ // a new module will add it to the module list and return a corresponding
+ // ModuleSP.
+ Error error;
+ ModuleSP module = GetTarget().GetSharedModule(module_spec, &error);
+ bool load_addr_changed = false;
+ module->SetLoadAddress(GetTarget(), module_addr, false, load_addr_changed);
+
+ ModuleList loaded_modules;
+ loaded_modules.Append(module);
+ GetTarget().ModulesDidLoad(loaded_modules);
+}
+
+void ProcessWindowsLive::OnUnloadDll(lldb::addr_t module_addr) {
+ Address resolved_addr;
+ if (GetTarget().ResolveLoadAddress(module_addr, resolved_addr)) {
+ ModuleSP module = resolved_addr.GetModule();
+ if (module) {
+ ModuleList unloaded_modules;
+ unloaded_modules.Append(module);
+ GetTarget().ModulesDidUnload(unloaded_modules, false);
+ }
+ }
+}
+
+void ProcessWindowsLive::OnDebugString(const std::string &string) {}
+
+void ProcessWindowsLive::OnDebuggerError(const Error &error, uint32_t type) {
+ llvm::sys::ScopedLock lock(m_mutex);
+
+ if (m_session_data->m_initial_stop_received) {
+ // This happened while debugging. Do we shutdown the debugging session, try
+ // to continue,
+ // or do something else?
+ WINERR_IFALL(WINDOWS_LOG_PROCESS, "Error %u occurred during debugging. "
+ "Unexpected behavior may result. %s",
+ error.GetError(), error.AsCString());
+ } else {
+ // If we haven't actually launched the process yet, this was an error
+ // launching the
+ // process. Set the internal error and signal the initial stop event so
+ // that the DoLaunch
+ // method wakes up and returns a failure.
+ m_session_data->m_launch_error = error;
+ ::SetEvent(m_session_data->m_initial_stop_event);
+ WINERR_IFALL(
+ WINDOWS_LOG_PROCESS,
+ "Error %u occurred launching the process before the initial stop. %s",
+ error.GetError(), error.AsCString());
+ return;
+ }
}
Modified: lldb/trunk/source/Plugins/Process/Windows/Live/ProcessWindowsLive.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Windows/Live/ProcessWindowsLive.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/Windows/Live/ProcessWindowsLive.h (original)
+++ lldb/trunk/source/Plugins/Process/Windows/Live/ProcessWindowsLive.h Tue Sep 6 15:57:50 2016
@@ -19,10 +19,10 @@
// Other libraries and framework includes
#include "ForwardDecl.h"
#include "IDebugDelegate.h"
-#include "lldb/lldb-forward.h"
#include "lldb/Core/Error.h"
#include "lldb/Host/HostThread.h"
#include "lldb/Target/Process.h"
+#include "lldb/lldb-forward.h"
#include "llvm/Support/Mutex.h"
@@ -30,96 +30,100 @@
class ProcessMonitor;
-namespace lldb_private
-{
+namespace lldb_private {
class HostProcess;
class ProcessWindowsData;
-class ProcessWindowsLive : public lldb_private::ProcessWindows, public lldb_private::IDebugDelegate
-{
+class ProcessWindowsLive : public lldb_private::ProcessWindows,
+ public lldb_private::IDebugDelegate {
public:
- //------------------------------------------------------------------
- // Static functions.
- //------------------------------------------------------------------
- static lldb::ProcessSP
- CreateInstance(lldb::TargetSP target_sp,
- lldb::ListenerSP listener_sp,
- const lldb_private::FileSpec *);
-
- static void
- Initialize();
-
- static void
- Terminate();
-
- static lldb_private::ConstString
- GetPluginNameStatic();
-
- static const char *
- GetPluginDescriptionStatic();
-
- //------------------------------------------------------------------
- // Constructors and destructors
- //------------------------------------------------------------------
- ProcessWindowsLive(lldb::TargetSP target_sp,
- lldb::ListenerSP listener_sp);
-
- ~ProcessWindowsLive();
-
- // lldb_private::Process overrides
- lldb_private::ConstString GetPluginName() override;
- uint32_t GetPluginVersion() override;
-
- lldb_private::Error EnableBreakpointSite(lldb_private::BreakpointSite *bp_site) override;
- lldb_private::Error DisableBreakpointSite(lldb_private::BreakpointSite *bp_site) override;
-
- lldb_private::Error DoDetach(bool keep_stopped) override;
- lldb_private::Error DoLaunch(lldb_private::Module *exe_module, lldb_private::ProcessLaunchInfo &launch_info) override;
- lldb_private::Error DoAttachToProcessWithID(lldb::pid_t pid,
- const lldb_private::ProcessAttachInfo &attach_info) override;
- lldb_private::Error DoResume() override;
- lldb_private::Error DoDestroy() override;
- lldb_private::Error DoHalt(bool &caused_stop) override;
-
- void DidLaunch() override;
- void DidAttach(lldb_private::ArchSpec &arch_spec) override;
-
- void RefreshStateAfterStop() override;
-
- bool CanDebug(lldb::TargetSP target_sp, bool plugin_specified_by_name) override;
- bool
- DestroyRequiresHalt() override
- {
- return false;
- }
- bool UpdateThreadList(lldb_private::ThreadList &old_thread_list, lldb_private::ThreadList &new_thread_list) override;
- bool IsAlive() override;
-
- size_t DoReadMemory(lldb::addr_t vm_addr, void *buf, size_t size, lldb_private::Error &error) override;
- size_t DoWriteMemory(lldb::addr_t vm_addr, const void *buf, size_t size, lldb_private::Error &error) override;
- lldb_private::Error GetMemoryRegionInfo(lldb::addr_t vm_addr, lldb_private::MemoryRegionInfo &info) override;
-
- // IDebugDelegate overrides.
- void OnExitProcess(uint32_t exit_code) override;
- void OnDebuggerConnected(lldb::addr_t image_base) override;
- ExceptionResult OnDebugException(bool first_chance, const lldb_private::ExceptionRecord &record) override;
- void OnCreateThread(const lldb_private::HostThread &thread) override;
- void OnExitThread(lldb::tid_t thread_id, uint32_t exit_code) override;
- void OnLoadDll(const lldb_private::ModuleSpec &module_spec, lldb::addr_t module_addr) override;
- void OnUnloadDll(lldb::addr_t module_addr) override;
- void OnDebugString(const std::string &string) override;
- void OnDebuggerError(const lldb_private::Error &error, uint32_t type) override;
-
- private:
- lldb_private::Error WaitForDebuggerConnection(lldb_private::DebuggerThreadSP debugger,
- lldb_private::HostProcess &process);
+ //------------------------------------------------------------------
+ // Static functions.
+ //------------------------------------------------------------------
+ static lldb::ProcessSP CreateInstance(lldb::TargetSP target_sp,
+ lldb::ListenerSP listener_sp,
+ const lldb_private::FileSpec *);
+
+ static void Initialize();
+
+ static void Terminate();
+
+ static lldb_private::ConstString GetPluginNameStatic();
+
+ static const char *GetPluginDescriptionStatic();
+
+ //------------------------------------------------------------------
+ // Constructors and destructors
+ //------------------------------------------------------------------
+ ProcessWindowsLive(lldb::TargetSP target_sp, lldb::ListenerSP listener_sp);
+
+ ~ProcessWindowsLive();
+
+ // lldb_private::Process overrides
+ lldb_private::ConstString GetPluginName() override;
+ uint32_t GetPluginVersion() override;
+
+ lldb_private::Error
+ EnableBreakpointSite(lldb_private::BreakpointSite *bp_site) override;
+ lldb_private::Error
+ DisableBreakpointSite(lldb_private::BreakpointSite *bp_site) override;
+
+ lldb_private::Error DoDetach(bool keep_stopped) override;
+ lldb_private::Error
+ DoLaunch(lldb_private::Module *exe_module,
+ lldb_private::ProcessLaunchInfo &launch_info) override;
+ lldb_private::Error DoAttachToProcessWithID(
+ lldb::pid_t pid,
+ const lldb_private::ProcessAttachInfo &attach_info) override;
+ lldb_private::Error DoResume() override;
+ lldb_private::Error DoDestroy() override;
+ lldb_private::Error DoHalt(bool &caused_stop) override;
+
+ void DidLaunch() override;
+ void DidAttach(lldb_private::ArchSpec &arch_spec) override;
+
+ void RefreshStateAfterStop() override;
+
+ bool CanDebug(lldb::TargetSP target_sp,
+ bool plugin_specified_by_name) override;
+ bool DestroyRequiresHalt() override { return false; }
+ bool UpdateThreadList(lldb_private::ThreadList &old_thread_list,
+ lldb_private::ThreadList &new_thread_list) override;
+ bool IsAlive() override;
+
+ size_t DoReadMemory(lldb::addr_t vm_addr, void *buf, size_t size,
+ lldb_private::Error &error) override;
+ size_t DoWriteMemory(lldb::addr_t vm_addr, const void *buf, size_t size,
+ lldb_private::Error &error) override;
+ lldb_private::Error
+ GetMemoryRegionInfo(lldb::addr_t vm_addr,
+ lldb_private::MemoryRegionInfo &info) override;
+
+ // IDebugDelegate overrides.
+ void OnExitProcess(uint32_t exit_code) override;
+ void OnDebuggerConnected(lldb::addr_t image_base) override;
+ ExceptionResult
+ OnDebugException(bool first_chance,
+ const lldb_private::ExceptionRecord &record) override;
+ void OnCreateThread(const lldb_private::HostThread &thread) override;
+ void OnExitThread(lldb::tid_t thread_id, uint32_t exit_code) override;
+ void OnLoadDll(const lldb_private::ModuleSpec &module_spec,
+ lldb::addr_t module_addr) override;
+ void OnUnloadDll(lldb::addr_t module_addr) override;
+ void OnDebugString(const std::string &string) override;
+ void OnDebuggerError(const lldb_private::Error &error,
+ uint32_t type) override;
+
+private:
+ lldb_private::Error
+ WaitForDebuggerConnection(lldb_private::DebuggerThreadSP debugger,
+ lldb_private::HostProcess &process);
- llvm::sys::Mutex m_mutex;
+ llvm::sys::Mutex m_mutex;
- // Data for the active debugging session.
- std::unique_ptr<lldb_private::ProcessWindowsData> m_session_data;
+ // Data for the active debugging session.
+ std::unique_ptr<lldb_private::ProcessWindowsData> m_session_data;
};
-
}
-#endif // liblldb_Plugins_Process_Windows_Live_ProcessWindowsLive_H_
+#endif // liblldb_Plugins_Process_Windows_Live_ProcessWindowsLive_H_
Modified: lldb/trunk/source/Plugins/Process/Windows/Live/TargetThreadWindowsLive.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Windows/Live/TargetThreadWindowsLive.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/Windows/Live/TargetThreadWindowsLive.cpp (original)
+++ lldb/trunk/source/Plugins/Process/Windows/Live/TargetThreadWindowsLive.cpp Tue Sep 6 15:57:50 2016
@@ -16,9 +16,9 @@
#include "lldb/Host/windows/windows.h"
#include "lldb/Target/RegisterContext.h"
-#include "TargetThreadWindowsLive.h"
#include "ProcessWindows.h"
#include "ProcessWindowsLog.h"
+#include "TargetThreadWindowsLive.h"
#include "UnwindLLDB.h"
#if defined(_WIN64)
@@ -30,118 +30,95 @@
using namespace lldb;
using namespace lldb_private;
-TargetThreadWindowsLive::TargetThreadWindowsLive(ProcessWindows &process, const HostThread &thread)
- : TargetThreadWindows(process, thread)
- , m_host_thread(thread)
-{
-}
+TargetThreadWindowsLive::TargetThreadWindowsLive(ProcessWindows &process,
+ const HostThread &thread)
+ : TargetThreadWindows(process, thread), m_host_thread(thread) {}
-TargetThreadWindowsLive::~TargetThreadWindowsLive()
-{
- DestroyThread();
-}
+TargetThreadWindowsLive::~TargetThreadWindowsLive() { DestroyThread(); }
-void
-TargetThreadWindowsLive::RefreshStateAfterStop()
-{
- ::SuspendThread(m_host_thread.GetNativeThread().GetSystemHandle());
- SetState(eStateStopped);
- GetRegisterContext()->InvalidateIfNeeded(false);
+void TargetThreadWindowsLive::RefreshStateAfterStop() {
+ ::SuspendThread(m_host_thread.GetNativeThread().GetSystemHandle());
+ SetState(eStateStopped);
+ GetRegisterContext()->InvalidateIfNeeded(false);
}
-void
-TargetThreadWindowsLive::WillResume(lldb::StateType resume_state)
-{
-}
+void TargetThreadWindowsLive::WillResume(lldb::StateType resume_state) {}
-void
-TargetThreadWindowsLive::DidStop()
-{
-}
+void TargetThreadWindowsLive::DidStop() {}
-RegisterContextSP
-TargetThreadWindowsLive::GetRegisterContext()
-{
- if (!m_reg_context_sp)
- m_reg_context_sp = CreateRegisterContextForFrameIndex(0);
+RegisterContextSP TargetThreadWindowsLive::GetRegisterContext() {
+ if (!m_reg_context_sp)
+ m_reg_context_sp = CreateRegisterContextForFrameIndex(0);
- return m_reg_context_sp;
+ return m_reg_context_sp;
}
RegisterContextSP
-TargetThreadWindowsLive::CreateRegisterContextForFrame(StackFrame *frame)
-{
- return CreateRegisterContextForFrameIndex(frame->GetConcreteFrameIndex());
+TargetThreadWindowsLive::CreateRegisterContextForFrame(StackFrame *frame) {
+ return CreateRegisterContextForFrameIndex(frame->GetConcreteFrameIndex());
}
RegisterContextSP
-TargetThreadWindowsLive::CreateRegisterContextForFrameIndex(uint32_t idx)
-{
- if (!m_reg_context_sp)
- {
- ArchSpec arch = HostInfo::GetArchitecture();
- switch (arch.GetMachine())
- {
- case llvm::Triple::x86:
+TargetThreadWindowsLive::CreateRegisterContextForFrameIndex(uint32_t idx) {
+ if (!m_reg_context_sp) {
+ ArchSpec arch = HostInfo::GetArchitecture();
+ switch (arch.GetMachine()) {
+ case llvm::Triple::x86:
#if defined(_WIN64)
- // FIXME: This is a Wow64 process, create a RegisterContextWindows_Wow64
+// FIXME: This is a Wow64 process, create a RegisterContextWindows_Wow64
#else
- m_reg_context_sp.reset(new RegisterContextWindowsLive_x86(*this, idx));
+ m_reg_context_sp.reset(new RegisterContextWindowsLive_x86(*this, idx));
#endif
- break;
- case llvm::Triple::x86_64:
+ break;
+ case llvm::Triple::x86_64:
#if defined(_WIN64)
- m_reg_context_sp.reset(new RegisterContextWindowsLive_x64(*this, idx));
+ m_reg_context_sp.reset(new RegisterContextWindowsLive_x64(*this, idx));
#else
- // LLDB is 32-bit, but the target process is 64-bit. We probably can't debug this.
+// LLDB is 32-bit, but the target process is 64-bit. We probably can't debug
+// this.
#endif
- default:
- break;
- }
+ default:
+ break;
}
- return m_reg_context_sp;
+ }
+ return m_reg_context_sp;
}
-bool
-TargetThreadWindowsLive::CalculateStopInfo()
-{
- SetStopInfo(m_stop_info_sp);
- return true;
+bool TargetThreadWindowsLive::CalculateStopInfo() {
+ SetStopInfo(m_stop_info_sp);
+ return true;
}
-Unwind *
-TargetThreadWindowsLive::GetUnwinder()
-{
- // FIXME: Implement an unwinder based on the Windows unwinder exposed through DIA SDK.
- if (m_unwinder_ap.get() == NULL)
- m_unwinder_ap.reset(new UnwindLLDB(*this));
- return m_unwinder_ap.get();
-}
-
-bool
-TargetThreadWindowsLive::DoResume()
-{
- StateType resume_state = GetTemporaryResumeState();
- StateType current_state = GetState();
- if (resume_state == current_state)
- return true;
-
- if (resume_state == eStateStepping)
- {
- uint32_t flags_index = GetRegisterContext()->ConvertRegisterKindToRegisterNumber(eRegisterKindGeneric, LLDB_REGNUM_GENERIC_FLAGS);
- uint64_t flags_value = GetRegisterContext()->ReadRegisterAsUnsigned(flags_index, 0);
- flags_value |= 0x100; // Set the trap flag on the CPU
- GetRegisterContext()->WriteRegisterFromUnsigned(flags_index, flags_value);
- }
+Unwind *TargetThreadWindowsLive::GetUnwinder() {
+ // FIXME: Implement an unwinder based on the Windows unwinder exposed through
+ // DIA SDK.
+ if (m_unwinder_ap.get() == NULL)
+ m_unwinder_ap.reset(new UnwindLLDB(*this));
+ return m_unwinder_ap.get();
+}
- if (resume_state == eStateStepping || resume_state == eStateRunning)
- {
- DWORD previous_suspend_count = 0;
- HANDLE thread_handle = m_host_thread.GetNativeThread().GetSystemHandle();
- do
- {
- previous_suspend_count = ::ResumeThread(thread_handle);
- } while (previous_suspend_count > 0);
- }
+bool TargetThreadWindowsLive::DoResume() {
+ StateType resume_state = GetTemporaryResumeState();
+ StateType current_state = GetState();
+ if (resume_state == current_state)
return true;
+
+ if (resume_state == eStateStepping) {
+ uint32_t flags_index =
+ GetRegisterContext()->ConvertRegisterKindToRegisterNumber(
+ eRegisterKindGeneric, LLDB_REGNUM_GENERIC_FLAGS);
+ uint64_t flags_value =
+ GetRegisterContext()->ReadRegisterAsUnsigned(flags_index, 0);
+ flags_value |= 0x100; // Set the trap flag on the CPU
+ GetRegisterContext()->WriteRegisterFromUnsigned(flags_index, flags_value);
+ }
+
+ if (resume_state == eStateStepping || resume_state == eStateRunning) {
+ DWORD previous_suspend_count = 0;
+ HANDLE thread_handle = m_host_thread.GetNativeThread().GetSystemHandle();
+ do {
+ previous_suspend_count = ::ResumeThread(thread_handle);
+ } while (previous_suspend_count > 0);
+ }
+ return true;
}
Modified: lldb/trunk/source/Plugins/Process/Windows/Live/TargetThreadWindowsLive.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Windows/Live/TargetThreadWindowsLive.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/Windows/Live/TargetThreadWindowsLive.h (original)
+++ lldb/trunk/source/Plugins/Process/Windows/Live/TargetThreadWindowsLive.h Tue Sep 6 15:57:50 2016
@@ -10,45 +10,40 @@
#ifndef liblldb_Plugins_Process_Windows_TargetThreadWindowsLive_H_
#define liblldb_Plugins_Process_Windows_TargetThreadWindowsLive_H_
-#include "lldb/lldb-forward.h"
#include "lldb/Host/HostThread.h"
#include "lldb/Target/Thread.h"
+#include "lldb/lldb-forward.h"
#include "Plugins/Process/Windows/Common/TargetThreadWindows.h"
-namespace lldb_private
-{
+namespace lldb_private {
class ProcessWindows;
class HostThread;
class StackFrame;
-class TargetThreadWindowsLive : public lldb_private::TargetThreadWindows
-{
- public:
- TargetThreadWindowsLive(ProcessWindows &process, const HostThread &thread);
- virtual ~TargetThreadWindowsLive();
-
- // lldb_private::Thread overrides
- void RefreshStateAfterStop() override;
- void WillResume(lldb::StateType resume_state) override;
- void DidStop() override;
- lldb::RegisterContextSP GetRegisterContext() override;
- lldb::RegisterContextSP CreateRegisterContextForFrame(StackFrame *frame) override;
- bool CalculateStopInfo() override;
- Unwind *GetUnwinder() override;
-
- bool DoResume();
-
- HostThread
- GetHostThread() const
- {
- return m_host_thread;
- }
+class TargetThreadWindowsLive : public lldb_private::TargetThreadWindows {
+public:
+ TargetThreadWindowsLive(ProcessWindows &process, const HostThread &thread);
+ virtual ~TargetThreadWindowsLive();
+
+ // lldb_private::Thread overrides
+ void RefreshStateAfterStop() override;
+ void WillResume(lldb::StateType resume_state) override;
+ void DidStop() override;
+ lldb::RegisterContextSP GetRegisterContext() override;
+ lldb::RegisterContextSP
+ CreateRegisterContextForFrame(StackFrame *frame) override;
+ bool CalculateStopInfo() override;
+ Unwind *GetUnwinder() override;
+
+ bool DoResume();
+
+ HostThread GetHostThread() const { return m_host_thread; }
- private:
- lldb::RegisterContextSP CreateRegisterContextForFrameIndex(uint32_t idx);
+private:
+ lldb::RegisterContextSP CreateRegisterContextForFrameIndex(uint32_t idx);
- HostThread m_host_thread;
+ HostThread m_host_thread;
};
}
Modified: lldb/trunk/source/Plugins/Process/Windows/Live/x64/RegisterContextWindowsLive_x64.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Windows/Live/x64/RegisterContextWindowsLive_x64.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/Windows/Live/x64/RegisterContextWindowsLive_x64.cpp (original)
+++ lldb/trunk/source/Plugins/Process/Windows/Live/x64/RegisterContextWindowsLive_x64.cpp Tue Sep 6 15:57:50 2016
@@ -7,165 +7,160 @@
//
//===----------------------------------------------------------------------===//
-#include "lldb/lldb-private-types.h"
#include "lldb/Core/Error.h"
#include "lldb/Core/RegisterValue.h"
#include "lldb/Host/windows/HostThreadWindows.h"
#include "lldb/Host/windows/windows.h"
+#include "lldb/lldb-private-types.h"
-#include "lldb-x86-register-enums.h"
#include "RegisterContextWindowsLive_x64.h"
#include "TargetThreadWindows.h"
+#include "lldb-x86-register-enums.h"
#include "llvm/ADT/STLExtras.h"
using namespace lldb;
using namespace lldb_private;
-RegisterContextWindowsLive_x64::RegisterContextWindowsLive_x64(Thread &thread, uint32_t concrete_frame_idx)
- : RegisterContextWindows_x64(thread, concrete_frame_idx)
-{
-}
-
-RegisterContextWindowsLive_x64::~RegisterContextWindowsLive_x64()
-{
-}
-
-
-bool
-RegisterContextWindowsLive_x64::ReadRegister(const RegisterInfo *reg_info, RegisterValue ®_value)
-{
- if (!CacheAllRegisterValues())
- return false;
-
- switch (reg_info->kinds[eRegisterKindLLDB])
- {
- case lldb_rax_x86_64:
- reg_value.SetUInt64(m_context.Rax);
- break;
- case lldb_rbx_x86_64:
- reg_value.SetUInt64(m_context.Rbx);
- break;
- case lldb_rcx_x86_64:
- reg_value.SetUInt64(m_context.Rcx);
- break;
- case lldb_rdx_x86_64:
- reg_value.SetUInt64(m_context.Rdx);
- break;
- case lldb_rdi_x86_64:
- reg_value.SetUInt64(m_context.Rdi);
- break;
- case lldb_rsi_x86_64:
- reg_value.SetUInt64(m_context.Rsi);
- break;
- case lldb_r8_x86_64:
- reg_value.SetUInt64(m_context.R8);
- break;
- case lldb_r9_x86_64:
- reg_value.SetUInt64(m_context.R9);
- break;
- case lldb_r10_x86_64:
- reg_value.SetUInt64(m_context.R10);
- break;
- case lldb_r11_x86_64:
- reg_value.SetUInt64(m_context.R11);
- break;
- case lldb_r12_x86_64:
- reg_value.SetUInt64(m_context.R12);
- break;
- case lldb_r13_x86_64:
- reg_value.SetUInt64(m_context.R13);
- break;
- case lldb_r14_x86_64:
- reg_value.SetUInt64(m_context.R14);
- break;
- case lldb_r15_x86_64:
- reg_value.SetUInt64(m_context.R15);
- break;
- case lldb_rbp_x86_64:
- reg_value.SetUInt64(m_context.Rbp);
- break;
- case lldb_rsp_x86_64:
- reg_value.SetUInt64(m_context.Rsp);
- break;
- case lldb_rip_x86_64:
- reg_value.SetUInt64(m_context.Rip);
- break;
- case lldb_rflags_x86_64:
- reg_value.SetUInt64(m_context.EFlags);
- break;
- }
- return true;
+RegisterContextWindowsLive_x64::RegisterContextWindowsLive_x64(
+ Thread &thread, uint32_t concrete_frame_idx)
+ : RegisterContextWindows_x64(thread, concrete_frame_idx) {}
+
+RegisterContextWindowsLive_x64::~RegisterContextWindowsLive_x64() {}
+
+bool RegisterContextWindowsLive_x64::ReadRegister(const RegisterInfo *reg_info,
+ RegisterValue ®_value) {
+ if (!CacheAllRegisterValues())
+ return false;
+
+ switch (reg_info->kinds[eRegisterKindLLDB]) {
+ case lldb_rax_x86_64:
+ reg_value.SetUInt64(m_context.Rax);
+ break;
+ case lldb_rbx_x86_64:
+ reg_value.SetUInt64(m_context.Rbx);
+ break;
+ case lldb_rcx_x86_64:
+ reg_value.SetUInt64(m_context.Rcx);
+ break;
+ case lldb_rdx_x86_64:
+ reg_value.SetUInt64(m_context.Rdx);
+ break;
+ case lldb_rdi_x86_64:
+ reg_value.SetUInt64(m_context.Rdi);
+ break;
+ case lldb_rsi_x86_64:
+ reg_value.SetUInt64(m_context.Rsi);
+ break;
+ case lldb_r8_x86_64:
+ reg_value.SetUInt64(m_context.R8);
+ break;
+ case lldb_r9_x86_64:
+ reg_value.SetUInt64(m_context.R9);
+ break;
+ case lldb_r10_x86_64:
+ reg_value.SetUInt64(m_context.R10);
+ break;
+ case lldb_r11_x86_64:
+ reg_value.SetUInt64(m_context.R11);
+ break;
+ case lldb_r12_x86_64:
+ reg_value.SetUInt64(m_context.R12);
+ break;
+ case lldb_r13_x86_64:
+ reg_value.SetUInt64(m_context.R13);
+ break;
+ case lldb_r14_x86_64:
+ reg_value.SetUInt64(m_context.R14);
+ break;
+ case lldb_r15_x86_64:
+ reg_value.SetUInt64(m_context.R15);
+ break;
+ case lldb_rbp_x86_64:
+ reg_value.SetUInt64(m_context.Rbp);
+ break;
+ case lldb_rsp_x86_64:
+ reg_value.SetUInt64(m_context.Rsp);
+ break;
+ case lldb_rip_x86_64:
+ reg_value.SetUInt64(m_context.Rip);
+ break;
+ case lldb_rflags_x86_64:
+ reg_value.SetUInt64(m_context.EFlags);
+ break;
+ }
+ return true;
}
-bool
-RegisterContextWindowsLive_x64::WriteRegister(const RegisterInfo *reg_info, const RegisterValue ®_value)
-{
- // Since we cannot only write a single register value to the inferior, we need to make sure
- // our cached copy of the register values are fresh. Otherwise when writing EAX, for example,
- // we may also overwrite some other register with a stale value.
- if (!CacheAllRegisterValues())
- return false;
-
- switch (reg_info->kinds[eRegisterKindLLDB])
- {
- case lldb_rax_x86_64:
- m_context.Rax = reg_value.GetAsUInt64();
- break;
- case lldb_rbx_x86_64:
- m_context.Rbx = reg_value.GetAsUInt64();
- break;
- case lldb_rcx_x86_64:
- m_context.Rcx = reg_value.GetAsUInt64();
- break;
- case lldb_rdx_x86_64:
- m_context.Rdx = reg_value.GetAsUInt64();
- break;
- case lldb_rdi_x86_64:
- m_context.Rdi = reg_value.GetAsUInt64();
- break;
- case lldb_rsi_x86_64:
- m_context.Rsi = reg_value.GetAsUInt64();
- break;
- case lldb_r8_x86_64:
- m_context.R8 = reg_value.GetAsUInt64();
- break;
- case lldb_r9_x86_64:
- m_context.R9 = reg_value.GetAsUInt64();
- break;
- case lldb_r10_x86_64:
- m_context.R10 = reg_value.GetAsUInt64();
- break;
- case lldb_r11_x86_64:
- m_context.R11 = reg_value.GetAsUInt64();
- break;
- case lldb_r12_x86_64:
- m_context.R12 = reg_value.GetAsUInt64();
- break;
- case lldb_r13_x86_64:
- m_context.R13 = reg_value.GetAsUInt64();
- break;
- case lldb_r14_x86_64:
- m_context.R14 = reg_value.GetAsUInt64();
- break;
- case lldb_r15_x86_64:
- m_context.R15 = reg_value.GetAsUInt64();
- break;
- case lldb_rbp_x86_64:
- m_context.Rbp = reg_value.GetAsUInt64();
- break;
- case lldb_rsp_x86_64:
- m_context.Rsp = reg_value.GetAsUInt64();
- break;
- case lldb_rip_x86_64:
- m_context.Rip = reg_value.GetAsUInt64();
- break;
- case lldb_rflags_x86_64:
- m_context.EFlags = reg_value.GetAsUInt64();
- break;
- }
-
- // Physically update the registers in the target process.
- TargetThreadWindows &wthread = static_cast<TargetThreadWindows &>(m_thread);
- return ::SetThreadContext(wthread.GetHostThread().GetNativeThread().GetSystemHandle(), &m_context);
+bool RegisterContextWindowsLive_x64::WriteRegister(
+ const RegisterInfo *reg_info, const RegisterValue ®_value) {
+ // Since we cannot only write a single register value to the inferior, we need
+ // to make sure
+ // our cached copy of the register values are fresh. Otherwise when writing
+ // EAX, for example,
+ // we may also overwrite some other register with a stale value.
+ if (!CacheAllRegisterValues())
+ return false;
+
+ switch (reg_info->kinds[eRegisterKindLLDB]) {
+ case lldb_rax_x86_64:
+ m_context.Rax = reg_value.GetAsUInt64();
+ break;
+ case lldb_rbx_x86_64:
+ m_context.Rbx = reg_value.GetAsUInt64();
+ break;
+ case lldb_rcx_x86_64:
+ m_context.Rcx = reg_value.GetAsUInt64();
+ break;
+ case lldb_rdx_x86_64:
+ m_context.Rdx = reg_value.GetAsUInt64();
+ break;
+ case lldb_rdi_x86_64:
+ m_context.Rdi = reg_value.GetAsUInt64();
+ break;
+ case lldb_rsi_x86_64:
+ m_context.Rsi = reg_value.GetAsUInt64();
+ break;
+ case lldb_r8_x86_64:
+ m_context.R8 = reg_value.GetAsUInt64();
+ break;
+ case lldb_r9_x86_64:
+ m_context.R9 = reg_value.GetAsUInt64();
+ break;
+ case lldb_r10_x86_64:
+ m_context.R10 = reg_value.GetAsUInt64();
+ break;
+ case lldb_r11_x86_64:
+ m_context.R11 = reg_value.GetAsUInt64();
+ break;
+ case lldb_r12_x86_64:
+ m_context.R12 = reg_value.GetAsUInt64();
+ break;
+ case lldb_r13_x86_64:
+ m_context.R13 = reg_value.GetAsUInt64();
+ break;
+ case lldb_r14_x86_64:
+ m_context.R14 = reg_value.GetAsUInt64();
+ break;
+ case lldb_r15_x86_64:
+ m_context.R15 = reg_value.GetAsUInt64();
+ break;
+ case lldb_rbp_x86_64:
+ m_context.Rbp = reg_value.GetAsUInt64();
+ break;
+ case lldb_rsp_x86_64:
+ m_context.Rsp = reg_value.GetAsUInt64();
+ break;
+ case lldb_rip_x86_64:
+ m_context.Rip = reg_value.GetAsUInt64();
+ break;
+ case lldb_rflags_x86_64:
+ m_context.EFlags = reg_value.GetAsUInt64();
+ break;
+ }
+
+ // Physically update the registers in the target process.
+ TargetThreadWindows &wthread = static_cast<TargetThreadWindows &>(m_thread);
+ return ::SetThreadContext(
+ wthread.GetHostThread().GetNativeThread().GetSystemHandle(), &m_context);
}
Modified: lldb/trunk/source/Plugins/Process/Windows/Live/x64/RegisterContextWindowsLive_x64.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Windows/Live/x64/RegisterContextWindowsLive_x64.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/Windows/Live/x64/RegisterContextWindowsLive_x64.h (original)
+++ lldb/trunk/source/Plugins/Process/Windows/Live/x64/RegisterContextWindowsLive_x64.h Tue Sep 6 15:57:50 2016
@@ -10,30 +10,30 @@
#ifndef liblldb_RegisterContextWindowsLive_x64_H_
#define liblldb_RegisterContextWindowsLive_x64_H_
-#include "lldb/lldb-forward.h"
#include "../../Common/x64/RegisterContextWindows_x64.h"
+#include "lldb/lldb-forward.h"
-namespace lldb_private
-{
+namespace lldb_private {
class Thread;
-class RegisterContextWindowsLive_x64 : public RegisterContextWindows_x64
-{
- public:
- //------------------------------------------------------------------
- // Constructors and Destructors
- //------------------------------------------------------------------
- RegisterContextWindowsLive_x64(Thread &thread, uint32_t concrete_frame_idx);
-
- virtual ~RegisterContextWindowsLive_x64();
-
- //------------------------------------------------------------------
- // Subclasses must override these functions
- //------------------------------------------------------------------
- bool ReadRegister(const RegisterInfo *reg_info, RegisterValue ®_value) override;
+class RegisterContextWindowsLive_x64 : public RegisterContextWindows_x64 {
+public:
+ //------------------------------------------------------------------
+ // Constructors and Destructors
+ //------------------------------------------------------------------
+ RegisterContextWindowsLive_x64(Thread &thread, uint32_t concrete_frame_idx);
+
+ virtual ~RegisterContextWindowsLive_x64();
+
+ //------------------------------------------------------------------
+ // Subclasses must override these functions
+ //------------------------------------------------------------------
+ bool ReadRegister(const RegisterInfo *reg_info,
+ RegisterValue ®_value) override;
- bool WriteRegister(const RegisterInfo *reg_info, const RegisterValue ®_value) override;
+ bool WriteRegister(const RegisterInfo *reg_info,
+ const RegisterValue ®_value) override;
};
}
Modified: lldb/trunk/source/Plugins/Process/Windows/Live/x86/RegisterContextWindowsLive_x86.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Windows/Live/x86/RegisterContextWindowsLive_x86.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/Windows/Live/x86/RegisterContextWindowsLive_x86.cpp (original)
+++ lldb/trunk/source/Plugins/Process/Windows/Live/x86/RegisterContextWindowsLive_x86.cpp Tue Sep 6 15:57:50 2016
@@ -1,4 +1,5 @@
-//===-- RegisterContextWindowsLive_x86.cpp ------------------------*- C++ -*-===//
+//===-- RegisterContextWindowsLive_x86.cpp ------------------------*- C++
+//-*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -7,94 +8,101 @@
//
//===----------------------------------------------------------------------===//
-#include "lldb/lldb-private-types.h"
#include "lldb/Core/Error.h"
#include "lldb/Core/RegisterValue.h"
#include "lldb/Host/windows/HostThreadWindows.h"
#include "lldb/Host/windows/windows.h"
+#include "lldb/lldb-private-types.h"
-#include "lldb-x86-register-enums.h"
#include "ProcessWindowsLog.h"
#include "RegisterContextWindowsLive_x86.h"
#include "TargetThreadWindows.h"
+#include "lldb-x86-register-enums.h"
#include "llvm/ADT/STLExtras.h"
using namespace lldb;
-namespace lldb_private
-{
-
-RegisterContextWindowsLive_x86::RegisterContextWindowsLive_x86(Thread &thread, uint32_t concrete_frame_idx)
- : RegisterContextWindows_x86(thread, concrete_frame_idx)
-{
-}
-
-RegisterContextWindowsLive_x86::~RegisterContextWindowsLive_x86()
-{
-}
-
+namespace lldb_private {
-bool
-RegisterContextWindowsLive_x86::WriteRegister(const RegisterInfo *reg_info, const RegisterValue ®_value)
-{
- // Since we cannot only write a single register value to the inferior, we need to make sure
- // our cached copy of the register values are fresh. Otherwise when writing EAX, for example,
- // we may also overwrite some other register with a stale value.
- if (!CacheAllRegisterValues())
- return false;
-
- uint32_t reg = reg_info->kinds[eRegisterKindLLDB];
- switch (reg)
- {
- case lldb_eax_i386:
- WINLOG_IFALL(WINDOWS_LOG_REGISTERS, "Write value 0x%x to EAX", reg_value.GetAsUInt32());
- m_context.Eax = reg_value.GetAsUInt32();
- break;
- case lldb_ebx_i386:
- WINLOG_IFALL(WINDOWS_LOG_REGISTERS, "Write value 0x%x to EBX", reg_value.GetAsUInt32());
- m_context.Ebx = reg_value.GetAsUInt32();
- break;
- case lldb_ecx_i386:
- WINLOG_IFALL(WINDOWS_LOG_REGISTERS, "Write value 0x%x to ECX", reg_value.GetAsUInt32());
- m_context.Ecx = reg_value.GetAsUInt32();
- break;
- case lldb_edx_i386:
- WINLOG_IFALL(WINDOWS_LOG_REGISTERS, "Write value 0x%x to EDX", reg_value.GetAsUInt32());
- m_context.Edx = reg_value.GetAsUInt32();
- break;
- case lldb_edi_i386:
- WINLOG_IFALL(WINDOWS_LOG_REGISTERS, "Write value 0x%x to EDI", reg_value.GetAsUInt32());
- m_context.Edi = reg_value.GetAsUInt32();
- break;
- case lldb_esi_i386:
- WINLOG_IFALL(WINDOWS_LOG_REGISTERS, "Write value 0x%x to ESI", reg_value.GetAsUInt32());
- m_context.Esi = reg_value.GetAsUInt32();
- break;
- case lldb_ebp_i386:
- WINLOG_IFALL(WINDOWS_LOG_REGISTERS, "Write value 0x%x to EBP", reg_value.GetAsUInt32());
- m_context.Ebp = reg_value.GetAsUInt32();
- break;
- case lldb_esp_i386:
- WINLOG_IFALL(WINDOWS_LOG_REGISTERS, "Write value 0x%x to ESP", reg_value.GetAsUInt32());
- m_context.Esp = reg_value.GetAsUInt32();
- break;
- case lldb_eip_i386:
- WINLOG_IFALL(WINDOWS_LOG_REGISTERS, "Write value 0x%x to EIP", reg_value.GetAsUInt32());
- m_context.Eip = reg_value.GetAsUInt32();
- break;
- case lldb_eflags_i386:
- WINLOG_IFALL(WINDOWS_LOG_REGISTERS, "Write value 0x%x to EFLAGS", reg_value.GetAsUInt32());
- m_context.EFlags = reg_value.GetAsUInt32();
- break;
- default:
- WINWARN_IFALL(WINDOWS_LOG_REGISTERS, "Write value 0x%x to unknown register %u", reg_value.GetAsUInt32(),
- reg);
- }
-
- // Physically update the registers in the target process.
- TargetThreadWindows &wthread = static_cast<TargetThreadWindows &>(m_thread);
- return ::SetThreadContext(wthread.GetHostThread().GetNativeThread().GetSystemHandle(), &m_context);
+RegisterContextWindowsLive_x86::RegisterContextWindowsLive_x86(
+ Thread &thread, uint32_t concrete_frame_idx)
+ : RegisterContextWindows_x86(thread, concrete_frame_idx) {}
+
+RegisterContextWindowsLive_x86::~RegisterContextWindowsLive_x86() {}
+
+bool RegisterContextWindowsLive_x86::WriteRegister(
+ const RegisterInfo *reg_info, const RegisterValue ®_value) {
+ // Since we cannot only write a single register value to the inferior, we need
+ // to make sure
+ // our cached copy of the register values are fresh. Otherwise when writing
+ // EAX, for example,
+ // we may also overwrite some other register with a stale value.
+ if (!CacheAllRegisterValues())
+ return false;
+
+ uint32_t reg = reg_info->kinds[eRegisterKindLLDB];
+ switch (reg) {
+ case lldb_eax_i386:
+ WINLOG_IFALL(WINDOWS_LOG_REGISTERS, "Write value 0x%x to EAX",
+ reg_value.GetAsUInt32());
+ m_context.Eax = reg_value.GetAsUInt32();
+ break;
+ case lldb_ebx_i386:
+ WINLOG_IFALL(WINDOWS_LOG_REGISTERS, "Write value 0x%x to EBX",
+ reg_value.GetAsUInt32());
+ m_context.Ebx = reg_value.GetAsUInt32();
+ break;
+ case lldb_ecx_i386:
+ WINLOG_IFALL(WINDOWS_LOG_REGISTERS, "Write value 0x%x to ECX",
+ reg_value.GetAsUInt32());
+ m_context.Ecx = reg_value.GetAsUInt32();
+ break;
+ case lldb_edx_i386:
+ WINLOG_IFALL(WINDOWS_LOG_REGISTERS, "Write value 0x%x to EDX",
+ reg_value.GetAsUInt32());
+ m_context.Edx = reg_value.GetAsUInt32();
+ break;
+ case lldb_edi_i386:
+ WINLOG_IFALL(WINDOWS_LOG_REGISTERS, "Write value 0x%x to EDI",
+ reg_value.GetAsUInt32());
+ m_context.Edi = reg_value.GetAsUInt32();
+ break;
+ case lldb_esi_i386:
+ WINLOG_IFALL(WINDOWS_LOG_REGISTERS, "Write value 0x%x to ESI",
+ reg_value.GetAsUInt32());
+ m_context.Esi = reg_value.GetAsUInt32();
+ break;
+ case lldb_ebp_i386:
+ WINLOG_IFALL(WINDOWS_LOG_REGISTERS, "Write value 0x%x to EBP",
+ reg_value.GetAsUInt32());
+ m_context.Ebp = reg_value.GetAsUInt32();
+ break;
+ case lldb_esp_i386:
+ WINLOG_IFALL(WINDOWS_LOG_REGISTERS, "Write value 0x%x to ESP",
+ reg_value.GetAsUInt32());
+ m_context.Esp = reg_value.GetAsUInt32();
+ break;
+ case lldb_eip_i386:
+ WINLOG_IFALL(WINDOWS_LOG_REGISTERS, "Write value 0x%x to EIP",
+ reg_value.GetAsUInt32());
+ m_context.Eip = reg_value.GetAsUInt32();
+ break;
+ case lldb_eflags_i386:
+ WINLOG_IFALL(WINDOWS_LOG_REGISTERS, "Write value 0x%x to EFLAGS",
+ reg_value.GetAsUInt32());
+ m_context.EFlags = reg_value.GetAsUInt32();
+ break;
+ default:
+ WINWARN_IFALL(WINDOWS_LOG_REGISTERS,
+ "Write value 0x%x to unknown register %u",
+ reg_value.GetAsUInt32(), reg);
+ }
+
+ // Physically update the registers in the target process.
+ TargetThreadWindows &wthread = static_cast<TargetThreadWindows &>(m_thread);
+ return ::SetThreadContext(
+ wthread.GetHostThread().GetNativeThread().GetSystemHandle(), &m_context);
}
-} // namespace lldb_private
+} // namespace lldb_private
Modified: lldb/trunk/source/Plugins/Process/Windows/Live/x86/RegisterContextWindowsLive_x86.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Windows/Live/x86/RegisterContextWindowsLive_x86.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/Windows/Live/x86/RegisterContextWindowsLive_x86.h (original)
+++ lldb/trunk/source/Plugins/Process/Windows/Live/x86/RegisterContextWindowsLive_x86.h Tue Sep 6 15:57:50 2016
@@ -10,27 +10,25 @@
#ifndef liblldb_RegisterContextWindowsLive_x86_H_
#define liblldb_RegisterContextWindowsLive_x86_H_
-#include "lldb/lldb-forward.h"
#include "../../Common/x86/RegisterContextWindows_x86.h"
+#include "lldb/lldb-forward.h"
-namespace lldb_private
-{
+namespace lldb_private {
class Thread;
-class RegisterContextWindowsLive_x86 : public RegisterContextWindows_x86
-{
- public:
- //------------------------------------------------------------------
- // Constructors and Destructors
- //------------------------------------------------------------------
- RegisterContextWindowsLive_x86(Thread &thread, uint32_t concrete_frame_idx);
+class RegisterContextWindowsLive_x86 : public RegisterContextWindows_x86 {
+public:
+ //------------------------------------------------------------------
+ // Constructors and Destructors
+ //------------------------------------------------------------------
+ RegisterContextWindowsLive_x86(Thread &thread, uint32_t concrete_frame_idx);
- virtual ~RegisterContextWindowsLive_x86();
+ virtual ~RegisterContextWindowsLive_x86();
- bool WriteRegister(const RegisterInfo *reg_info, const RegisterValue ®_value) override;
+ bool WriteRegister(const RegisterInfo *reg_info,
+ const RegisterValue ®_value) override;
};
-
}
#endif // #ifndef liblldb_RegisterContextWindowsLive_x86_H_
Modified: lldb/trunk/source/Plugins/Process/Windows/MiniDump/ProcessWinMiniDump.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Windows/MiniDump/ProcessWinMiniDump.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/Windows/MiniDump/ProcessWinMiniDump.cpp (original)
+++ lldb/trunk/source/Plugins/Process/Windows/MiniDump/ProcessWinMiniDump.cpp Tue Sep 6 15:57:50 2016
@@ -13,9 +13,9 @@
#include <DbgHelp.h>
#include <assert.h>
-#include <stdlib.h>
#include <memory>
#include <mutex>
+#include <stdlib.h>
#include "Plugins/DynamicLoader/Windows-DYLD/DynamicLoaderWindowsDYLD.h"
#include "lldb/Core/DataBufferHeap.h"
@@ -47,664 +47,589 @@ using namespace lldb_private;
// code, keeping non-portable types out of the header files.
// TODO(amccarth): Determine if we need a mutex for access. Given that this is
// postmortem debugging, I don't think so.
-class ProcessWinMiniDump::Impl
-{
+class ProcessWinMiniDump::Impl {
public:
- Impl(const FileSpec &core_file, ProcessWinMiniDump *self);
- ~Impl();
+ Impl(const FileSpec &core_file, ProcessWinMiniDump *self);
+ ~Impl();
- Error
- DoLoadCore();
+ Error DoLoadCore();
- bool
- UpdateThreadList(ThreadList &old_thread_list, ThreadList &new_thread_list);
+ bool UpdateThreadList(ThreadList &old_thread_list,
+ ThreadList &new_thread_list);
- void
- RefreshStateAfterStop();
+ void RefreshStateAfterStop();
- size_t
- DoReadMemory(lldb::addr_t addr, void *buf, size_t size, Error &error);
+ size_t DoReadMemory(lldb::addr_t addr, void *buf, size_t size, Error &error);
- Error
- GetMemoryRegionInfo(lldb::addr_t load_addr, lldb_private::MemoryRegionInfo &info);
+ Error GetMemoryRegionInfo(lldb::addr_t load_addr,
+ lldb_private::MemoryRegionInfo &info);
private:
- // Describes a range of memory captured in the mini dump.
- struct Range
- {
- lldb::addr_t start; // virtual address of the beginning of the range
- size_t size; // size of the range in bytes
- const uint8_t *ptr; // absolute pointer to the first byte of the range
- };
-
- // If the mini dump has a memory range that contains the desired address, it
- // returns true with the details of the range in *range_out. Otherwise, it
- // returns false.
- bool
- FindMemoryRange(lldb::addr_t addr, Range *range_out) const;
-
- lldb_private::Error
- MapMiniDumpIntoMemory();
-
- lldb_private::ArchSpec
- DetermineArchitecture();
-
- void
- ReadExceptionRecord();
-
- void
- ReadMiscInfo();
-
- void
- ReadModuleList();
-
- // A thin wrapper around WinAPI's MiniDumpReadDumpStream to avoid redundant
- // checks. If there's a failure (e.g., if the requested stream doesn't exist),
- // the function returns nullptr and sets *size_out to 0.
- void *
- FindDumpStream(unsigned stream_number, size_t *size_out) const;
-
- // Getting a string out of a mini dump is a chore. You're usually given a
- // relative virtual address (RVA), which points to a counted string that's in
- // Windows Unicode (UTF-16). This wrapper handles all the redirection and
- // returns a UTF-8 copy of the string.
- std::string
- GetMiniDumpString(RVA rva) const;
-
- ProcessWinMiniDump *m_self; // non-owning back pointer
- FileSpec m_core_file;
- HANDLE m_dump_file; // handle to the open minidump file
- HANDLE m_mapping; // handle to the file mapping for the minidump file
- void * m_base_addr; // base memory address of the minidump
- std::shared_ptr<ExceptionRecord> m_exception_sp;
- bool m_is_wow64; // minidump is of a 32-bit process captured with a 64-bit debugger
+ // Describes a range of memory captured in the mini dump.
+ struct Range {
+ lldb::addr_t start; // virtual address of the beginning of the range
+ size_t size; // size of the range in bytes
+ const uint8_t *ptr; // absolute pointer to the first byte of the range
+ };
+
+ // If the mini dump has a memory range that contains the desired address, it
+ // returns true with the details of the range in *range_out. Otherwise, it
+ // returns false.
+ bool FindMemoryRange(lldb::addr_t addr, Range *range_out) const;
+
+ lldb_private::Error MapMiniDumpIntoMemory();
+
+ lldb_private::ArchSpec DetermineArchitecture();
+
+ void ReadExceptionRecord();
+
+ void ReadMiscInfo();
+
+ void ReadModuleList();
+
+ // A thin wrapper around WinAPI's MiniDumpReadDumpStream to avoid redundant
+ // checks. If there's a failure (e.g., if the requested stream doesn't
+ // exist),
+ // the function returns nullptr and sets *size_out to 0.
+ void *FindDumpStream(unsigned stream_number, size_t *size_out) const;
+
+ // Getting a string out of a mini dump is a chore. You're usually given a
+ // relative virtual address (RVA), which points to a counted string that's in
+ // Windows Unicode (UTF-16). This wrapper handles all the redirection and
+ // returns a UTF-8 copy of the string.
+ std::string GetMiniDumpString(RVA rva) const;
+
+ ProcessWinMiniDump *m_self; // non-owning back pointer
+ FileSpec m_core_file;
+ HANDLE m_dump_file; // handle to the open minidump file
+ HANDLE m_mapping; // handle to the file mapping for the minidump file
+ void *m_base_addr; // base memory address of the minidump
+ std::shared_ptr<ExceptionRecord> m_exception_sp;
+ bool m_is_wow64; // minidump is of a 32-bit process captured with a 64-bit
+ // debugger
};
-ProcessWinMiniDump::Impl::Impl(const FileSpec &core_file, ProcessWinMiniDump *self)
- : m_self(self),
- m_core_file(core_file),
- m_dump_file(INVALID_HANDLE_VALUE),
- m_mapping(NULL),
- m_base_addr(nullptr),
- m_exception_sp(),
- m_is_wow64(false)
-{
-}
-
-ProcessWinMiniDump::Impl::~Impl()
-{
- if (m_base_addr)
- {
- ::UnmapViewOfFile(m_base_addr);
- m_base_addr = nullptr;
- }
- if (m_mapping)
- {
- ::CloseHandle(m_mapping);
- m_mapping = NULL;
- }
- if (m_dump_file != INVALID_HANDLE_VALUE)
- {
- ::CloseHandle(m_dump_file);
- m_dump_file = INVALID_HANDLE_VALUE;
- }
-}
-
-Error
-ProcessWinMiniDump::Impl::DoLoadCore()
-{
- Error error = MapMiniDumpIntoMemory();
- if (error.Fail())
- {
- return error;
- }
-
- m_self->GetTarget().SetArchitecture(DetermineArchitecture());
- ReadMiscInfo(); // notably for process ID
- ReadModuleList();
- ReadExceptionRecord();
-
+ProcessWinMiniDump::Impl::Impl(const FileSpec &core_file,
+ ProcessWinMiniDump *self)
+ : m_self(self), m_core_file(core_file), m_dump_file(INVALID_HANDLE_VALUE),
+ m_mapping(NULL), m_base_addr(nullptr), m_exception_sp(),
+ m_is_wow64(false) {}
+
+ProcessWinMiniDump::Impl::~Impl() {
+ if (m_base_addr) {
+ ::UnmapViewOfFile(m_base_addr);
+ m_base_addr = nullptr;
+ }
+ if (m_mapping) {
+ ::CloseHandle(m_mapping);
+ m_mapping = NULL;
+ }
+ if (m_dump_file != INVALID_HANDLE_VALUE) {
+ ::CloseHandle(m_dump_file);
+ m_dump_file = INVALID_HANDLE_VALUE;
+ }
+}
+
+Error ProcessWinMiniDump::Impl::DoLoadCore() {
+ Error error = MapMiniDumpIntoMemory();
+ if (error.Fail()) {
return error;
+ }
-}
-
-bool
-ProcessWinMiniDump::Impl::UpdateThreadList(ThreadList &old_thread_list, ThreadList &new_thread_list)
-{
- size_t size = 0;
- auto thread_list_ptr = static_cast<const MINIDUMP_THREAD_LIST *>(FindDumpStream(ThreadListStream, &size));
- if (thread_list_ptr)
- {
- const ULONG32 thread_count = thread_list_ptr->NumberOfThreads;
- for (ULONG32 i = 0; i < thread_count; ++i) {
- const auto &mini_dump_thread = thread_list_ptr->Threads[i];
- auto thread_sp = std::make_shared<ThreadWinMiniDump>(*m_self, mini_dump_thread.ThreadId);
- if (mini_dump_thread.ThreadContext.DataSize >= sizeof(CONTEXT))
- {
- const CONTEXT *context = reinterpret_cast<const CONTEXT *>(static_cast<const char *>(m_base_addr) +
- mini_dump_thread.ThreadContext.Rva);
-
- if (m_is_wow64)
- {
- // On Windows, a 32-bit process can run on a 64-bit machine under WOW64.
- // If the minidump was captured with a 64-bit debugger, then the CONTEXT
- // we just grabbed from the mini_dump_thread is the one for the 64-bit
- // "native" process rather than the 32-bit "guest" process we care about.
- // In this case, we can get the 32-bit CONTEXT from the TEB (Thread
- // Environment Block) of the 64-bit process.
- Error error;
- TEB64 wow64teb = {0};
- m_self->ReadMemory(mini_dump_thread.Teb, &wow64teb, sizeof(wow64teb), error);
- if (error.Success())
- {
- // Slot 1 of the thread-local storage in the 64-bit TEB points to a structure
- // that includes the 32-bit CONTEXT (after a ULONG).
- // See: https://msdn.microsoft.com/en-us/library/ms681670.aspx
- const size_t addr = wow64teb.TlsSlots[1];
- Range range = {0};
- if (FindMemoryRange(addr, &range))
- {
- lldbassert(range.start <= addr);
- const size_t offset = addr - range.start + sizeof(ULONG);
- if (offset < range.size)
- {
- const size_t overlap = range.size - offset;
- if (overlap >= sizeof(CONTEXT))
- {
- context = reinterpret_cast<const CONTEXT *>(range.ptr + offset);
- }
- }
- }
- }
-
- // NOTE: We don't currently use the TEB for anything else. If we need it in
- // the future, the 32-bit TEB is located according to the address stored in the
- // first slot of the 64-bit TEB (wow64teb.Reserved1[0]).
+ m_self->GetTarget().SetArchitecture(DetermineArchitecture());
+ ReadMiscInfo(); // notably for process ID
+ ReadModuleList();
+ ReadExceptionRecord();
+
+ return error;
+}
+
+bool ProcessWinMiniDump::Impl::UpdateThreadList(ThreadList &old_thread_list,
+ ThreadList &new_thread_list) {
+ size_t size = 0;
+ auto thread_list_ptr = static_cast<const MINIDUMP_THREAD_LIST *>(
+ FindDumpStream(ThreadListStream, &size));
+ if (thread_list_ptr) {
+ const ULONG32 thread_count = thread_list_ptr->NumberOfThreads;
+ for (ULONG32 i = 0; i < thread_count; ++i) {
+ const auto &mini_dump_thread = thread_list_ptr->Threads[i];
+ auto thread_sp = std::make_shared<ThreadWinMiniDump>(
+ *m_self, mini_dump_thread.ThreadId);
+ if (mini_dump_thread.ThreadContext.DataSize >= sizeof(CONTEXT)) {
+ const CONTEXT *context = reinterpret_cast<const CONTEXT *>(
+ static_cast<const char *>(m_base_addr) +
+ mini_dump_thread.ThreadContext.Rva);
+
+ if (m_is_wow64) {
+ // On Windows, a 32-bit process can run on a 64-bit machine under
+ // WOW64.
+ // If the minidump was captured with a 64-bit debugger, then the
+ // CONTEXT
+ // we just grabbed from the mini_dump_thread is the one for the 64-bit
+ // "native" process rather than the 32-bit "guest" process we care
+ // about.
+ // In this case, we can get the 32-bit CONTEXT from the TEB (Thread
+ // Environment Block) of the 64-bit process.
+ Error error;
+ TEB64 wow64teb = {0};
+ m_self->ReadMemory(mini_dump_thread.Teb, &wow64teb, sizeof(wow64teb),
+ error);
+ if (error.Success()) {
+ // Slot 1 of the thread-local storage in the 64-bit TEB points to a
+ // structure
+ // that includes the 32-bit CONTEXT (after a ULONG).
+ // See: https://msdn.microsoft.com/en-us/library/ms681670.aspx
+ const size_t addr = wow64teb.TlsSlots[1];
+ Range range = {0};
+ if (FindMemoryRange(addr, &range)) {
+ lldbassert(range.start <= addr);
+ const size_t offset = addr - range.start + sizeof(ULONG);
+ if (offset < range.size) {
+ const size_t overlap = range.size - offset;
+ if (overlap >= sizeof(CONTEXT)) {
+ context =
+ reinterpret_cast<const CONTEXT *>(range.ptr + offset);
}
-
- thread_sp->SetContext(context);
+ }
}
- new_thread_list.AddThread(thread_sp);
- }
- }
+ }
- return new_thread_list.GetSize(false) > 0;
-}
-
-void
-ProcessWinMiniDump::Impl::RefreshStateAfterStop()
-{
- if (!m_exception_sp)
- return;
-
- auto active_exception = m_exception_sp;
- std::string desc;
- llvm::raw_string_ostream desc_stream(desc);
- desc_stream << "Exception " << llvm::format_hex(active_exception->GetExceptionCode(), 8)
- << " encountered at address " << llvm::format_hex(active_exception->GetExceptionAddress(), 8);
- m_self->m_thread_list.SetSelectedThreadByID(active_exception->GetThreadID());
- auto stop_thread = m_self->m_thread_list.GetSelectedThread();
- auto stop_info = StopInfo::CreateStopReasonWithException(*stop_thread, desc_stream.str().c_str());
- stop_thread->SetStopInfo(stop_info);
-}
-
-size_t
-ProcessWinMiniDump::Impl::DoReadMemory(lldb::addr_t addr, void *buf, size_t size, Error &error)
-{
- // I don't have a sense of how frequently this is called or how many memory
- // ranges a mini dump typically has, so I'm not sure if searching for the
- // appropriate range linearly each time is stupid. Perhaps we should build
- // an index for faster lookups.
- Range range = {0};
- if (!FindMemoryRange(addr, &range))
- {
- return 0;
- }
-
- // There's at least some overlap between the beginning of the desired range
- // (addr) and the current range. Figure out where the overlap begins and
- // how much overlap there is, then copy it to the destination buffer.
- lldbassert(range.start <= addr);
- const size_t offset = addr - range.start;
- lldbassert(offset < range.size);
- const size_t overlap = std::min(size, range.size - offset);
- std::memcpy(buf, range.ptr + offset, overlap);
- return overlap;
-}
-
-Error
-ProcessWinMiniDump::Impl::GetMemoryRegionInfo(lldb::addr_t load_addr, lldb_private::MemoryRegionInfo &info)
-{
- Error error;
- size_t size;
- info.Clear();
- const auto list = reinterpret_cast<const MINIDUMP_MEMORY_INFO_LIST *>(FindDumpStream(MemoryInfoListStream, &size));
- if (list == nullptr || size < sizeof(MINIDUMP_MEMORY_INFO_LIST))
- {
- error.SetErrorString("the mini dump contains no memory range information");
- return error;
- }
-
- if (list->SizeOfEntry < sizeof(MINIDUMP_MEMORY_INFO))
- {
- error.SetErrorString("the entries in the mini dump memory info list are smaller than expected");
- return error;
- }
-
- if (size < list->SizeOfHeader + list->SizeOfEntry * list->NumberOfEntries)
- {
- error.SetErrorString("the mini dump memory info list is incomplete");
- return error;
- }
-
- const MINIDUMP_MEMORY_INFO *next_entry = nullptr;
-
- for (int i = 0; i < list->NumberOfEntries; ++i)
- {
- const auto entry = reinterpret_cast<const MINIDUMP_MEMORY_INFO *>(reinterpret_cast<const char *>(list) +
- list->SizeOfHeader + i * list->SizeOfEntry);
- const auto head = entry->BaseAddress;
- const auto tail = head + entry->RegionSize;
- if (head <= load_addr && load_addr < tail)
- {
- info.GetRange().SetRangeBase((entry->State != MEM_FREE) ? head : load_addr);
- info.GetRange().SetRangeEnd(tail);
- info.SetReadable(IsPageReadable(entry->Protect) ? MemoryRegionInfo::eYes : MemoryRegionInfo::eNo);
- info.SetWritable(IsPageWritable(entry->Protect) ? MemoryRegionInfo::eYes : MemoryRegionInfo::eNo);
- info.SetExecutable(IsPageExecutable(entry->Protect) ? MemoryRegionInfo::eYes : MemoryRegionInfo::eNo);
- info.SetMapped((entry->State != MEM_FREE) ? MemoryRegionInfo::eYes : MemoryRegionInfo::eNo);
- return error;
- }
- else if (head > load_addr && (next_entry == nullptr || head < next_entry->BaseAddress) )
- {
- // In case there is no region containing load_addr keep track of the nearest region
- // after load_addr so we can return the distance to it.
- next_entry = entry;
+ // NOTE: We don't currently use the TEB for anything else. If we
+ // need it in
+ // the future, the 32-bit TEB is located according to the address
+ // stored in the
+ // first slot of the 64-bit TEB (wow64teb.Reserved1[0]).
}
- }
- // No containing region found. Create an unmapped region that extends to the next region
- // or LLDB_INVALID_ADDRESS
- info.GetRange().SetRangeBase(load_addr);
- info.GetRange().SetRangeEnd((next_entry != nullptr)?next_entry->BaseAddress:LLDB_INVALID_ADDRESS);
- info.SetReadable(MemoryRegionInfo::eNo);
- info.SetWritable(MemoryRegionInfo::eNo);
- info.SetExecutable(MemoryRegionInfo::eNo);
- info.SetMapped(MemoryRegionInfo::eNo);
-
- // Note that the memory info list doesn't seem to contain ranges in kernel space,
- // so if you're walking a stack that has kernel frames, the stack may appear
- // truncated.
+ thread_sp->SetContext(context);
+ }
+ new_thread_list.AddThread(thread_sp);
+ }
+ }
+
+ return new_thread_list.GetSize(false) > 0;
+}
+
+void ProcessWinMiniDump::Impl::RefreshStateAfterStop() {
+ if (!m_exception_sp)
+ return;
+
+ auto active_exception = m_exception_sp;
+ std::string desc;
+ llvm::raw_string_ostream desc_stream(desc);
+ desc_stream << "Exception "
+ << llvm::format_hex(active_exception->GetExceptionCode(), 8)
+ << " encountered at address "
+ << llvm::format_hex(active_exception->GetExceptionAddress(), 8);
+ m_self->m_thread_list.SetSelectedThreadByID(active_exception->GetThreadID());
+ auto stop_thread = m_self->m_thread_list.GetSelectedThread();
+ auto stop_info = StopInfo::CreateStopReasonWithException(
+ *stop_thread, desc_stream.str().c_str());
+ stop_thread->SetStopInfo(stop_info);
+}
+
+size_t ProcessWinMiniDump::Impl::DoReadMemory(lldb::addr_t addr, void *buf,
+ size_t size, Error &error) {
+ // I don't have a sense of how frequently this is called or how many memory
+ // ranges a mini dump typically has, so I'm not sure if searching for the
+ // appropriate range linearly each time is stupid. Perhaps we should build
+ // an index for faster lookups.
+ Range range = {0};
+ if (!FindMemoryRange(addr, &range)) {
+ return 0;
+ }
+
+ // There's at least some overlap between the beginning of the desired range
+ // (addr) and the current range. Figure out where the overlap begins and
+ // how much overlap there is, then copy it to the destination buffer.
+ lldbassert(range.start <= addr);
+ const size_t offset = addr - range.start;
+ lldbassert(offset < range.size);
+ const size_t overlap = std::min(size, range.size - offset);
+ std::memcpy(buf, range.ptr + offset, overlap);
+ return overlap;
+}
+
+Error ProcessWinMiniDump::Impl::GetMemoryRegionInfo(
+ lldb::addr_t load_addr, lldb_private::MemoryRegionInfo &info) {
+ Error error;
+ size_t size;
+ info.Clear();
+ const auto list = reinterpret_cast<const MINIDUMP_MEMORY_INFO_LIST *>(
+ FindDumpStream(MemoryInfoListStream, &size));
+ if (list == nullptr || size < sizeof(MINIDUMP_MEMORY_INFO_LIST)) {
+ error.SetErrorString("the mini dump contains no memory range information");
return error;
-}
-
-bool
-ProcessWinMiniDump::Impl::FindMemoryRange(lldb::addr_t addr, Range *range_out) const
-{
- size_t stream_size = 0;
- auto mem_list_stream = static_cast<const MINIDUMP_MEMORY_LIST *>(FindDumpStream(MemoryListStream, &stream_size));
- if (mem_list_stream)
- {
- for (ULONG32 i = 0; i < mem_list_stream->NumberOfMemoryRanges; ++i)
- {
- const MINIDUMP_MEMORY_DESCRIPTOR &mem_desc = mem_list_stream->MemoryRanges[i];
- const MINIDUMP_LOCATION_DESCRIPTOR &loc_desc = mem_desc.Memory;
- const lldb::addr_t range_start = mem_desc.StartOfMemoryRange;
- const size_t range_size = loc_desc.DataSize;
- if (range_start <= addr && addr < range_start + range_size)
- {
- range_out->start = range_start;
- range_out->size = range_size;
- range_out->ptr = reinterpret_cast<const uint8_t *>(m_base_addr) + loc_desc.Rva;
- return true;
- }
- }
- }
-
- // Some mini dumps have a Memory64ListStream that captures all the heap
- // memory. We can't exactly use the same loop as above, because the mini
- // dump uses slightly different data structures to describe those.
- auto mem_list64_stream = static_cast<const MINIDUMP_MEMORY64_LIST *>(FindDumpStream(Memory64ListStream, &stream_size));
- if (mem_list64_stream)
- {
- size_t base_rva = mem_list64_stream->BaseRva;
- for (ULONG32 i = 0; i < mem_list64_stream->NumberOfMemoryRanges; ++i) {
- const MINIDUMP_MEMORY_DESCRIPTOR64 &mem_desc = mem_list64_stream->MemoryRanges[i];
- const lldb::addr_t range_start = mem_desc.StartOfMemoryRange;
- const size_t range_size = mem_desc.DataSize;
- if (range_start <= addr && addr < range_start + range_size)
- {
- range_out->start = range_start;
- range_out->size = range_size;
- range_out->ptr = reinterpret_cast<const uint8_t *>(m_base_addr) + base_rva;
- return true;
- }
- base_rva += range_size;
- }
- }
-
- return false;
-}
+ }
-Error
-ProcessWinMiniDump::Impl::MapMiniDumpIntoMemory()
-{
- Error error;
- const char *file = m_core_file.GetCString();
- std::wstring wfile;
- if (!llvm::ConvertUTF8toWide(file, wfile))
- {
- error.SetErrorString("Error converting path to UTF-16");
- return error;
- }
- m_dump_file =
- ::CreateFileW(wfile.c_str(), GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
- if (m_dump_file == INVALID_HANDLE_VALUE)
- {
- error.SetError(::GetLastError(), lldb::eErrorTypeWin32);
- return error;
- }
+ if (list->SizeOfEntry < sizeof(MINIDUMP_MEMORY_INFO)) {
+ error.SetErrorString("the entries in the mini dump memory info list are "
+ "smaller than expected");
+ return error;
+ }
- m_mapping = ::CreateFileMappingW(m_dump_file, NULL, PAGE_READONLY, 0, 0, NULL);
- if (m_mapping == NULL)
- {
- error.SetError(::GetLastError(), lldb::eErrorTypeWin32);
- return error;
- }
+ if (size < list->SizeOfHeader + list->SizeOfEntry * list->NumberOfEntries) {
+ error.SetErrorString("the mini dump memory info list is incomplete");
+ return error;
+ }
- m_base_addr = ::MapViewOfFile(m_mapping, FILE_MAP_READ, 0, 0, 0);
- if (m_base_addr == nullptr)
- {
- error.SetError(::GetLastError(), lldb::eErrorTypeWin32);
- return error;
- }
+ const MINIDUMP_MEMORY_INFO *next_entry = nullptr;
+ for (int i = 0; i < list->NumberOfEntries; ++i) {
+ const auto entry = reinterpret_cast<const MINIDUMP_MEMORY_INFO *>(
+ reinterpret_cast<const char *>(list) + list->SizeOfHeader +
+ i * list->SizeOfEntry);
+ const auto head = entry->BaseAddress;
+ const auto tail = head + entry->RegionSize;
+ if (head <= load_addr && load_addr < tail) {
+ info.GetRange().SetRangeBase((entry->State != MEM_FREE) ? head
+ : load_addr);
+ info.GetRange().SetRangeEnd(tail);
+ info.SetReadable(IsPageReadable(entry->Protect) ? MemoryRegionInfo::eYes
+ : MemoryRegionInfo::eNo);
+ info.SetWritable(IsPageWritable(entry->Protect) ? MemoryRegionInfo::eYes
+ : MemoryRegionInfo::eNo);
+ info.SetExecutable(IsPageExecutable(entry->Protect)
+ ? MemoryRegionInfo::eYes
+ : MemoryRegionInfo::eNo);
+ info.SetMapped((entry->State != MEM_FREE) ? MemoryRegionInfo::eYes
+ : MemoryRegionInfo::eNo);
+ return error;
+ } else if (head > load_addr &&
+ (next_entry == nullptr || head < next_entry->BaseAddress)) {
+ // In case there is no region containing load_addr keep track of the
+ // nearest region
+ // after load_addr so we can return the distance to it.
+ next_entry = entry;
+ }
+ }
+
+ // No containing region found. Create an unmapped region that extends to the
+ // next region
+ // or LLDB_INVALID_ADDRESS
+ info.GetRange().SetRangeBase(load_addr);
+ info.GetRange().SetRangeEnd((next_entry != nullptr) ? next_entry->BaseAddress
+ : LLDB_INVALID_ADDRESS);
+ info.SetReadable(MemoryRegionInfo::eNo);
+ info.SetWritable(MemoryRegionInfo::eNo);
+ info.SetExecutable(MemoryRegionInfo::eNo);
+ info.SetMapped(MemoryRegionInfo::eNo);
+
+ // Note that the memory info list doesn't seem to contain ranges in kernel
+ // space,
+ // so if you're walking a stack that has kernel frames, the stack may appear
+ // truncated.
+ return error;
+}
+
+bool ProcessWinMiniDump::Impl::FindMemoryRange(lldb::addr_t addr,
+ Range *range_out) const {
+ size_t stream_size = 0;
+ auto mem_list_stream = static_cast<const MINIDUMP_MEMORY_LIST *>(
+ FindDumpStream(MemoryListStream, &stream_size));
+ if (mem_list_stream) {
+ for (ULONG32 i = 0; i < mem_list_stream->NumberOfMemoryRanges; ++i) {
+ const MINIDUMP_MEMORY_DESCRIPTOR &mem_desc =
+ mem_list_stream->MemoryRanges[i];
+ const MINIDUMP_LOCATION_DESCRIPTOR &loc_desc = mem_desc.Memory;
+ const lldb::addr_t range_start = mem_desc.StartOfMemoryRange;
+ const size_t range_size = loc_desc.DataSize;
+ if (range_start <= addr && addr < range_start + range_size) {
+ range_out->start = range_start;
+ range_out->size = range_size;
+ range_out->ptr =
+ reinterpret_cast<const uint8_t *>(m_base_addr) + loc_desc.Rva;
+ return true;
+ }
+ }
+ }
+
+ // Some mini dumps have a Memory64ListStream that captures all the heap
+ // memory. We can't exactly use the same loop as above, because the mini
+ // dump uses slightly different data structures to describe those.
+ auto mem_list64_stream = static_cast<const MINIDUMP_MEMORY64_LIST *>(
+ FindDumpStream(Memory64ListStream, &stream_size));
+ if (mem_list64_stream) {
+ size_t base_rva = mem_list64_stream->BaseRva;
+ for (ULONG32 i = 0; i < mem_list64_stream->NumberOfMemoryRanges; ++i) {
+ const MINIDUMP_MEMORY_DESCRIPTOR64 &mem_desc =
+ mem_list64_stream->MemoryRanges[i];
+ const lldb::addr_t range_start = mem_desc.StartOfMemoryRange;
+ const size_t range_size = mem_desc.DataSize;
+ if (range_start <= addr && addr < range_start + range_size) {
+ range_out->start = range_start;
+ range_out->size = range_size;
+ range_out->ptr =
+ reinterpret_cast<const uint8_t *>(m_base_addr) + base_rva;
+ return true;
+ }
+ base_rva += range_size;
+ }
+ }
+
+ return false;
+}
+
+Error ProcessWinMiniDump::Impl::MapMiniDumpIntoMemory() {
+ Error error;
+ const char *file = m_core_file.GetCString();
+ std::wstring wfile;
+ if (!llvm::ConvertUTF8toWide(file, wfile)) {
+ error.SetErrorString("Error converting path to UTF-16");
return error;
-}
+ }
+ m_dump_file = ::CreateFileW(wfile.c_str(), GENERIC_READ, FILE_SHARE_READ,
+ NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
+ if (m_dump_file == INVALID_HANDLE_VALUE) {
+ error.SetError(::GetLastError(), lldb::eErrorTypeWin32);
+ return error;
+ }
-ArchSpec
-ProcessWinMiniDump::Impl::DetermineArchitecture()
-{
- size_t size = 0;
- auto system_info_ptr = static_cast<const MINIDUMP_SYSTEM_INFO *>(FindDumpStream(SystemInfoStream, &size));
- if (system_info_ptr)
- {
- switch (system_info_ptr->ProcessorArchitecture)
- {
- case PROCESSOR_ARCHITECTURE_INTEL:
- if (system_info_ptr->ProcessorLevel == 6)
- {
- return ArchSpec("i686-pc-windows");
- }
- else
- {
- return ArchSpec("i386-pc-windows");
- }
- break;
- case PROCESSOR_ARCHITECTURE_AMD64:
- return ArchSpec("x86_64-pc-windows");
- default:
- break;
- }
- }
+ m_mapping =
+ ::CreateFileMappingW(m_dump_file, NULL, PAGE_READONLY, 0, 0, NULL);
+ if (m_mapping == NULL) {
+ error.SetError(::GetLastError(), lldb::eErrorTypeWin32);
+ return error;
+ }
- return ArchSpec(); // invalid or unknown
-}
+ m_base_addr = ::MapViewOfFile(m_mapping, FILE_MAP_READ, 0, 0, 0);
+ if (m_base_addr == nullptr) {
+ error.SetError(::GetLastError(), lldb::eErrorTypeWin32);
+ return error;
+ }
-void
-ProcessWinMiniDump::Impl::ReadExceptionRecord()
-{
- size_t size = 0;
- auto exception_stream_ptr = static_cast<MINIDUMP_EXCEPTION_STREAM*>(FindDumpStream(ExceptionStream, &size));
- if (exception_stream_ptr)
- {
- m_exception_sp.reset(
- new ExceptionRecord(exception_stream_ptr->ExceptionRecord, exception_stream_ptr->ThreadId));
- }
- else
- {
- WINLOG_IFALL(WINDOWS_LOG_PROCESS, "Minidump has no exception record.");
- // TODO: See if we can recover the exception from the TEB.
- }
+ return error;
}
-void
-ProcessWinMiniDump::Impl::ReadMiscInfo()
-{
- size_t size = 0;
- const auto misc_info_ptr = static_cast<MINIDUMP_MISC_INFO*>(FindDumpStream(MiscInfoStream, &size));
- if (!misc_info_ptr || size < sizeof(MINIDUMP_MISC_INFO)) {
- return;
- }
-
- if ((misc_info_ptr->Flags1 & MINIDUMP_MISC1_PROCESS_ID) != 0) {
- // This misc info record has the process ID.
- m_self->SetID(misc_info_ptr->ProcessId);
- }
+ArchSpec ProcessWinMiniDump::Impl::DetermineArchitecture() {
+ size_t size = 0;
+ auto system_info_ptr = static_cast<const MINIDUMP_SYSTEM_INFO *>(
+ FindDumpStream(SystemInfoStream, &size));
+ if (system_info_ptr) {
+ switch (system_info_ptr->ProcessorArchitecture) {
+ case PROCESSOR_ARCHITECTURE_INTEL:
+ if (system_info_ptr->ProcessorLevel == 6) {
+ return ArchSpec("i686-pc-windows");
+ } else {
+ return ArchSpec("i386-pc-windows");
+ }
+ break;
+ case PROCESSOR_ARCHITECTURE_AMD64:
+ return ArchSpec("x86_64-pc-windows");
+ default:
+ break;
+ }
+ }
+
+ return ArchSpec(); // invalid or unknown
+}
+
+void ProcessWinMiniDump::Impl::ReadExceptionRecord() {
+ size_t size = 0;
+ auto exception_stream_ptr = static_cast<MINIDUMP_EXCEPTION_STREAM *>(
+ FindDumpStream(ExceptionStream, &size));
+ if (exception_stream_ptr) {
+ m_exception_sp.reset(new ExceptionRecord(
+ exception_stream_ptr->ExceptionRecord, exception_stream_ptr->ThreadId));
+ } else {
+ WINLOG_IFALL(WINDOWS_LOG_PROCESS, "Minidump has no exception record.");
+ // TODO: See if we can recover the exception from the TEB.
+ }
+}
+
+void ProcessWinMiniDump::Impl::ReadMiscInfo() {
+ size_t size = 0;
+ const auto misc_info_ptr =
+ static_cast<MINIDUMP_MISC_INFO *>(FindDumpStream(MiscInfoStream, &size));
+ if (!misc_info_ptr || size < sizeof(MINIDUMP_MISC_INFO)) {
+ return;
+ }
+
+ if ((misc_info_ptr->Flags1 & MINIDUMP_MISC1_PROCESS_ID) != 0) {
+ // This misc info record has the process ID.
+ m_self->SetID(misc_info_ptr->ProcessId);
+ }
+}
+
+void ProcessWinMiniDump::Impl::ReadModuleList() {
+ size_t size = 0;
+ auto module_list_ptr = static_cast<MINIDUMP_MODULE_LIST *>(
+ FindDumpStream(ModuleListStream, &size));
+ if (!module_list_ptr || module_list_ptr->NumberOfModules == 0) {
+ return;
+ }
+
+ for (ULONG32 i = 0; i < module_list_ptr->NumberOfModules; ++i) {
+ const auto &module = module_list_ptr->Modules[i];
+ const auto file_name = GetMiniDumpString(module.ModuleNameRva);
+ const auto file_spec = FileSpec(file_name, true);
+ if (FileSpec::Compare(file_spec, FileSpec("wow64.dll", false), false) ==
+ 0) {
+ WINLOG_IFALL(WINDOWS_LOG_PROCESS, "Minidump is for a WOW64 process.");
+ m_is_wow64 = true;
+ }
+ ModuleSpec module_spec = file_spec;
+
+ lldb::ModuleSP module_sp = m_self->GetTarget().GetSharedModule(module_spec);
+ if (!module_sp) {
+ continue;
+ }
+ bool load_addr_changed = false;
+ module_sp->SetLoadAddress(m_self->GetTarget(), module.BaseOfImage, false,
+ load_addr_changed);
+ }
+}
+
+void *ProcessWinMiniDump::Impl::FindDumpStream(unsigned stream_number,
+ size_t *size_out) const {
+ void *stream = nullptr;
+ *size_out = 0;
+
+ MINIDUMP_DIRECTORY *dir = nullptr;
+ if (::MiniDumpReadDumpStream(m_base_addr, stream_number, &dir, nullptr,
+ nullptr) &&
+ dir != nullptr && dir->Location.DataSize > 0) {
+ assert(dir->StreamType == stream_number);
+ *size_out = dir->Location.DataSize;
+ stream = static_cast<void *>(static_cast<char *>(m_base_addr) +
+ dir->Location.Rva);
+ }
+
+ return stream;
+}
+
+std::string ProcessWinMiniDump::Impl::GetMiniDumpString(RVA rva) const {
+ std::string result;
+ if (!m_base_addr) {
+ return result;
+ }
+ auto md_string = reinterpret_cast<const MINIDUMP_STRING *>(
+ static_cast<const char *>(m_base_addr) + rva);
+ auto source_start = reinterpret_cast<const UTF16 *>(md_string->Buffer);
+ const auto source_length = ::wcslen(md_string->Buffer);
+ const auto source_end = source_start + source_length;
+ result.resize(UNI_MAX_UTF8_BYTES_PER_CODE_POINT *
+ source_length); // worst case length
+ auto result_start = reinterpret_cast<UTF8 *>(&result[0]);
+ const auto result_end = result_start + result.size();
+ ConvertUTF16toUTF8(&source_start, source_end, &result_start, result_end,
+ strictConversion);
+ const auto result_size =
+ std::distance(reinterpret_cast<UTF8 *>(&result[0]), result_start);
+ result.resize(result_size); // shrink to actual length
+ return result;
}
-void
-ProcessWinMiniDump::Impl::ReadModuleList()
-{
- size_t size = 0;
- auto module_list_ptr = static_cast<MINIDUMP_MODULE_LIST*>(FindDumpStream(ModuleListStream, &size));
- if (!module_list_ptr || module_list_ptr->NumberOfModules == 0)
- {
- return;
- }
-
- for (ULONG32 i = 0; i < module_list_ptr->NumberOfModules; ++i)
- {
- const auto &module = module_list_ptr->Modules[i];
- const auto file_name = GetMiniDumpString(module.ModuleNameRva);
- const auto file_spec = FileSpec(file_name, true);
- if (FileSpec::Compare(file_spec, FileSpec("wow64.dll", false), false) == 0)
- {
- WINLOG_IFALL(WINDOWS_LOG_PROCESS, "Minidump is for a WOW64 process.");
- m_is_wow64 = true;
- }
- ModuleSpec module_spec = file_spec;
-
- lldb::ModuleSP module_sp = m_self->GetTarget().GetSharedModule(module_spec);
- if (!module_sp)
- {
- continue;
- }
- bool load_addr_changed = false;
- module_sp->SetLoadAddress(m_self->GetTarget(), module.BaseOfImage, false, load_addr_changed);
- }
+ConstString ProcessWinMiniDump::GetPluginNameStatic() {
+ static ConstString g_name("win-minidump");
+ return g_name;
}
-void *
-ProcessWinMiniDump::Impl::FindDumpStream(unsigned stream_number, size_t *size_out) const
-{
- void *stream = nullptr;
- *size_out = 0;
-
- MINIDUMP_DIRECTORY *dir = nullptr;
- if (::MiniDumpReadDumpStream(m_base_addr, stream_number, &dir, nullptr, nullptr) && dir != nullptr &&
- dir->Location.DataSize > 0)
- {
- assert(dir->StreamType == stream_number);
- *size_out = dir->Location.DataSize;
- stream = static_cast<void *>(static_cast<char *>(m_base_addr) + dir->Location.Rva);
- }
-
- return stream;
+const char *ProcessWinMiniDump::GetPluginDescriptionStatic() {
+ return "Windows minidump plug-in.";
}
-std::string
-ProcessWinMiniDump::Impl::GetMiniDumpString(RVA rva) const
-{
- std::string result;
- if (!m_base_addr)
- {
- return result;
- }
- auto md_string = reinterpret_cast<const MINIDUMP_STRING *>(static_cast<const char *>(m_base_addr) + rva);
- auto source_start = reinterpret_cast<const UTF16 *>(md_string->Buffer);
- const auto source_length = ::wcslen(md_string->Buffer);
- const auto source_end = source_start + source_length;
- result.resize(UNI_MAX_UTF8_BYTES_PER_CODE_POINT * source_length); // worst case length
- auto result_start = reinterpret_cast<UTF8 *>(&result[0]);
- const auto result_end = result_start + result.size();
- ConvertUTF16toUTF8(&source_start, source_end, &result_start, result_end, strictConversion);
- const auto result_size = std::distance(reinterpret_cast<UTF8 *>(&result[0]), result_start);
- result.resize(result_size); // shrink to actual length
- return result;
+void ProcessWinMiniDump::Terminate() {
+ PluginManager::UnregisterPlugin(ProcessWinMiniDump::CreateInstance);
}
-ConstString
-ProcessWinMiniDump::GetPluginNameStatic()
-{
- static ConstString g_name("win-minidump");
- return g_name;
-}
-
-const char *
-ProcessWinMiniDump::GetPluginDescriptionStatic()
-{
- return "Windows minidump plug-in.";
-}
-
-void
-ProcessWinMiniDump::Terminate()
-{
- PluginManager::UnregisterPlugin(ProcessWinMiniDump::CreateInstance);
-}
-
-lldb::ProcessSP
-ProcessWinMiniDump::CreateInstance(lldb::TargetSP target_sp, lldb::ListenerSP listener_sp, const FileSpec *crash_file)
-{
- lldb::ProcessSP process_sp;
- if (crash_file)
- {
- process_sp.reset(new ProcessWinMiniDump(target_sp, listener_sp, *crash_file));
- }
- return process_sp;
+lldb::ProcessSP ProcessWinMiniDump::CreateInstance(lldb::TargetSP target_sp,
+ lldb::ListenerSP listener_sp,
+ const FileSpec *crash_file) {
+ lldb::ProcessSP process_sp;
+ if (crash_file) {
+ process_sp.reset(
+ new ProcessWinMiniDump(target_sp, listener_sp, *crash_file));
+ }
+ return process_sp;
}
-bool
-ProcessWinMiniDump::CanDebug(lldb::TargetSP target_sp, bool plugin_specified_by_name)
-{
- // TODO(amccarth): Eventually, this needs some actual logic.
- return true;
+bool ProcessWinMiniDump::CanDebug(lldb::TargetSP target_sp,
+ bool plugin_specified_by_name) {
+ // TODO(amccarth): Eventually, this needs some actual logic.
+ return true;
}
-ProcessWinMiniDump::ProcessWinMiniDump(lldb::TargetSP target_sp, lldb::ListenerSP listener_sp, const FileSpec &core_file)
- : ProcessWindows(target_sp, listener_sp), m_impl_up(new Impl(core_file, this))
-{
-}
+ProcessWinMiniDump::ProcessWinMiniDump(lldb::TargetSP target_sp,
+ lldb::ListenerSP listener_sp,
+ const FileSpec &core_file)
+ : ProcessWindows(target_sp, listener_sp),
+ m_impl_up(new Impl(core_file, this)) {}
-ProcessWinMiniDump::~ProcessWinMiniDump()
-{
- Clear();
- // We need to call finalize on the process before destroying ourselves
- // to make sure all of the broadcaster cleanup goes as planned. If we
- // destruct this class, then Process::~Process() might have problems
- // trying to fully destroy the broadcaster.
- Finalize();
+ProcessWinMiniDump::~ProcessWinMiniDump() {
+ Clear();
+ // We need to call finalize on the process before destroying ourselves
+ // to make sure all of the broadcaster cleanup goes as planned. If we
+ // destruct this class, then Process::~Process() might have problems
+ // trying to fully destroy the broadcaster.
+ Finalize();
}
-ConstString
-ProcessWinMiniDump::GetPluginName()
-{
- return GetPluginNameStatic();
+ConstString ProcessWinMiniDump::GetPluginName() {
+ return GetPluginNameStatic();
}
-uint32_t
-ProcessWinMiniDump::GetPluginVersion()
-{
- return 1;
-}
+uint32_t ProcessWinMiniDump::GetPluginVersion() { return 1; }
-Error
-ProcessWinMiniDump::DoLoadCore()
-{
- return m_impl_up->DoLoadCore();
-}
+Error ProcessWinMiniDump::DoLoadCore() { return m_impl_up->DoLoadCore(); }
-DynamicLoader *
-ProcessWinMiniDump::GetDynamicLoader()
-{
- if (m_dyld_ap.get() == NULL)
- m_dyld_ap.reset(DynamicLoader::FindPlugin(this, DynamicLoaderWindowsDYLD::GetPluginNameStatic().GetCString()));
- return m_dyld_ap.get();
+DynamicLoader *ProcessWinMiniDump::GetDynamicLoader() {
+ if (m_dyld_ap.get() == NULL)
+ m_dyld_ap.reset(DynamicLoader::FindPlugin(
+ this, DynamicLoaderWindowsDYLD::GetPluginNameStatic().GetCString()));
+ return m_dyld_ap.get();
}
-bool
-ProcessWinMiniDump::UpdateThreadList(ThreadList &old_thread_list, ThreadList &new_thread_list)
-{
- return m_impl_up->UpdateThreadList(old_thread_list, new_thread_list);
+bool ProcessWinMiniDump::UpdateThreadList(ThreadList &old_thread_list,
+ ThreadList &new_thread_list) {
+ return m_impl_up->UpdateThreadList(old_thread_list, new_thread_list);
}
-void
-ProcessWinMiniDump::RefreshStateAfterStop()
-{
- if (!m_impl_up)
- return;
- return m_impl_up->RefreshStateAfterStop();
+void ProcessWinMiniDump::RefreshStateAfterStop() {
+ if (!m_impl_up)
+ return;
+ return m_impl_up->RefreshStateAfterStop();
}
-Error
-ProcessWinMiniDump::DoDestroy()
-{
- return Error();
-}
+Error ProcessWinMiniDump::DoDestroy() { return Error(); }
-bool
-ProcessWinMiniDump::IsAlive()
-{
- return true;
-}
+bool ProcessWinMiniDump::IsAlive() { return true; }
-bool
-ProcessWinMiniDump::WarnBeforeDetach() const
-{
- // Since this is post-mortem debugging, there's no need to warn the user
- // that quitting the debugger will terminate the process.
- return false;
+bool ProcessWinMiniDump::WarnBeforeDetach() const {
+ // Since this is post-mortem debugging, there's no need to warn the user
+ // that quitting the debugger will terminate the process.
+ return false;
}
-size_t
-ProcessWinMiniDump::ReadMemory(lldb::addr_t addr, void *buf, size_t size, Error &error)
-{
- // Don't allow the caching that lldb_private::Process::ReadMemory does
- // since we have it all cached our our dump file anyway.
- return DoReadMemory(addr, buf, size, error);
+size_t ProcessWinMiniDump::ReadMemory(lldb::addr_t addr, void *buf, size_t size,
+ Error &error) {
+ // Don't allow the caching that lldb_private::Process::ReadMemory does
+ // since we have it all cached our our dump file anyway.
+ return DoReadMemory(addr, buf, size, error);
}
-size_t
-ProcessWinMiniDump::DoReadMemory(lldb::addr_t addr, void *buf, size_t size, Error &error)
-{
- return m_impl_up->DoReadMemory(addr, buf, size, error);
+size_t ProcessWinMiniDump::DoReadMemory(lldb::addr_t addr, void *buf,
+ size_t size, Error &error) {
+ return m_impl_up->DoReadMemory(addr, buf, size, error);
}
-Error
-ProcessWinMiniDump::GetMemoryRegionInfo(lldb::addr_t load_addr, lldb_private::MemoryRegionInfo &info)
-{
- return m_impl_up->GetMemoryRegionInfo(load_addr, info);
+Error ProcessWinMiniDump::GetMemoryRegionInfo(
+ lldb::addr_t load_addr, lldb_private::MemoryRegionInfo &info) {
+ return m_impl_up->GetMemoryRegionInfo(load_addr, info);
}
-void
-ProcessWinMiniDump::Clear()
-{
- m_thread_list.Clear();
-}
+void ProcessWinMiniDump::Clear() { m_thread_list.Clear(); }
-void
-ProcessWinMiniDump::Initialize()
-{
- static std::once_flag g_once_flag;
+void ProcessWinMiniDump::Initialize() {
+ static std::once_flag g_once_flag;
- std::call_once(g_once_flag, []() {
- PluginManager::RegisterPlugin(GetPluginNameStatic(), GetPluginDescriptionStatic(), CreateInstance);
- });
+ std::call_once(g_once_flag, []() {
+ PluginManager::RegisterPlugin(GetPluginNameStatic(),
+ GetPluginDescriptionStatic(), CreateInstance);
+ });
}
-ArchSpec
-ProcessWinMiniDump::GetArchitecture()
-{
- // TODO
- return ArchSpec();
+ArchSpec ProcessWinMiniDump::GetArchitecture() {
+ // TODO
+ return ArchSpec();
}
Modified: lldb/trunk/source/Plugins/Process/Windows/MiniDump/ProcessWinMiniDump.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Windows/MiniDump/ProcessWinMiniDump.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/Windows/MiniDump/ProcessWinMiniDump.h (original)
+++ lldb/trunk/source/Plugins/Process/Windows/MiniDump/ProcessWinMiniDump.h Tue Sep 6 15:57:50 2016
@@ -21,84 +21,66 @@
struct ThreadData;
-class ProcessWinMiniDump : public lldb_private::ProcessWindows
-{
- public:
- static lldb::ProcessSP
- CreateInstance (lldb::TargetSP target_sp,
- lldb::ListenerSP listener_sp,
- const lldb_private::FileSpec *crash_file_path);
+class ProcessWinMiniDump : public lldb_private::ProcessWindows {
+public:
+ static lldb::ProcessSP
+ CreateInstance(lldb::TargetSP target_sp, lldb::ListenerSP listener_sp,
+ const lldb_private::FileSpec *crash_file_path);
- static void
- Initialize();
+ static void Initialize();
- static void
- Terminate();
+ static void Terminate();
- static lldb_private::ConstString
- GetPluginNameStatic();
+ static lldb_private::ConstString GetPluginNameStatic();
- static const char *
- GetPluginDescriptionStatic();
+ static const char *GetPluginDescriptionStatic();
- ProcessWinMiniDump(lldb::TargetSP target_sp,
- lldb::ListenerSP listener_sp,
- const lldb_private::FileSpec &core_file);
+ ProcessWinMiniDump(lldb::TargetSP target_sp, lldb::ListenerSP listener_sp,
+ const lldb_private::FileSpec &core_file);
- virtual
- ~ProcessWinMiniDump();
+ virtual ~ProcessWinMiniDump();
- bool
- CanDebug(lldb::TargetSP target_sp, bool plugin_specified_by_name) override;
+ bool CanDebug(lldb::TargetSP target_sp,
+ bool plugin_specified_by_name) override;
- lldb_private::Error
- DoLoadCore() override;
+ lldb_private::Error DoLoadCore() override;
- lldb_private::DynamicLoader *
- GetDynamicLoader() override;
+ lldb_private::DynamicLoader *GetDynamicLoader() override;
- lldb_private::ConstString
- GetPluginName() override;
+ lldb_private::ConstString GetPluginName() override;
- uint32_t
- GetPluginVersion() override;
+ uint32_t GetPluginVersion() override;
- lldb_private::Error
- DoDestroy() override;
+ lldb_private::Error DoDestroy() override;
- void
- RefreshStateAfterStop() override;
+ void RefreshStateAfterStop() override;
- bool
- IsAlive() override;
+ bool IsAlive() override;
- bool
- WarnBeforeDetach () const override;
+ bool WarnBeforeDetach() const override;
- size_t
- ReadMemory(lldb::addr_t addr, void *buf, size_t size, lldb_private::Error &error) override;
+ size_t ReadMemory(lldb::addr_t addr, void *buf, size_t size,
+ lldb_private::Error &error) override;
- size_t
- DoReadMemory(lldb::addr_t addr, void *buf, size_t size, lldb_private::Error &error) override;
+ size_t DoReadMemory(lldb::addr_t addr, void *buf, size_t size,
+ lldb_private::Error &error) override;
- lldb_private::ArchSpec
- GetArchitecture();
+ lldb_private::ArchSpec GetArchitecture();
- lldb_private::Error
- GetMemoryRegionInfo(lldb::addr_t load_addr, lldb_private::MemoryRegionInfo &range_info) override;
+ lldb_private::Error
+ GetMemoryRegionInfo(lldb::addr_t load_addr,
+ lldb_private::MemoryRegionInfo &range_info) override;
- protected:
- void
- Clear();
+protected:
+ void Clear();
- bool
- UpdateThreadList(lldb_private::ThreadList &old_thread_list,
- lldb_private::ThreadList &new_thread_list) override;
+ bool UpdateThreadList(lldb_private::ThreadList &old_thread_list,
+ lldb_private::ThreadList &new_thread_list) override;
- private:
- // Keep Windows-specific types out of this header.
- class Impl;
- std::unique_ptr<Impl> m_impl_up;
+private:
+ // Keep Windows-specific types out of this header.
+ class Impl;
+ std::unique_ptr<Impl> m_impl_up;
};
-#endif // liblldb_ProcessWinMiniDump_h_
+#endif // liblldb_ProcessWinMiniDump_h_
Modified: lldb/trunk/source/Plugins/Process/Windows/MiniDump/ThreadWinMiniDump.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Windows/MiniDump/ThreadWinMiniDump.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/Windows/MiniDump/ThreadWinMiniDump.cpp (original)
+++ lldb/trunk/source/Plugins/Process/Windows/MiniDump/ThreadWinMiniDump.cpp Tue Sep 6 15:57:50 2016
@@ -27,78 +27,61 @@ using namespace lldb_private;
// be fleshed out as more mini-dump functionality is added.
class ThreadWinMiniDump::Data {
- public:
- Data() : m_context(nullptr) {}
- const CONTEXT *m_context;
+public:
+ Data() : m_context(nullptr) {}
+ const CONTEXT *m_context;
};
-ThreadWinMiniDump::ThreadWinMiniDump(lldb_private::Process &process, lldb::tid_t tid) :
- Thread(process, tid),
- m_data(new Data)
-{
-}
-
-ThreadWinMiniDump::~ThreadWinMiniDump()
-{
-}
-
-void
-ThreadWinMiniDump::RefreshStateAfterStop()
-{
-}
-
-lldb::RegisterContextSP
-ThreadWinMiniDump::GetRegisterContext()
-{
- if (m_reg_context_sp.get() == NULL) {
- m_reg_context_sp = CreateRegisterContextForFrame (NULL);
- }
- return m_reg_context_sp;
-}
-
-lldb::RegisterContextSP
-ThreadWinMiniDump::CreateRegisterContextForFrame(lldb_private::StackFrame *frame)
-{
- const uint32_t concrete_frame_idx = (frame) ? frame->GetConcreteFrameIndex() : 0;
- RegisterContextSP reg_ctx_sp;
- ArchSpec arch = HostInfo::GetArchitecture();
- switch (arch.GetMachine())
- {
- case llvm::Triple::x86:
+ThreadWinMiniDump::ThreadWinMiniDump(lldb_private::Process &process,
+ lldb::tid_t tid)
+ : Thread(process, tid), m_data(new Data) {}
+
+ThreadWinMiniDump::~ThreadWinMiniDump() {}
+
+void ThreadWinMiniDump::RefreshStateAfterStop() {}
+
+lldb::RegisterContextSP ThreadWinMiniDump::GetRegisterContext() {
+ if (m_reg_context_sp.get() == NULL) {
+ m_reg_context_sp = CreateRegisterContextForFrame(NULL);
+ }
+ return m_reg_context_sp;
+}
+
+lldb::RegisterContextSP ThreadWinMiniDump::CreateRegisterContextForFrame(
+ lldb_private::StackFrame *frame) {
+ const uint32_t concrete_frame_idx =
+ (frame) ? frame->GetConcreteFrameIndex() : 0;
+ RegisterContextSP reg_ctx_sp;
+ ArchSpec arch = HostInfo::GetArchitecture();
+ switch (arch.GetMachine()) {
+ case llvm::Triple::x86:
#if defined(_WIN64)
- // FIXME: This is a Wow64 process, create a RegisterContextWindows_Wow64
+// FIXME: This is a Wow64 process, create a RegisterContextWindows_Wow64
#else
- reg_ctx_sp.reset(new RegisterContextWindowsMiniDump_x86(*this, concrete_frame_idx, m_data->m_context));
+ reg_ctx_sp.reset(new RegisterContextWindowsMiniDump_x86(
+ *this, concrete_frame_idx, m_data->m_context));
#endif
- break;
- case llvm::Triple::x86_64:
+ break;
+ case llvm::Triple::x86_64:
#if defined(_WIN64)
- reg_ctx_sp.reset(new RegisterContextWindowsMiniDump_x64(*this, concrete_frame_idx, m_data->m_context));
+ reg_ctx_sp.reset(new RegisterContextWindowsMiniDump_x64(
+ *this, concrete_frame_idx, m_data->m_context));
#else
- // LLDB is 32-bit, but the target process is 64-bit. We probably can't debug this.
+// LLDB is 32-bit, but the target process is 64-bit. We probably can't debug
+// this.
#endif
- default:
- break;
- }
- return reg_ctx_sp;
+ default:
+ break;
+ }
+ return reg_ctx_sp;
}
-void
-ThreadWinMiniDump::ClearStackFrames()
-{
-}
+void ThreadWinMiniDump::ClearStackFrames() {}
-void
-ThreadWinMiniDump::SetContext(const void *context)
-{
- if (m_data)
- {
- m_data->m_context = static_cast<const CONTEXT *>(context);
- }
+void ThreadWinMiniDump::SetContext(const void *context) {
+ if (m_data) {
+ m_data->m_context = static_cast<const CONTEXT *>(context);
+ }
}
-bool
-ThreadWinMiniDump::CalculateStopInfo()
-{
- return false;
-}
+bool ThreadWinMiniDump::CalculateStopInfo() { return false; }
Modified: lldb/trunk/source/Plugins/Process/Windows/MiniDump/ThreadWinMiniDump.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Windows/MiniDump/ThreadWinMiniDump.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/Windows/MiniDump/ThreadWinMiniDump.h (original)
+++ lldb/trunk/source/Plugins/Process/Windows/MiniDump/ThreadWinMiniDump.h Tue Sep 6 15:57:50 2016
@@ -15,35 +15,29 @@
#include "lldb/Core/DataExtractor.h"
#include "lldb/Target/Thread.h"
-class ThreadWinMiniDump : public lldb_private::Thread
-{
+class ThreadWinMiniDump : public lldb_private::Thread {
public:
- ThreadWinMiniDump(lldb_private::Process &process, lldb::tid_t tid);
+ ThreadWinMiniDump(lldb_private::Process &process, lldb::tid_t tid);
- virtual
- ~ThreadWinMiniDump();
+ virtual ~ThreadWinMiniDump();
- void
- RefreshStateAfterStop() override;
+ void RefreshStateAfterStop() override;
- lldb::RegisterContextSP
- GetRegisterContext() override;
+ lldb::RegisterContextSP GetRegisterContext() override;
- lldb::RegisterContextSP
- CreateRegisterContextForFrame(lldb_private::StackFrame *frame) override;
+ lldb::RegisterContextSP
+ CreateRegisterContextForFrame(lldb_private::StackFrame *frame) override;
- void
- ClearStackFrames() override;
+ void ClearStackFrames() override;
- void
- SetContext(const void *context);
+ void SetContext(const void *context);
protected:
- lldb::RegisterContextSP m_reg_context_sp;
- class Data;
- std::unique_ptr<Data> m_data; // for WinAPI-specific data
+ lldb::RegisterContextSP m_reg_context_sp;
+ class Data;
+ std::unique_ptr<Data> m_data; // for WinAPI-specific data
- bool CalculateStopInfo() override;
+ bool CalculateStopInfo() override;
};
#endif
Modified: lldb/trunk/source/Plugins/Process/Windows/MiniDump/x64/RegisterContextWindowsMiniDump_x64.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Windows/MiniDump/x64/RegisterContextWindowsMiniDump_x64.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/Windows/MiniDump/x64/RegisterContextWindowsMiniDump_x64.cpp (original)
+++ lldb/trunk/source/Plugins/Process/Windows/MiniDump/x64/RegisterContextWindowsMiniDump_x64.cpp Tue Sep 6 15:57:50 2016
@@ -7,41 +7,36 @@
//
//===----------------------------------------------------------------------===//
-#include "lldb/lldb-private-types.h"
#include "lldb/Host/windows/windows.h"
+#include "lldb/lldb-private-types.h"
#include "RegisterContextWindowsMiniDump_x64.h"
using namespace lldb;
-namespace lldb_private
-{
+namespace lldb_private {
-RegisterContextWindowsMiniDump_x64::RegisterContextWindowsMiniDump_x64(Thread &thread, uint32_t concrete_frame_idx, const CONTEXT *context)
- : RegisterContextWindows_x64(thread, concrete_frame_idx)
-{
- if (context)
- {
- m_context = *context;
- m_context_stale = false;
- }
+RegisterContextWindowsMiniDump_x64::RegisterContextWindowsMiniDump_x64(
+ Thread &thread, uint32_t concrete_frame_idx, const CONTEXT *context)
+ : RegisterContextWindows_x64(thread, concrete_frame_idx) {
+ if (context) {
+ m_context = *context;
+ m_context_stale = false;
+ }
}
-RegisterContextWindowsMiniDump_x64::~RegisterContextWindowsMiniDump_x64()
-{
-}
+RegisterContextWindowsMiniDump_x64::~RegisterContextWindowsMiniDump_x64() {}
-bool
-RegisterContextWindowsMiniDump_x64::WriteRegister(const RegisterInfo * /* reg_info */, const RegisterValue & /* reg_value */)
-{
- return false;
+bool RegisterContextWindowsMiniDump_x64::WriteRegister(
+ const RegisterInfo * /* reg_info */,
+ const RegisterValue & /* reg_value */) {
+ return false;
}
-bool
-RegisterContextWindowsMiniDump_x64::CacheAllRegisterValues()
-{
- // Since this is post-mortem debugging, we either have the context or we don't.
- return !m_context_stale;
+bool RegisterContextWindowsMiniDump_x64::CacheAllRegisterValues() {
+ // Since this is post-mortem debugging, we either have the context or we
+ // don't.
+ return !m_context_stale;
}
-} // namespace lldb_private
+} // namespace lldb_private
Modified: lldb/trunk/source/Plugins/Process/Windows/MiniDump/x64/RegisterContextWindowsMiniDump_x64.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Windows/MiniDump/x64/RegisterContextWindowsMiniDump_x64.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/Windows/MiniDump/x64/RegisterContextWindowsMiniDump_x64.h (original)
+++ lldb/trunk/source/Plugins/Process/Windows/MiniDump/x64/RegisterContextWindowsMiniDump_x64.h Tue Sep 6 15:57:50 2016
@@ -10,27 +10,27 @@
#ifndef liblldb_RegisterContextWindowsMiniDump_x64_H_
#define liblldb_RegisterContextWindowsMiniDump_x64_H_
-#include "lldb/lldb-forward.h"
#include "Plugins/Process/Windows/Common/x64/RegisterContextWindows_x64.h"
+#include "lldb/lldb-forward.h"
-namespace lldb_private
-{
+namespace lldb_private {
class Thread;
-class RegisterContextWindowsMiniDump_x64 : public RegisterContextWindows_x64
-{
- public:
- RegisterContextWindowsMiniDump_x64(Thread &thread, uint32_t concrete_frame_idx, const CONTEXT *context);
+class RegisterContextWindowsMiniDump_x64 : public RegisterContextWindows_x64 {
+public:
+ RegisterContextWindowsMiniDump_x64(Thread &thread,
+ uint32_t concrete_frame_idx,
+ const CONTEXT *context);
- virtual ~RegisterContextWindowsMiniDump_x64();
+ virtual ~RegisterContextWindowsMiniDump_x64();
- bool WriteRegister(const RegisterInfo *reg_info, const RegisterValue ®_value) override;
+ bool WriteRegister(const RegisterInfo *reg_info,
+ const RegisterValue ®_value) override;
- protected:
- bool CacheAllRegisterValues() override;
+protected:
+ bool CacheAllRegisterValues() override;
};
-
}
#endif // #ifndef liblldb_RegisterContextWindowsMiniDump_x64_H_
Modified: lldb/trunk/source/Plugins/Process/Windows/MiniDump/x86/RegisterContextWindowsMiniDump_x86.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Windows/MiniDump/x86/RegisterContextWindowsMiniDump_x86.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/Windows/MiniDump/x86/RegisterContextWindowsMiniDump_x86.cpp (original)
+++ lldb/trunk/source/Plugins/Process/Windows/MiniDump/x86/RegisterContextWindowsMiniDump_x86.cpp Tue Sep 6 15:57:50 2016
@@ -7,41 +7,36 @@
//
//===----------------------------------------------------------------------===//
-#include "lldb/lldb-private-types.h"
#include "lldb/Host/windows/windows.h"
+#include "lldb/lldb-private-types.h"
#include "RegisterContextWindowsMiniDump_x86.h"
using namespace lldb;
-namespace lldb_private
-{
+namespace lldb_private {
-RegisterContextWindowsMiniDump_x86::RegisterContextWindowsMiniDump_x86(Thread &thread, uint32_t concrete_frame_idx, const CONTEXT *context)
- : RegisterContextWindows_x86(thread, concrete_frame_idx)
-{
- if (context)
- {
- m_context = *context;
- m_context_stale = false;
- }
+RegisterContextWindowsMiniDump_x86::RegisterContextWindowsMiniDump_x86(
+ Thread &thread, uint32_t concrete_frame_idx, const CONTEXT *context)
+ : RegisterContextWindows_x86(thread, concrete_frame_idx) {
+ if (context) {
+ m_context = *context;
+ m_context_stale = false;
+ }
}
-RegisterContextWindowsMiniDump_x86::~RegisterContextWindowsMiniDump_x86()
-{
-}
+RegisterContextWindowsMiniDump_x86::~RegisterContextWindowsMiniDump_x86() {}
-bool
-RegisterContextWindowsMiniDump_x86::WriteRegister(const RegisterInfo * /* reg_info */, const RegisterValue & /* reg_value */)
-{
- return false;
+bool RegisterContextWindowsMiniDump_x86::WriteRegister(
+ const RegisterInfo * /* reg_info */,
+ const RegisterValue & /* reg_value */) {
+ return false;
}
-bool
-RegisterContextWindowsMiniDump_x86::CacheAllRegisterValues()
-{
- // Since this is post-mortem debugging, we either have the context or we don't.
- return !m_context_stale;
+bool RegisterContextWindowsMiniDump_x86::CacheAllRegisterValues() {
+ // Since this is post-mortem debugging, we either have the context or we
+ // don't.
+ return !m_context_stale;
}
-} // namespace lldb_private
+} // namespace lldb_private
Modified: lldb/trunk/source/Plugins/Process/Windows/MiniDump/x86/RegisterContextWindowsMiniDump_x86.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Windows/MiniDump/x86/RegisterContextWindowsMiniDump_x86.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/Windows/MiniDump/x86/RegisterContextWindowsMiniDump_x86.h (original)
+++ lldb/trunk/source/Plugins/Process/Windows/MiniDump/x86/RegisterContextWindowsMiniDump_x86.h Tue Sep 6 15:57:50 2016
@@ -1,4 +1,5 @@
-//===-- RegisterContextWindowsMiniDump_x86.h ------------------------*- C++ -*-===//
+//===-- RegisterContextWindowsMiniDump_x86.h ------------------------*- C++
+//-*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -10,27 +11,27 @@
#ifndef liblldb_RegisterContextWindowsMiniDump_x86_H_
#define liblldb_RegisterContextWindowsMiniDump_x86_H_
-#include "lldb/lldb-forward.h"
#include "Plugins/Process/Windows/Common/x86/RegisterContextWindows_x86.h"
+#include "lldb/lldb-forward.h"
-namespace lldb_private
-{
+namespace lldb_private {
class Thread;
-class RegisterContextWindowsMiniDump_x86 : public RegisterContextWindows_x86
-{
- public:
- RegisterContextWindowsMiniDump_x86(Thread &thread, uint32_t concrete_frame_idx, const CONTEXT *context);
+class RegisterContextWindowsMiniDump_x86 : public RegisterContextWindows_x86 {
+public:
+ RegisterContextWindowsMiniDump_x86(Thread &thread,
+ uint32_t concrete_frame_idx,
+ const CONTEXT *context);
- virtual ~RegisterContextWindowsMiniDump_x86();
+ virtual ~RegisterContextWindowsMiniDump_x86();
- bool WriteRegister(const RegisterInfo *reg_info, const RegisterValue ®_value) override;
+ bool WriteRegister(const RegisterInfo *reg_info,
+ const RegisterValue ®_value) override;
- protected:
- bool CacheAllRegisterValues() override;
+protected:
+ bool CacheAllRegisterValues() override;
};
-
}
#endif // #ifndef liblldb_RegisterContextWindowsMiniDump_x86_H_
Modified: lldb/trunk/source/Plugins/Process/elf-core/ProcessElfCore.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/elf-core/ProcessElfCore.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/elf-core/ProcessElfCore.cpp (original)
+++ lldb/trunk/source/Plugins/Process/elf-core/ProcessElfCore.cpp Tue Sep 6 15:57:50 2016
@@ -28,8 +28,8 @@
#include "llvm/Support/ELF.h"
-#include "Plugins/ObjectFile/ELF/ObjectFileELF.h"
#include "Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.h"
+#include "Plugins/ObjectFile/ELF/ObjectFileELF.h"
// Project includes
#include "ProcessElfCore.h"
@@ -37,485 +37,418 @@
using namespace lldb_private;
-ConstString
-ProcessElfCore::GetPluginNameStatic()
-{
- static ConstString g_name("elf-core");
- return g_name;
-}
-
-const char *
-ProcessElfCore::GetPluginDescriptionStatic()
-{
- return "ELF core dump plug-in.";
-}
-
-void
-ProcessElfCore::Terminate()
-{
- PluginManager::UnregisterPlugin (ProcessElfCore::CreateInstance);
-}
-
-
-lldb::ProcessSP
-ProcessElfCore::CreateInstance (lldb::TargetSP target_sp, lldb::ListenerSP listener_sp, const FileSpec *crash_file)
-{
- lldb::ProcessSP process_sp;
- if (crash_file)
- {
- // Read enough data for a ELF32 header or ELF64 header
- const size_t header_size = sizeof(llvm::ELF::Elf64_Ehdr);
-
- lldb::DataBufferSP data_sp (crash_file->ReadFileContents(0, header_size));
- if (data_sp && data_sp->GetByteSize() == header_size &&
- elf::ELFHeader::MagicBytesMatch (data_sp->GetBytes()))
- {
- elf::ELFHeader elf_header;
- DataExtractor data(data_sp, lldb::eByteOrderLittle, 4);
- lldb::offset_t data_offset = 0;
- if (elf_header.Parse(data, &data_offset))
- {
- if (elf_header.e_type == llvm::ELF::ET_CORE)
- process_sp.reset(new ProcessElfCore (target_sp, listener_sp, *crash_file));
- }
- }
- }
- return process_sp;
-}
-
-bool
-ProcessElfCore::CanDebug(lldb::TargetSP target_sp, bool plugin_specified_by_name)
-{
- // For now we are just making sure the file exists for a given module
- if (!m_core_module_sp && m_core_file.Exists())
- {
- ModuleSpec core_module_spec(m_core_file, target_sp->GetArchitecture());
- Error error (ModuleList::GetSharedModule (core_module_spec, m_core_module_sp,
- NULL, NULL, NULL));
- if (m_core_module_sp)
- {
- ObjectFile *core_objfile = m_core_module_sp->GetObjectFile();
- if (core_objfile && core_objfile->GetType() == ObjectFile::eTypeCoreFile)
- return true;
- }
+ConstString ProcessElfCore::GetPluginNameStatic() {
+ static ConstString g_name("elf-core");
+ return g_name;
+}
+
+const char *ProcessElfCore::GetPluginDescriptionStatic() {
+ return "ELF core dump plug-in.";
+}
+
+void ProcessElfCore::Terminate() {
+ PluginManager::UnregisterPlugin(ProcessElfCore::CreateInstance);
+}
+
+lldb::ProcessSP ProcessElfCore::CreateInstance(lldb::TargetSP target_sp,
+ lldb::ListenerSP listener_sp,
+ const FileSpec *crash_file) {
+ lldb::ProcessSP process_sp;
+ if (crash_file) {
+ // Read enough data for a ELF32 header or ELF64 header
+ const size_t header_size = sizeof(llvm::ELF::Elf64_Ehdr);
+
+ lldb::DataBufferSP data_sp(crash_file->ReadFileContents(0, header_size));
+ if (data_sp && data_sp->GetByteSize() == header_size &&
+ elf::ELFHeader::MagicBytesMatch(data_sp->GetBytes())) {
+ elf::ELFHeader elf_header;
+ DataExtractor data(data_sp, lldb::eByteOrderLittle, 4);
+ lldb::offset_t data_offset = 0;
+ if (elf_header.Parse(data, &data_offset)) {
+ if (elf_header.e_type == llvm::ELF::ET_CORE)
+ process_sp.reset(
+ new ProcessElfCore(target_sp, listener_sp, *crash_file));
+ }
+ }
+ }
+ return process_sp;
+}
+
+bool ProcessElfCore::CanDebug(lldb::TargetSP target_sp,
+ bool plugin_specified_by_name) {
+ // For now we are just making sure the file exists for a given module
+ if (!m_core_module_sp && m_core_file.Exists()) {
+ ModuleSpec core_module_spec(m_core_file, target_sp->GetArchitecture());
+ Error error(ModuleList::GetSharedModule(core_module_spec, m_core_module_sp,
+ NULL, NULL, NULL));
+ if (m_core_module_sp) {
+ ObjectFile *core_objfile = m_core_module_sp->GetObjectFile();
+ if (core_objfile && core_objfile->GetType() == ObjectFile::eTypeCoreFile)
+ return true;
}
- return false;
+ }
+ return false;
}
//----------------------------------------------------------------------
// ProcessElfCore constructor
//----------------------------------------------------------------------
-ProcessElfCore::ProcessElfCore(lldb::TargetSP target_sp, lldb::ListenerSP listener_sp,
- const FileSpec &core_file) :
- Process (target_sp, listener_sp),
- m_core_module_sp (),
- m_core_file (core_file),
- m_dyld_plugin_name (),
- m_os(llvm::Triple::UnknownOS),
- m_thread_data_valid(false),
- m_thread_data(),
- m_core_aranges ()
-{
-}
+ProcessElfCore::ProcessElfCore(lldb::TargetSP target_sp,
+ lldb::ListenerSP listener_sp,
+ const FileSpec &core_file)
+ : Process(target_sp, listener_sp), m_core_module_sp(),
+ m_core_file(core_file), m_dyld_plugin_name(),
+ m_os(llvm::Triple::UnknownOS), m_thread_data_valid(false),
+ m_thread_data(), m_core_aranges() {}
//----------------------------------------------------------------------
// Destructor
//----------------------------------------------------------------------
-ProcessElfCore::~ProcessElfCore()
-{
- Clear();
- // We need to call finalize on the process before destroying ourselves
- // to make sure all of the broadcaster cleanup goes as planned. If we
- // destruct this class, then Process::~Process() might have problems
- // trying to fully destroy the broadcaster.
- Finalize();
+ProcessElfCore::~ProcessElfCore() {
+ Clear();
+ // We need to call finalize on the process before destroying ourselves
+ // to make sure all of the broadcaster cleanup goes as planned. If we
+ // destruct this class, then Process::~Process() might have problems
+ // trying to fully destroy the broadcaster.
+ Finalize();
}
//----------------------------------------------------------------------
// PluginInterface
//----------------------------------------------------------------------
-ConstString
-ProcessElfCore::GetPluginName()
-{
- return GetPluginNameStatic();
-}
-
-uint32_t
-ProcessElfCore::GetPluginVersion()
-{
- return 1;
-}
-
-lldb::addr_t
-ProcessElfCore::AddAddressRangeFromLoadSegment(const elf::ELFProgramHeader *header)
-{
- const lldb::addr_t addr = header->p_vaddr;
- FileRange file_range (header->p_offset, header->p_filesz);
- VMRangeToFileOffset::Entry range_entry(addr, header->p_memsz, file_range);
-
- VMRangeToFileOffset::Entry *last_entry = m_core_aranges.Back();
- if (last_entry &&
- last_entry->GetRangeEnd() == range_entry.GetRangeBase() &&
- last_entry->data.GetRangeEnd() == range_entry.data.GetRangeBase() &&
- last_entry->GetByteSize() == last_entry->data.GetByteSize())
- {
- last_entry->SetRangeEnd (range_entry.GetRangeEnd());
- last_entry->data.SetRangeEnd (range_entry.data.GetRangeEnd());
- }
- else
- {
- m_core_aranges.Append(range_entry);
- }
+ConstString ProcessElfCore::GetPluginName() { return GetPluginNameStatic(); }
- // Keep a separate map of permissions that that isn't coalesced so all ranges
- // are maintained.
- const uint32_t permissions = ((header->p_flags & llvm::ELF::PF_R) ? lldb::ePermissionsReadable : 0) |
- ((header->p_flags & llvm::ELF::PF_W) ? lldb::ePermissionsWritable : 0) |
- ((header->p_flags & llvm::ELF::PF_X) ? lldb::ePermissionsExecutable : 0);
+uint32_t ProcessElfCore::GetPluginVersion() { return 1; }
- m_core_range_infos.Append(VMRangeToPermissions::Entry(addr, header->p_memsz, permissions));
+lldb::addr_t ProcessElfCore::AddAddressRangeFromLoadSegment(
+ const elf::ELFProgramHeader *header) {
+ const lldb::addr_t addr = header->p_vaddr;
+ FileRange file_range(header->p_offset, header->p_filesz);
+ VMRangeToFileOffset::Entry range_entry(addr, header->p_memsz, file_range);
+
+ VMRangeToFileOffset::Entry *last_entry = m_core_aranges.Back();
+ if (last_entry && last_entry->GetRangeEnd() == range_entry.GetRangeBase() &&
+ last_entry->data.GetRangeEnd() == range_entry.data.GetRangeBase() &&
+ last_entry->GetByteSize() == last_entry->data.GetByteSize()) {
+ last_entry->SetRangeEnd(range_entry.GetRangeEnd());
+ last_entry->data.SetRangeEnd(range_entry.data.GetRangeEnd());
+ } else {
+ m_core_aranges.Append(range_entry);
+ }
+
+ // Keep a separate map of permissions that that isn't coalesced so all ranges
+ // are maintained.
+ const uint32_t permissions =
+ ((header->p_flags & llvm::ELF::PF_R) ? lldb::ePermissionsReadable : 0) |
+ ((header->p_flags & llvm::ELF::PF_W) ? lldb::ePermissionsWritable : 0) |
+ ((header->p_flags & llvm::ELF::PF_X) ? lldb::ePermissionsExecutable : 0);
- return addr;
+ m_core_range_infos.Append(
+ VMRangeToPermissions::Entry(addr, header->p_memsz, permissions));
+
+ return addr;
}
//----------------------------------------------------------------------
// Process Control
//----------------------------------------------------------------------
-Error
-ProcessElfCore::DoLoadCore ()
-{
- Error error;
- if (!m_core_module_sp)
- {
- error.SetErrorString ("invalid core module");
- return error;
- }
-
- ObjectFileELF *core = (ObjectFileELF *)(m_core_module_sp->GetObjectFile());
- if (core == NULL)
- {
- error.SetErrorString ("invalid core object file");
- return error;
- }
-
- const uint32_t num_segments = core->GetProgramHeaderCount();
- if (num_segments == 0)
- {
- error.SetErrorString ("core file has no segments");
- return error;
- }
+Error ProcessElfCore::DoLoadCore() {
+ Error error;
+ if (!m_core_module_sp) {
+ error.SetErrorString("invalid core module");
+ return error;
+ }
- SetCanJIT(false);
+ ObjectFileELF *core = (ObjectFileELF *)(m_core_module_sp->GetObjectFile());
+ if (core == NULL) {
+ error.SetErrorString("invalid core object file");
+ return error;
+ }
- m_thread_data_valid = true;
+ const uint32_t num_segments = core->GetProgramHeaderCount();
+ if (num_segments == 0) {
+ error.SetErrorString("core file has no segments");
+ return error;
+ }
- bool ranges_are_sorted = true;
- lldb::addr_t vm_addr = 0;
- /// Walk through segments and Thread and Address Map information.
- /// PT_NOTE - Contains Thread and Register information
- /// PT_LOAD - Contains a contiguous range of Process Address Space
- for(uint32_t i = 1; i <= num_segments; i++)
- {
- const elf::ELFProgramHeader *header = core->GetProgramHeaderByIndex(i);
- assert(header != NULL);
-
- DataExtractor data = core->GetSegmentDataByIndex(i);
-
- // Parse thread contexts and auxv structure
- if (header->p_type == llvm::ELF::PT_NOTE)
- {
- error = ParseThreadContextsFromNoteSegment(header, data);
- if (error.Fail())
- return error;
- }
- // PT_LOAD segments contains address map
- if (header->p_type == llvm::ELF::PT_LOAD)
- {
- lldb::addr_t last_addr = AddAddressRangeFromLoadSegment(header);
- if (vm_addr > last_addr)
- ranges_are_sorted = false;
- vm_addr = last_addr;
- }
- }
+ SetCanJIT(false);
- if (!ranges_are_sorted)
- {
- m_core_aranges.Sort();
- m_core_range_infos.Sort();
- }
+ m_thread_data_valid = true;
- // Even if the architecture is set in the target, we need to override
- // it to match the core file which is always single arch.
- ArchSpec arch (m_core_module_sp->GetArchitecture());
- if (arch.IsValid())
- GetTarget().SetArchitecture(arch);
-
- SetUnixSignals(UnixSignals::Create(GetArchitecture()));
-
- // Core files are useless without the main executable. See if we can locate the main
- // executable using data we found in the core file notes.
- lldb::ModuleSP exe_module_sp = GetTarget().GetExecutableModule();
- if (!exe_module_sp)
- {
- // The first entry in the NT_FILE might be our executable
- if (!m_nt_file_entries.empty())
- {
- ModuleSpec exe_module_spec;
- exe_module_spec.GetArchitecture() = arch;
- exe_module_spec.GetFileSpec().SetFile(m_nt_file_entries[0].path.GetCString(), false);
- if (exe_module_spec.GetFileSpec())
- {
- exe_module_sp = GetTarget().GetSharedModule(exe_module_spec);
- if (exe_module_sp)
- GetTarget().SetExecutableModule(exe_module_sp, false);
- }
- }
+ bool ranges_are_sorted = true;
+ lldb::addr_t vm_addr = 0;
+ /// Walk through segments and Thread and Address Map information.
+ /// PT_NOTE - Contains Thread and Register information
+ /// PT_LOAD - Contains a contiguous range of Process Address Space
+ for (uint32_t i = 1; i <= num_segments; i++) {
+ const elf::ELFProgramHeader *header = core->GetProgramHeaderByIndex(i);
+ assert(header != NULL);
+
+ DataExtractor data = core->GetSegmentDataByIndex(i);
+
+ // Parse thread contexts and auxv structure
+ if (header->p_type == llvm::ELF::PT_NOTE) {
+ error = ParseThreadContextsFromNoteSegment(header, data);
+ if (error.Fail())
+ return error;
}
- return error;
-}
+ // PT_LOAD segments contains address map
+ if (header->p_type == llvm::ELF::PT_LOAD) {
+ lldb::addr_t last_addr = AddAddressRangeFromLoadSegment(header);
+ if (vm_addr > last_addr)
+ ranges_are_sorted = false;
+ vm_addr = last_addr;
+ }
+ }
+
+ if (!ranges_are_sorted) {
+ m_core_aranges.Sort();
+ m_core_range_infos.Sort();
+ }
+
+ // Even if the architecture is set in the target, we need to override
+ // it to match the core file which is always single arch.
+ ArchSpec arch(m_core_module_sp->GetArchitecture());
+ if (arch.IsValid())
+ GetTarget().SetArchitecture(arch);
+
+ SetUnixSignals(UnixSignals::Create(GetArchitecture()));
+
+ // Core files are useless without the main executable. See if we can locate
+ // the main
+ // executable using data we found in the core file notes.
+ lldb::ModuleSP exe_module_sp = GetTarget().GetExecutableModule();
+ if (!exe_module_sp) {
+ // The first entry in the NT_FILE might be our executable
+ if (!m_nt_file_entries.empty()) {
+ ModuleSpec exe_module_spec;
+ exe_module_spec.GetArchitecture() = arch;
+ exe_module_spec.GetFileSpec().SetFile(
+ m_nt_file_entries[0].path.GetCString(), false);
+ if (exe_module_spec.GetFileSpec()) {
+ exe_module_sp = GetTarget().GetSharedModule(exe_module_spec);
+ if (exe_module_sp)
+ GetTarget().SetExecutableModule(exe_module_sp, false);
+ }
+ }
+ }
+ return error;
+}
+
+lldb_private::DynamicLoader *ProcessElfCore::GetDynamicLoader() {
+ if (m_dyld_ap.get() == NULL)
+ m_dyld_ap.reset(DynamicLoader::FindPlugin(
+ this, DynamicLoaderPOSIXDYLD::GetPluginNameStatic().GetCString()));
+ return m_dyld_ap.get();
+}
+
+bool ProcessElfCore::UpdateThreadList(ThreadList &old_thread_list,
+ ThreadList &new_thread_list) {
+ const uint32_t num_threads = GetNumThreadContexts();
+ if (!m_thread_data_valid)
+ return false;
-lldb_private::DynamicLoader *
-ProcessElfCore::GetDynamicLoader ()
-{
- if (m_dyld_ap.get() == NULL)
- m_dyld_ap.reset (DynamicLoader::FindPlugin(this, DynamicLoaderPOSIXDYLD::GetPluginNameStatic().GetCString()));
- return m_dyld_ap.get();
-}
-
-bool
-ProcessElfCore::UpdateThreadList (ThreadList &old_thread_list, ThreadList &new_thread_list)
-{
- const uint32_t num_threads = GetNumThreadContexts ();
- if (!m_thread_data_valid)
- return false;
-
- for (lldb::tid_t tid = 0; tid < num_threads; ++tid)
- {
- const ThreadData &td = m_thread_data[tid];
- lldb::ThreadSP thread_sp(new ThreadElfCore (*this, td));
- new_thread_list.AddThread (thread_sp);
- }
- return new_thread_list.GetSize(false) > 0;
+ for (lldb::tid_t tid = 0; tid < num_threads; ++tid) {
+ const ThreadData &td = m_thread_data[tid];
+ lldb::ThreadSP thread_sp(new ThreadElfCore(*this, td));
+ new_thread_list.AddThread(thread_sp);
+ }
+ return new_thread_list.GetSize(false) > 0;
}
-void
-ProcessElfCore::RefreshStateAfterStop ()
-{
-}
+void ProcessElfCore::RefreshStateAfterStop() {}
-Error
-ProcessElfCore::DoDestroy ()
-{
- return Error();
-}
+Error ProcessElfCore::DoDestroy() { return Error(); }
//------------------------------------------------------------------
// Process Queries
//------------------------------------------------------------------
-bool
-ProcessElfCore::IsAlive ()
-{
- return true;
-}
+bool ProcessElfCore::IsAlive() { return true; }
//------------------------------------------------------------------
// Process Memory
//------------------------------------------------------------------
-size_t
-ProcessElfCore::ReadMemory (lldb::addr_t addr, void *buf, size_t size, Error &error)
-{
- // Don't allow the caching that lldb_private::Process::ReadMemory does
- // since in core files we have it all cached our our core file anyway.
- return DoReadMemory (addr, buf, size, error);
-}
-
-Error
-ProcessElfCore::GetMemoryRegionInfo(lldb::addr_t load_addr, MemoryRegionInfo ®ion_info)
-{
- region_info.Clear();
- const VMRangeToPermissions::Entry *permission_entry = m_core_range_infos.FindEntryThatContainsOrFollows(load_addr);
- if (permission_entry)
- {
- if (permission_entry->Contains(load_addr))
- {
- region_info.GetRange().SetRangeBase(permission_entry->GetRangeBase());
- region_info.GetRange().SetRangeEnd(permission_entry->GetRangeEnd());
- const Flags permissions(permission_entry->data);
- region_info.SetReadable(permissions.Test(lldb::ePermissionsReadable) ? MemoryRegionInfo::eYes
- : MemoryRegionInfo::eNo);
- region_info.SetWritable(permissions.Test(lldb::ePermissionsWritable) ? MemoryRegionInfo::eYes
- : MemoryRegionInfo::eNo);
- region_info.SetExecutable(permissions.Test(lldb::ePermissionsExecutable) ? MemoryRegionInfo::eYes
- : MemoryRegionInfo::eNo);
- region_info.SetMapped(MemoryRegionInfo::eYes);
- }
- else if (load_addr < permission_entry->GetRangeBase())
- {
- region_info.GetRange().SetRangeBase(load_addr);
- region_info.GetRange().SetRangeEnd(permission_entry->GetRangeBase());
- region_info.SetReadable(MemoryRegionInfo::eNo);
- region_info.SetWritable(MemoryRegionInfo::eNo);
- region_info.SetExecutable(MemoryRegionInfo::eNo);
- region_info.SetMapped(MemoryRegionInfo::eNo);
- }
- return Error();
+size_t ProcessElfCore::ReadMemory(lldb::addr_t addr, void *buf, size_t size,
+ Error &error) {
+ // Don't allow the caching that lldb_private::Process::ReadMemory does
+ // since in core files we have it all cached our our core file anyway.
+ return DoReadMemory(addr, buf, size, error);
+}
+
+Error ProcessElfCore::GetMemoryRegionInfo(lldb::addr_t load_addr,
+ MemoryRegionInfo ®ion_info) {
+ region_info.Clear();
+ const VMRangeToPermissions::Entry *permission_entry =
+ m_core_range_infos.FindEntryThatContainsOrFollows(load_addr);
+ if (permission_entry) {
+ if (permission_entry->Contains(load_addr)) {
+ region_info.GetRange().SetRangeBase(permission_entry->GetRangeBase());
+ region_info.GetRange().SetRangeEnd(permission_entry->GetRangeEnd());
+ const Flags permissions(permission_entry->data);
+ region_info.SetReadable(permissions.Test(lldb::ePermissionsReadable)
+ ? MemoryRegionInfo::eYes
+ : MemoryRegionInfo::eNo);
+ region_info.SetWritable(permissions.Test(lldb::ePermissionsWritable)
+ ? MemoryRegionInfo::eYes
+ : MemoryRegionInfo::eNo);
+ region_info.SetExecutable(permissions.Test(lldb::ePermissionsExecutable)
+ ? MemoryRegionInfo::eYes
+ : MemoryRegionInfo::eNo);
+ region_info.SetMapped(MemoryRegionInfo::eYes);
+ } else if (load_addr < permission_entry->GetRangeBase()) {
+ region_info.GetRange().SetRangeBase(load_addr);
+ region_info.GetRange().SetRangeEnd(permission_entry->GetRangeBase());
+ region_info.SetReadable(MemoryRegionInfo::eNo);
+ region_info.SetWritable(MemoryRegionInfo::eNo);
+ region_info.SetExecutable(MemoryRegionInfo::eNo);
+ region_info.SetMapped(MemoryRegionInfo::eNo);
}
-
- region_info.GetRange().SetRangeBase(load_addr);
- region_info.GetRange().SetRangeEnd(LLDB_INVALID_ADDRESS);
- region_info.SetReadable(MemoryRegionInfo::eNo);
- region_info.SetWritable(MemoryRegionInfo::eNo);
- region_info.SetExecutable(MemoryRegionInfo::eNo);
- region_info.SetMapped(MemoryRegionInfo::eNo);
return Error();
-}
-
-size_t
-ProcessElfCore::DoReadMemory (lldb::addr_t addr, void *buf, size_t size, Error &error)
-{
- ObjectFile *core_objfile = m_core_module_sp->GetObjectFile();
-
- if (core_objfile == NULL)
- return 0;
-
- // Get the address range
- const VMRangeToFileOffset::Entry *address_range = m_core_aranges.FindEntryThatContains (addr);
- if (address_range == NULL || address_range->GetRangeEnd() < addr)
- {
- error.SetErrorStringWithFormat ("core file does not contain 0x%" PRIx64, addr);
- return 0;
- }
-
- // Convert the address into core file offset
- const lldb::addr_t offset = addr - address_range->GetRangeBase();
- const lldb::addr_t file_start = address_range->data.GetRangeBase();
- const lldb::addr_t file_end = address_range->data.GetRangeEnd();
- size_t bytes_to_read = size; // Number of bytes to read from the core file
- size_t bytes_copied = 0; // Number of bytes actually read from the core file
- size_t zero_fill_size = 0; // Padding
- lldb::addr_t bytes_left = 0; // Number of bytes available in the core file from the given address
-
- // Figure out how many on-disk bytes remain in this segment
- // starting at the given offset
- if (file_end > file_start + offset)
- bytes_left = file_end - (file_start + offset);
-
- // Figure out how many bytes we need to zero-fill if we are
- // reading more bytes than available in the on-disk segment
- if (bytes_to_read > bytes_left)
- {
- zero_fill_size = bytes_to_read - bytes_left;
- bytes_to_read = bytes_left;
- }
-
- // If there is data available on the core file read it
- if (bytes_to_read)
- bytes_copied = core_objfile->CopyData(offset + file_start, bytes_to_read, buf);
-
- assert(zero_fill_size <= size);
- // Pad remaining bytes
- if (zero_fill_size)
- memset(((char *)buf) + bytes_copied, 0, zero_fill_size);
-
- return bytes_copied + zero_fill_size;
-}
-
-void
-ProcessElfCore::Clear()
-{
- m_thread_list.Clear();
- m_os = llvm::Triple::UnknownOS;
-
- SetUnixSignals(std::make_shared<UnixSignals>());
-}
-
-void
-ProcessElfCore::Initialize()
-{
- static std::once_flag g_once_flag;
-
- std::call_once(g_once_flag, []()
- {
- PluginManager::RegisterPlugin (GetPluginNameStatic(),
- GetPluginDescriptionStatic(), CreateInstance);
- });
-}
-
-lldb::addr_t
-ProcessElfCore::GetImageInfoAddress()
-{
- ObjectFile *obj_file = GetTarget().GetExecutableModule()->GetObjectFile();
- Address addr = obj_file->GetImageInfoAddress(&GetTarget());
+ }
- if (addr.IsValid())
- return addr.GetLoadAddress(&GetTarget());
- return LLDB_INVALID_ADDRESS;
+ region_info.GetRange().SetRangeBase(load_addr);
+ region_info.GetRange().SetRangeEnd(LLDB_INVALID_ADDRESS);
+ region_info.SetReadable(MemoryRegionInfo::eNo);
+ region_info.SetWritable(MemoryRegionInfo::eNo);
+ region_info.SetExecutable(MemoryRegionInfo::eNo);
+ region_info.SetMapped(MemoryRegionInfo::eNo);
+ return Error();
+}
+
+size_t ProcessElfCore::DoReadMemory(lldb::addr_t addr, void *buf, size_t size,
+ Error &error) {
+ ObjectFile *core_objfile = m_core_module_sp->GetObjectFile();
+
+ if (core_objfile == NULL)
+ return 0;
+
+ // Get the address range
+ const VMRangeToFileOffset::Entry *address_range =
+ m_core_aranges.FindEntryThatContains(addr);
+ if (address_range == NULL || address_range->GetRangeEnd() < addr) {
+ error.SetErrorStringWithFormat("core file does not contain 0x%" PRIx64,
+ addr);
+ return 0;
+ }
+
+ // Convert the address into core file offset
+ const lldb::addr_t offset = addr - address_range->GetRangeBase();
+ const lldb::addr_t file_start = address_range->data.GetRangeBase();
+ const lldb::addr_t file_end = address_range->data.GetRangeEnd();
+ size_t bytes_to_read = size; // Number of bytes to read from the core file
+ size_t bytes_copied = 0; // Number of bytes actually read from the core file
+ size_t zero_fill_size = 0; // Padding
+ lldb::addr_t bytes_left =
+ 0; // Number of bytes available in the core file from the given address
+
+ // Figure out how many on-disk bytes remain in this segment
+ // starting at the given offset
+ if (file_end > file_start + offset)
+ bytes_left = file_end - (file_start + offset);
+
+ // Figure out how many bytes we need to zero-fill if we are
+ // reading more bytes than available in the on-disk segment
+ if (bytes_to_read > bytes_left) {
+ zero_fill_size = bytes_to_read - bytes_left;
+ bytes_to_read = bytes_left;
+ }
+
+ // If there is data available on the core file read it
+ if (bytes_to_read)
+ bytes_copied =
+ core_objfile->CopyData(offset + file_start, bytes_to_read, buf);
+
+ assert(zero_fill_size <= size);
+ // Pad remaining bytes
+ if (zero_fill_size)
+ memset(((char *)buf) + bytes_copied, 0, zero_fill_size);
+
+ return bytes_copied + zero_fill_size;
+}
+
+void ProcessElfCore::Clear() {
+ m_thread_list.Clear();
+ m_os = llvm::Triple::UnknownOS;
+
+ SetUnixSignals(std::make_shared<UnixSignals>());
+}
+
+void ProcessElfCore::Initialize() {
+ static std::once_flag g_once_flag;
+
+ std::call_once(g_once_flag, []() {
+ PluginManager::RegisterPlugin(GetPluginNameStatic(),
+ GetPluginDescriptionStatic(), CreateInstance);
+ });
+}
+
+lldb::addr_t ProcessElfCore::GetImageInfoAddress() {
+ ObjectFile *obj_file = GetTarget().GetExecutableModule()->GetObjectFile();
+ Address addr = obj_file->GetImageInfoAddress(&GetTarget());
+
+ if (addr.IsValid())
+ return addr.GetLoadAddress(&GetTarget());
+ return LLDB_INVALID_ADDRESS;
}
/// Core files PT_NOTE segment descriptor types
enum {
- NT_PRSTATUS = 1,
- NT_FPREGSET,
- NT_PRPSINFO,
- NT_TASKSTRUCT,
- NT_PLATFORM,
- NT_AUXV,
- NT_FILE = 0x46494c45
+ NT_PRSTATUS = 1,
+ NT_FPREGSET,
+ NT_PRPSINFO,
+ NT_TASKSTRUCT,
+ NT_PLATFORM,
+ NT_AUXV,
+ NT_FILE = 0x46494c45
};
namespace FREEBSD {
enum {
- NT_PRSTATUS = 1,
- NT_FPREGSET,
- NT_PRPSINFO,
- NT_THRMISC = 7,
- NT_PROCSTAT_AUXV = 16,
- NT_PPC_VMX = 0x100
+ NT_PRSTATUS = 1,
+ NT_FPREGSET,
+ NT_PRPSINFO,
+ NT_THRMISC = 7,
+ NT_PROCSTAT_AUXV = 16,
+ NT_PPC_VMX = 0x100
};
-
}
// Parse a FreeBSD NT_PRSTATUS note - see FreeBSD sys/procfs.h for details.
-static void
-ParseFreeBSDPrStatus(ThreadData &thread_data, DataExtractor &data,
- ArchSpec &arch)
-{
- lldb::offset_t offset = 0;
- bool lp64 = (arch.GetMachine() == llvm::Triple::aarch64 ||
- arch.GetMachine() == llvm::Triple::mips64 ||
- arch.GetMachine() == llvm::Triple::ppc64 ||
- arch.GetMachine() == llvm::Triple::x86_64);
- int pr_version = data.GetU32(&offset);
-
- Log *log (GetLogIfAllCategoriesSet(LIBLLDB_LOG_PROCESS));
- if (log)
- {
- if (pr_version > 1)
- log->Printf("FreeBSD PRSTATUS unexpected version %d", pr_version);
- }
-
- // Skip padding, pr_statussz, pr_gregsetsz, pr_fpregsetsz, pr_osreldate
- if (lp64)
- offset += 32;
- else
- offset += 16;
-
- thread_data.signo = data.GetU32(&offset); // pr_cursig
- thread_data.tid = data.GetU32(&offset); // pr_pid
- if (lp64)
- offset += 4;
-
- size_t len = data.GetByteSize() - offset;
- thread_data.gpregset = DataExtractor(data, offset, len);
-}
-
-static void
-ParseFreeBSDThrMisc(ThreadData &thread_data, DataExtractor &data)
-{
- lldb::offset_t offset = 0;
- thread_data.name = data.GetCStr(&offset, 20);
+static void ParseFreeBSDPrStatus(ThreadData &thread_data, DataExtractor &data,
+ ArchSpec &arch) {
+ lldb::offset_t offset = 0;
+ bool lp64 = (arch.GetMachine() == llvm::Triple::aarch64 ||
+ arch.GetMachine() == llvm::Triple::mips64 ||
+ arch.GetMachine() == llvm::Triple::ppc64 ||
+ arch.GetMachine() == llvm::Triple::x86_64);
+ int pr_version = data.GetU32(&offset);
+
+ Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_PROCESS));
+ if (log) {
+ if (pr_version > 1)
+ log->Printf("FreeBSD PRSTATUS unexpected version %d", pr_version);
+ }
+
+ // Skip padding, pr_statussz, pr_gregsetsz, pr_fpregsetsz, pr_osreldate
+ if (lp64)
+ offset += 32;
+ else
+ offset += 16;
+
+ thread_data.signo = data.GetU32(&offset); // pr_cursig
+ thread_data.tid = data.GetU32(&offset); // pr_pid
+ if (lp64)
+ offset += 4;
+
+ size_t len = data.GetByteSize() - offset;
+ thread_data.gpregset = DataExtractor(data, offset, len);
+}
+
+static void ParseFreeBSDThrMisc(ThreadData &thread_data, DataExtractor &data) {
+ lldb::offset_t offset = 0;
+ thread_data.name = data.GetCStr(&offset, 20);
}
/// Parse Thread context from PT_NOTE segment and store it in the thread list
@@ -528,190 +461,173 @@ ParseFreeBSDThrMisc(ThreadData &thread_d
/// b) NT_PRPSINFO - Process info(pid..)
/// c) NT_FPREGSET - Floating point registers
/// 4) The NOTE entries can be in any order
-/// 5) If a core file contains multiple thread contexts then there is two data forms
-/// a) Each thread context(2 or more NOTE entries) contained in its own segment (PT_NOTE)
+/// 5) If a core file contains multiple thread contexts then there is two data
+/// forms
+/// a) Each thread context(2 or more NOTE entries) contained in its own
+/// segment (PT_NOTE)
/// b) All thread context is stored in a single segment(PT_NOTE).
-/// This case is little tricker since while parsing we have to find where the
+/// This case is little tricker since while parsing we have to find where
+/// the
/// new thread starts. The current implementation marks beginning of
/// new thread when it finds NT_PRSTATUS or NT_PRPSINFO NOTE entry.
/// For case (b) there may be either one NT_PRPSINFO per thread, or a single
/// one that applies to all threads (depending on the platform type).
-Error
-ProcessElfCore::ParseThreadContextsFromNoteSegment(const elf::ELFProgramHeader *segment_header,
- DataExtractor segment_data)
-{
- assert(segment_header && segment_header->p_type == llvm::ELF::PT_NOTE);
-
- lldb::offset_t offset = 0;
- std::unique_ptr<ThreadData> thread_data(new ThreadData);
- bool have_prstatus = false;
- bool have_prpsinfo = false;
-
- ArchSpec arch = GetArchitecture();
- ELFLinuxPrPsInfo prpsinfo;
- ELFLinuxPrStatus prstatus;
- size_t header_size;
- size_t len;
- Error error;
-
- // Loop through the NOTE entires in the segment
- while (offset < segment_header->p_filesz)
- {
- ELFNote note = ELFNote();
- note.Parse(segment_data, &offset);
-
- // Beginning of new thread
- if ((note.n_type == NT_PRSTATUS && have_prstatus) ||
- (note.n_type == NT_PRPSINFO && have_prpsinfo))
- {
- assert(thread_data->gpregset.GetByteSize() > 0);
- // Add the new thread to thread list
- m_thread_data.push_back(*thread_data);
- *thread_data = ThreadData();
- have_prstatus = false;
- have_prpsinfo = false;
- }
-
- size_t note_start, note_size;
- note_start = offset;
- note_size = llvm::alignTo(note.n_descsz, 4);
-
- // Store the NOTE information in the current thread
- DataExtractor note_data (segment_data, note_start, note_size);
- note_data.SetAddressByteSize(m_core_module_sp->GetArchitecture().GetAddressByteSize());
- if (note.n_name == "FreeBSD")
- {
- m_os = llvm::Triple::FreeBSD;
- switch (note.n_type)
- {
- case FREEBSD::NT_PRSTATUS:
- have_prstatus = true;
- ParseFreeBSDPrStatus(*thread_data, note_data, arch);
- break;
- case FREEBSD::NT_FPREGSET:
- thread_data->fpregset = note_data;
- break;
- case FREEBSD::NT_PRPSINFO:
- have_prpsinfo = true;
- break;
- case FREEBSD::NT_THRMISC:
- ParseFreeBSDThrMisc(*thread_data, note_data);
- break;
- case FREEBSD::NT_PROCSTAT_AUXV:
- // FIXME: FreeBSD sticks an int at the beginning of the note
- m_auxv = DataExtractor(segment_data, note_start + 4, note_size - 4);
- break;
- case FREEBSD::NT_PPC_VMX:
- thread_data->vregset = note_data;
- break;
- default:
- break;
- }
+Error ProcessElfCore::ParseThreadContextsFromNoteSegment(
+ const elf::ELFProgramHeader *segment_header, DataExtractor segment_data) {
+ assert(segment_header && segment_header->p_type == llvm::ELF::PT_NOTE);
+
+ lldb::offset_t offset = 0;
+ std::unique_ptr<ThreadData> thread_data(new ThreadData);
+ bool have_prstatus = false;
+ bool have_prpsinfo = false;
+
+ ArchSpec arch = GetArchitecture();
+ ELFLinuxPrPsInfo prpsinfo;
+ ELFLinuxPrStatus prstatus;
+ size_t header_size;
+ size_t len;
+ Error error;
+
+ // Loop through the NOTE entires in the segment
+ while (offset < segment_header->p_filesz) {
+ ELFNote note = ELFNote();
+ note.Parse(segment_data, &offset);
+
+ // Beginning of new thread
+ if ((note.n_type == NT_PRSTATUS && have_prstatus) ||
+ (note.n_type == NT_PRPSINFO && have_prpsinfo)) {
+ assert(thread_data->gpregset.GetByteSize() > 0);
+ // Add the new thread to thread list
+ m_thread_data.push_back(*thread_data);
+ *thread_data = ThreadData();
+ have_prstatus = false;
+ have_prpsinfo = false;
+ }
+
+ size_t note_start, note_size;
+ note_start = offset;
+ note_size = llvm::alignTo(note.n_descsz, 4);
+
+ // Store the NOTE information in the current thread
+ DataExtractor note_data(segment_data, note_start, note_size);
+ note_data.SetAddressByteSize(
+ m_core_module_sp->GetArchitecture().GetAddressByteSize());
+ if (note.n_name == "FreeBSD") {
+ m_os = llvm::Triple::FreeBSD;
+ switch (note.n_type) {
+ case FREEBSD::NT_PRSTATUS:
+ have_prstatus = true;
+ ParseFreeBSDPrStatus(*thread_data, note_data, arch);
+ break;
+ case FREEBSD::NT_FPREGSET:
+ thread_data->fpregset = note_data;
+ break;
+ case FREEBSD::NT_PRPSINFO:
+ have_prpsinfo = true;
+ break;
+ case FREEBSD::NT_THRMISC:
+ ParseFreeBSDThrMisc(*thread_data, note_data);
+ break;
+ case FREEBSD::NT_PROCSTAT_AUXV:
+ // FIXME: FreeBSD sticks an int at the beginning of the note
+ m_auxv = DataExtractor(segment_data, note_start + 4, note_size - 4);
+ break;
+ case FREEBSD::NT_PPC_VMX:
+ thread_data->vregset = note_data;
+ break;
+ default:
+ break;
+ }
+ } else if (note.n_name == "CORE") {
+ switch (note.n_type) {
+ case NT_PRSTATUS:
+ have_prstatus = true;
+ error = prstatus.Parse(note_data, arch);
+ if (error.Fail())
+ return error;
+ thread_data->signo = prstatus.pr_cursig;
+ thread_data->tid = prstatus.pr_pid;
+ header_size = ELFLinuxPrStatus::GetSize(arch);
+ len = note_data.GetByteSize() - header_size;
+ thread_data->gpregset = DataExtractor(note_data, header_size, len);
+ break;
+ case NT_FPREGSET:
+ thread_data->fpregset = note_data;
+ break;
+ case NT_PRPSINFO:
+ have_prpsinfo = true;
+ error = prpsinfo.Parse(note_data, arch);
+ if (error.Fail())
+ return error;
+ thread_data->name = prpsinfo.pr_fname;
+ SetID(prpsinfo.pr_pid);
+ break;
+ case NT_AUXV:
+ m_auxv = DataExtractor(note_data);
+ break;
+ case NT_FILE: {
+ m_nt_file_entries.clear();
+ lldb::offset_t offset = 0;
+ const uint64_t count = note_data.GetAddress(&offset);
+ note_data.GetAddress(&offset); // Skip page size
+ for (uint64_t i = 0; i < count; ++i) {
+ NT_FILE_Entry entry;
+ entry.start = note_data.GetAddress(&offset);
+ entry.end = note_data.GetAddress(&offset);
+ entry.file_ofs = note_data.GetAddress(&offset);
+ m_nt_file_entries.push_back(entry);
}
- else if (note.n_name == "CORE")
- {
- switch (note.n_type)
- {
- case NT_PRSTATUS:
- have_prstatus = true;
- error = prstatus.Parse(note_data, arch);
- if (error.Fail())
- return error;
- thread_data->signo = prstatus.pr_cursig;
- thread_data->tid = prstatus.pr_pid;
- header_size = ELFLinuxPrStatus::GetSize(arch);
- len = note_data.GetByteSize() - header_size;
- thread_data->gpregset = DataExtractor(note_data, header_size, len);
- break;
- case NT_FPREGSET:
- thread_data->fpregset = note_data;
- break;
- case NT_PRPSINFO:
- have_prpsinfo = true;
- error = prpsinfo.Parse(note_data, arch);
- if (error.Fail())
- return error;
- thread_data->name = prpsinfo.pr_fname;
- SetID(prpsinfo.pr_pid);
- break;
- case NT_AUXV:
- m_auxv = DataExtractor(note_data);
- break;
- case NT_FILE:
- {
- m_nt_file_entries.clear();
- lldb::offset_t offset = 0;
- const uint64_t count = note_data.GetAddress(&offset);
- note_data.GetAddress(&offset); // Skip page size
- for (uint64_t i = 0; i<count; ++i)
- {
- NT_FILE_Entry entry;
- entry.start = note_data.GetAddress(&offset);
- entry.end = note_data.GetAddress(&offset);
- entry.file_ofs = note_data.GetAddress(&offset);
- m_nt_file_entries.push_back(entry);
- }
- for (uint64_t i = 0; i<count; ++i)
- {
- const char *path = note_data.GetCStr(&offset);
- if (path && path[0])
- m_nt_file_entries[i].path.SetCString(path);
- }
- }
- break;
- default:
- break;
- }
+ for (uint64_t i = 0; i < count; ++i) {
+ const char *path = note_data.GetCStr(&offset);
+ if (path && path[0])
+ m_nt_file_entries[i].path.SetCString(path);
}
-
- offset += note_size;
- }
- // Add last entry in the note section
- if (thread_data && thread_data->gpregset.GetByteSize() > 0)
- {
- m_thread_data.push_back(*thread_data);
- }
-
- return error;
-}
-
-uint32_t
-ProcessElfCore::GetNumThreadContexts ()
-{
- if (!m_thread_data_valid)
- DoLoadCore();
- return m_thread_data.size();
-}
-
-ArchSpec
-ProcessElfCore::GetArchitecture()
-{
- ObjectFileELF *core_file = (ObjectFileELF *)(m_core_module_sp->GetObjectFile());
- ArchSpec arch;
- core_file->GetArchitecture(arch);
- return arch;
-}
-
-const lldb::DataBufferSP
-ProcessElfCore::GetAuxvData()
-{
- const uint8_t *start = m_auxv.GetDataStart();
- size_t len = m_auxv.GetByteSize();
- lldb::DataBufferSP buffer(new lldb_private::DataBufferHeap(start, len));
- return buffer;
-}
-
-bool
-ProcessElfCore::GetProcessInfo(ProcessInstanceInfo &info)
-{
- info.Clear();
- info.SetProcessID(GetID());
- info.SetArchitecture(GetArchitecture());
- lldb::ModuleSP module_sp = GetTarget().GetExecutableModule();
- if (module_sp)
- {
- const bool add_exe_file_as_first_arg = false;
- info.SetExecutableFile(GetTarget().GetExecutableModule()->GetFileSpec(), add_exe_file_as_first_arg);
- }
- return true;
+ } break;
+ default:
+ break;
+ }
+ }
+
+ offset += note_size;
+ }
+ // Add last entry in the note section
+ if (thread_data && thread_data->gpregset.GetByteSize() > 0) {
+ m_thread_data.push_back(*thread_data);
+ }
+
+ return error;
+}
+
+uint32_t ProcessElfCore::GetNumThreadContexts() {
+ if (!m_thread_data_valid)
+ DoLoadCore();
+ return m_thread_data.size();
+}
+
+ArchSpec ProcessElfCore::GetArchitecture() {
+ ObjectFileELF *core_file =
+ (ObjectFileELF *)(m_core_module_sp->GetObjectFile());
+ ArchSpec arch;
+ core_file->GetArchitecture(arch);
+ return arch;
+}
+
+const lldb::DataBufferSP ProcessElfCore::GetAuxvData() {
+ const uint8_t *start = m_auxv.GetDataStart();
+ size_t len = m_auxv.GetByteSize();
+ lldb::DataBufferSP buffer(new lldb_private::DataBufferHeap(start, len));
+ return buffer;
+}
+
+bool ProcessElfCore::GetProcessInfo(ProcessInstanceInfo &info) {
+ info.Clear();
+ info.SetProcessID(GetID());
+ info.SetArchitecture(GetArchitecture());
+ lldb::ModuleSP module_sp = GetTarget().GetExecutableModule();
+ if (module_sp) {
+ const bool add_exe_file_as_first_arg = false;
+ info.SetExecutableFile(GetTarget().GetExecutableModule()->GetFileSpec(),
+ add_exe_file_as_first_arg);
+ }
+ return true;
}
Modified: lldb/trunk/source/Plugins/Process/elf-core/ProcessElfCore.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/elf-core/ProcessElfCore.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/elf-core/ProcessElfCore.h (original)
+++ lldb/trunk/source/Plugins/Process/elf-core/ProcessElfCore.h Tue Sep 6 15:57:50 2016
@@ -32,151 +32,144 @@
struct ThreadData;
-class ProcessElfCore : public lldb_private::Process
-{
+class ProcessElfCore : public lldb_private::Process {
public:
- //------------------------------------------------------------------
- // Constructors and Destructors
- //------------------------------------------------------------------
- static lldb::ProcessSP
- CreateInstance (lldb::TargetSP target_sp,
- lldb::ListenerSP listener_sp,
- const lldb_private::FileSpec *crash_file_path);
+ //------------------------------------------------------------------
+ // Constructors and Destructors
+ //------------------------------------------------------------------
+ static lldb::ProcessSP
+ CreateInstance(lldb::TargetSP target_sp, lldb::ListenerSP listener_sp,
+ const lldb_private::FileSpec *crash_file_path);
- static void
- Initialize();
+ static void Initialize();
- static void
- Terminate();
+ static void Terminate();
- static lldb_private::ConstString
- GetPluginNameStatic();
+ static lldb_private::ConstString GetPluginNameStatic();
- static const char *
- GetPluginDescriptionStatic();
+ static const char *GetPluginDescriptionStatic();
- //------------------------------------------------------------------
- // Constructors and Destructors
- //------------------------------------------------------------------
- ProcessElfCore(lldb::TargetSP target_sp,
- lldb::ListenerSP listener_sp,
- const lldb_private::FileSpec &core_file);
+ //------------------------------------------------------------------
+ // Constructors and Destructors
+ //------------------------------------------------------------------
+ ProcessElfCore(lldb::TargetSP target_sp, lldb::ListenerSP listener_sp,
+ const lldb_private::FileSpec &core_file);
- ~ProcessElfCore() override;
+ ~ProcessElfCore() override;
- //------------------------------------------------------------------
- // Check if a given Process
- //------------------------------------------------------------------
- bool CanDebug(lldb::TargetSP target_sp, bool plugin_specified_by_name) override;
+ //------------------------------------------------------------------
+ // Check if a given Process
+ //------------------------------------------------------------------
+ bool CanDebug(lldb::TargetSP target_sp,
+ bool plugin_specified_by_name) override;
- //------------------------------------------------------------------
- // Creating a new process, or attaching to an existing one
- //------------------------------------------------------------------
- lldb_private::Error DoLoadCore() override;
+ //------------------------------------------------------------------
+ // Creating a new process, or attaching to an existing one
+ //------------------------------------------------------------------
+ lldb_private::Error DoLoadCore() override;
- lldb_private::DynamicLoader *GetDynamicLoader() override;
+ lldb_private::DynamicLoader *GetDynamicLoader() override;
- //------------------------------------------------------------------
- // PluginInterface protocol
- //------------------------------------------------------------------
- lldb_private::ConstString GetPluginName() override;
+ //------------------------------------------------------------------
+ // PluginInterface protocol
+ //------------------------------------------------------------------
+ lldb_private::ConstString GetPluginName() override;
- uint32_t GetPluginVersion() override;
+ uint32_t GetPluginVersion() override;
- //------------------------------------------------------------------
- // Process Control
- //------------------------------------------------------------------
- lldb_private::Error DoDestroy() override;
+ //------------------------------------------------------------------
+ // Process Control
+ //------------------------------------------------------------------
+ lldb_private::Error DoDestroy() override;
- void RefreshStateAfterStop() override;
+ void RefreshStateAfterStop() override;
- //------------------------------------------------------------------
- // Process Queries
- //------------------------------------------------------------------
- bool IsAlive() override;
+ //------------------------------------------------------------------
+ // Process Queries
+ //------------------------------------------------------------------
+ bool IsAlive() override;
- //------------------------------------------------------------------
- // Process Memory
- //------------------------------------------------------------------
- size_t ReadMemory(lldb::addr_t addr, void *buf, size_t size, lldb_private::Error &error) override;
+ //------------------------------------------------------------------
+ // Process Memory
+ //------------------------------------------------------------------
+ size_t ReadMemory(lldb::addr_t addr, void *buf, size_t size,
+ lldb_private::Error &error) override;
- size_t DoReadMemory(lldb::addr_t addr, void *buf, size_t size, lldb_private::Error &error) override;
+ size_t DoReadMemory(lldb::addr_t addr, void *buf, size_t size,
+ lldb_private::Error &error) override;
- lldb_private::Error
- GetMemoryRegionInfo(lldb::addr_t load_addr, lldb_private::MemoryRegionInfo ®ion_info) override;
+ lldb_private::Error
+ GetMemoryRegionInfo(lldb::addr_t load_addr,
+ lldb_private::MemoryRegionInfo ®ion_info) override;
- lldb::addr_t GetImageInfoAddress() override;
+ lldb::addr_t GetImageInfoAddress() override;
- lldb_private::ArchSpec
- GetArchitecture();
+ lldb_private::ArchSpec GetArchitecture();
- // Returns AUXV structure found in the core file
- const lldb::DataBufferSP
- GetAuxvData() override;
+ // Returns AUXV structure found in the core file
+ const lldb::DataBufferSP GetAuxvData() override;
- bool
- GetProcessInfo(lldb_private::ProcessInstanceInfo &info) override;
+ bool GetProcessInfo(lldb_private::ProcessInstanceInfo &info) override;
protected:
- void
- Clear ( );
+ void Clear();
- bool UpdateThreadList(lldb_private::ThreadList &old_thread_list,
- lldb_private::ThreadList &new_thread_list) override;
+ bool UpdateThreadList(lldb_private::ThreadList &old_thread_list,
+ lldb_private::ThreadList &new_thread_list) override;
private:
- struct NT_FILE_Entry
- {
- lldb::addr_t start;
- lldb::addr_t end;
- lldb::addr_t file_ofs;
- lldb_private::ConstString path;
- };
-
- //------------------------------------------------------------------
- // For ProcessElfCore only
- //------------------------------------------------------------------
- typedef lldb_private::Range<lldb::addr_t, lldb::addr_t> FileRange;
- typedef lldb_private::RangeDataArray<lldb::addr_t, lldb::addr_t, FileRange, 1> VMRangeToFileOffset;
- typedef lldb_private::RangeDataVector<lldb::addr_t, lldb::addr_t, uint32_t> VMRangeToPermissions;
-
- lldb::ModuleSP m_core_module_sp;
- lldb_private::FileSpec m_core_file;
- std::string m_dyld_plugin_name;
- DISALLOW_COPY_AND_ASSIGN (ProcessElfCore);
-
- llvm::Triple::OSType m_os;
-
- // True if m_thread_contexts contains valid entries
- bool m_thread_data_valid;
-
- // Contain thread data read from NOTE segments
- std::vector<ThreadData> m_thread_data;
-
- // AUXV structure found from the NOTE segment
- lldb_private::DataExtractor m_auxv;
-
- // Address ranges found in the core
- VMRangeToFileOffset m_core_aranges;
-
- // Permissions for all ranges
- VMRangeToPermissions m_core_range_infos;
-
- // NT_FILE entries found from the NOTE segment
- std::vector<NT_FILE_Entry> m_nt_file_entries;
-
- // Parse thread(s) data structures(prstatus, prpsinfo) from given NOTE segment
- lldb_private::Error
- ParseThreadContextsFromNoteSegment(const elf::ELFProgramHeader *segment_header,
- lldb_private::DataExtractor segment_data);
-
- // Returns number of thread contexts stored in the core file
- uint32_t
- GetNumThreadContexts();
-
- // Parse a contiguous address range of the process from LOAD segment
- lldb::addr_t
- AddAddressRangeFromLoadSegment(const elf::ELFProgramHeader *header);
+ struct NT_FILE_Entry {
+ lldb::addr_t start;
+ lldb::addr_t end;
+ lldb::addr_t file_ofs;
+ lldb_private::ConstString path;
+ };
+
+ //------------------------------------------------------------------
+ // For ProcessElfCore only
+ //------------------------------------------------------------------
+ typedef lldb_private::Range<lldb::addr_t, lldb::addr_t> FileRange;
+ typedef lldb_private::RangeDataArray<lldb::addr_t, lldb::addr_t, FileRange, 1>
+ VMRangeToFileOffset;
+ typedef lldb_private::RangeDataVector<lldb::addr_t, lldb::addr_t, uint32_t>
+ VMRangeToPermissions;
+
+ lldb::ModuleSP m_core_module_sp;
+ lldb_private::FileSpec m_core_file;
+ std::string m_dyld_plugin_name;
+ DISALLOW_COPY_AND_ASSIGN(ProcessElfCore);
+
+ llvm::Triple::OSType m_os;
+
+ // True if m_thread_contexts contains valid entries
+ bool m_thread_data_valid;
+
+ // Contain thread data read from NOTE segments
+ std::vector<ThreadData> m_thread_data;
+
+ // AUXV structure found from the NOTE segment
+ lldb_private::DataExtractor m_auxv;
+
+ // Address ranges found in the core
+ VMRangeToFileOffset m_core_aranges;
+
+ // Permissions for all ranges
+ VMRangeToPermissions m_core_range_infos;
+
+ // NT_FILE entries found from the NOTE segment
+ std::vector<NT_FILE_Entry> m_nt_file_entries;
+
+ // Parse thread(s) data structures(prstatus, prpsinfo) from given NOTE segment
+ lldb_private::Error ParseThreadContextsFromNoteSegment(
+ const elf::ELFProgramHeader *segment_header,
+ lldb_private::DataExtractor segment_data);
+
+ // Returns number of thread contexts stored in the core file
+ uint32_t GetNumThreadContexts();
+
+ // Parse a contiguous address range of the process from LOAD segment
+ lldb::addr_t
+ AddAddressRangeFromLoadSegment(const elf::ELFProgramHeader *header);
};
#endif // liblldb_ProcessElfCore_h_
Modified: lldb/trunk/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_arm.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_arm.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_arm.cpp (original)
+++ lldb/trunk/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_arm.cpp Tue Sep 6 15:57:50 2016
@@ -14,80 +14,58 @@
using namespace lldb_private;
-RegisterContextCorePOSIX_arm::RegisterContextCorePOSIX_arm(Thread &thread,
- RegisterInfoInterface *register_info,
- const DataExtractor &gpregset,
- const DataExtractor &fpregset)
- : RegisterContextPOSIX_arm(thread, 0, register_info)
-{
- m_gpr_buffer.reset(new DataBufferHeap(gpregset.GetDataStart(), gpregset.GetByteSize()));
- m_gpr.SetData(m_gpr_buffer);
- m_gpr.SetByteOrder(gpregset.GetByteOrder());
-}
-
-RegisterContextCorePOSIX_arm::~RegisterContextCorePOSIX_arm()
-{
-}
-
-bool
-RegisterContextCorePOSIX_arm::ReadGPR()
-{
- return true;
+RegisterContextCorePOSIX_arm::RegisterContextCorePOSIX_arm(
+ Thread &thread, RegisterInfoInterface *register_info,
+ const DataExtractor &gpregset, const DataExtractor &fpregset)
+ : RegisterContextPOSIX_arm(thread, 0, register_info) {
+ m_gpr_buffer.reset(
+ new DataBufferHeap(gpregset.GetDataStart(), gpregset.GetByteSize()));
+ m_gpr.SetData(m_gpr_buffer);
+ m_gpr.SetByteOrder(gpregset.GetByteOrder());
}
-bool
-RegisterContextCorePOSIX_arm::ReadFPR()
-{
- return false;
-}
+RegisterContextCorePOSIX_arm::~RegisterContextCorePOSIX_arm() {}
+
+bool RegisterContextCorePOSIX_arm::ReadGPR() { return true; }
-bool
-RegisterContextCorePOSIX_arm::WriteGPR()
-{
- assert(0);
- return false;
+bool RegisterContextCorePOSIX_arm::ReadFPR() { return false; }
+
+bool RegisterContextCorePOSIX_arm::WriteGPR() {
+ assert(0);
+ return false;
}
-bool
-RegisterContextCorePOSIX_arm::WriteFPR()
-{
- assert(0);
- return false;
+bool RegisterContextCorePOSIX_arm::WriteFPR() {
+ assert(0);
+ return false;
}
-bool
-RegisterContextCorePOSIX_arm::ReadRegister(const RegisterInfo *reg_info, RegisterValue &value)
-{
- lldb::offset_t offset = reg_info->byte_offset;
- uint64_t v = m_gpr.GetMaxU64(&offset, reg_info->byte_size);
- if (offset == reg_info->byte_offset + reg_info->byte_size)
- {
- value = v;
- return true;
- }
- return false;
+bool RegisterContextCorePOSIX_arm::ReadRegister(const RegisterInfo *reg_info,
+ RegisterValue &value) {
+ lldb::offset_t offset = reg_info->byte_offset;
+ uint64_t v = m_gpr.GetMaxU64(&offset, reg_info->byte_size);
+ if (offset == reg_info->byte_offset + reg_info->byte_size) {
+ value = v;
+ return true;
+ }
+ return false;
}
-bool
-RegisterContextCorePOSIX_arm::ReadAllRegisterValues(lldb::DataBufferSP &data_sp)
-{
- return false;
+bool RegisterContextCorePOSIX_arm::ReadAllRegisterValues(
+ lldb::DataBufferSP &data_sp) {
+ return false;
}
-bool
-RegisterContextCorePOSIX_arm::WriteRegister(const RegisterInfo *reg_info, const RegisterValue &value)
-{
- return false;
+bool RegisterContextCorePOSIX_arm::WriteRegister(const RegisterInfo *reg_info,
+ const RegisterValue &value) {
+ return false;
}
-bool
-RegisterContextCorePOSIX_arm::WriteAllRegisterValues(const lldb::DataBufferSP &data_sp)
-{
- return false;
+bool RegisterContextCorePOSIX_arm::WriteAllRegisterValues(
+ const lldb::DataBufferSP &data_sp) {
+ return false;
}
-bool
-RegisterContextCorePOSIX_arm::HardwareSingleStep(bool enable)
-{
- return false;
+bool RegisterContextCorePOSIX_arm::HardwareSingleStep(bool enable) {
+ return false;
}
Modified: lldb/trunk/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_arm.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_arm.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_arm.h (original)
+++ lldb/trunk/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_arm.h Tue Sep 6 15:57:50 2016
@@ -18,50 +18,40 @@
#include "lldb/Core/DataBufferHeap.h"
#include "lldb/Core/DataExtractor.h"
-class RegisterContextCorePOSIX_arm :
- public RegisterContextPOSIX_arm
-{
+class RegisterContextCorePOSIX_arm : public RegisterContextPOSIX_arm {
public:
- RegisterContextCorePOSIX_arm (lldb_private::Thread &thread,
- lldb_private::RegisterInfoInterface *register_info,
- const lldb_private::DataExtractor &gpregset,
- const lldb_private::DataExtractor &fpregset);
+ RegisterContextCorePOSIX_arm(
+ lldb_private::Thread &thread,
+ lldb_private::RegisterInfoInterface *register_info,
+ const lldb_private::DataExtractor &gpregset,
+ const lldb_private::DataExtractor &fpregset);
- ~RegisterContextCorePOSIX_arm() override;
+ ~RegisterContextCorePOSIX_arm() override;
- bool
- ReadRegister(const lldb_private::RegisterInfo *reg_info,
- lldb_private::RegisterValue &value) override;
+ bool ReadRegister(const lldb_private::RegisterInfo *reg_info,
+ lldb_private::RegisterValue &value) override;
- bool
- WriteRegister(const lldb_private::RegisterInfo *reg_info,
- const lldb_private::RegisterValue &value) override;
+ bool WriteRegister(const lldb_private::RegisterInfo *reg_info,
+ const lldb_private::RegisterValue &value) override;
- bool
- ReadAllRegisterValues(lldb::DataBufferSP &data_sp) override;
+ bool ReadAllRegisterValues(lldb::DataBufferSP &data_sp) override;
- bool
- WriteAllRegisterValues(const lldb::DataBufferSP &data_sp) override;
+ bool WriteAllRegisterValues(const lldb::DataBufferSP &data_sp) override;
- bool
- HardwareSingleStep(bool enable) override;
+ bool HardwareSingleStep(bool enable) override;
protected:
- bool
- ReadGPR() override;
+ bool ReadGPR() override;
- bool
- ReadFPR() override;
+ bool ReadFPR() override;
- bool
- WriteGPR() override;
+ bool WriteGPR() override;
- bool
- WriteFPR() override;
+ bool WriteFPR() override;
private:
- lldb::DataBufferSP m_gpr_buffer;
- lldb_private::DataExtractor m_gpr;
+ lldb::DataBufferSP m_gpr_buffer;
+ lldb_private::DataExtractor m_gpr;
};
#endif // liblldb_RegisterContextCorePOSIX_arm_h_
Modified: lldb/trunk/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_arm64.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_arm64.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_arm64.cpp (original)
+++ lldb/trunk/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_arm64.cpp Tue Sep 6 15:57:50 2016
@@ -14,80 +14,58 @@
using namespace lldb_private;
-RegisterContextCorePOSIX_arm64::RegisterContextCorePOSIX_arm64(Thread &thread,
- RegisterInfoInterface *register_info,
- const DataExtractor &gpregset,
- const DataExtractor &fpregset)
- : RegisterContextPOSIX_arm64(thread, 0, register_info)
-{
- m_gpr_buffer.reset(new DataBufferHeap(gpregset.GetDataStart(), gpregset.GetByteSize()));
- m_gpr.SetData(m_gpr_buffer);
- m_gpr.SetByteOrder(gpregset.GetByteOrder());
-}
-
-RegisterContextCorePOSIX_arm64::~RegisterContextCorePOSIX_arm64()
-{
-}
-
-bool
-RegisterContextCorePOSIX_arm64::ReadGPR()
-{
- return true;
+RegisterContextCorePOSIX_arm64::RegisterContextCorePOSIX_arm64(
+ Thread &thread, RegisterInfoInterface *register_info,
+ const DataExtractor &gpregset, const DataExtractor &fpregset)
+ : RegisterContextPOSIX_arm64(thread, 0, register_info) {
+ m_gpr_buffer.reset(
+ new DataBufferHeap(gpregset.GetDataStart(), gpregset.GetByteSize()));
+ m_gpr.SetData(m_gpr_buffer);
+ m_gpr.SetByteOrder(gpregset.GetByteOrder());
}
-bool
-RegisterContextCorePOSIX_arm64::ReadFPR()
-{
- return false;
-}
+RegisterContextCorePOSIX_arm64::~RegisterContextCorePOSIX_arm64() {}
+
+bool RegisterContextCorePOSIX_arm64::ReadGPR() { return true; }
-bool
-RegisterContextCorePOSIX_arm64::WriteGPR()
-{
- assert(0);
- return false;
+bool RegisterContextCorePOSIX_arm64::ReadFPR() { return false; }
+
+bool RegisterContextCorePOSIX_arm64::WriteGPR() {
+ assert(0);
+ return false;
}
-bool
-RegisterContextCorePOSIX_arm64::WriteFPR()
-{
- assert(0);
- return false;
+bool RegisterContextCorePOSIX_arm64::WriteFPR() {
+ assert(0);
+ return false;
}
-bool
-RegisterContextCorePOSIX_arm64::ReadRegister(const RegisterInfo *reg_info, RegisterValue &value)
-{
- lldb::offset_t offset = reg_info->byte_offset;
- uint64_t v = m_gpr.GetMaxU64(&offset, reg_info->byte_size);
- if (offset == reg_info->byte_offset + reg_info->byte_size)
- {
- value = v;
- return true;
- }
- return false;
+bool RegisterContextCorePOSIX_arm64::ReadRegister(const RegisterInfo *reg_info,
+ RegisterValue &value) {
+ lldb::offset_t offset = reg_info->byte_offset;
+ uint64_t v = m_gpr.GetMaxU64(&offset, reg_info->byte_size);
+ if (offset == reg_info->byte_offset + reg_info->byte_size) {
+ value = v;
+ return true;
+ }
+ return false;
}
-bool
-RegisterContextCorePOSIX_arm64::ReadAllRegisterValues(lldb::DataBufferSP &data_sp)
-{
- return false;
+bool RegisterContextCorePOSIX_arm64::ReadAllRegisterValues(
+ lldb::DataBufferSP &data_sp) {
+ return false;
}
-bool
-RegisterContextCorePOSIX_arm64::WriteRegister(const RegisterInfo *reg_info, const RegisterValue &value)
-{
- return false;
+bool RegisterContextCorePOSIX_arm64::WriteRegister(const RegisterInfo *reg_info,
+ const RegisterValue &value) {
+ return false;
}
-bool
-RegisterContextCorePOSIX_arm64::WriteAllRegisterValues(const lldb::DataBufferSP &data_sp)
-{
- return false;
+bool RegisterContextCorePOSIX_arm64::WriteAllRegisterValues(
+ const lldb::DataBufferSP &data_sp) {
+ return false;
}
-bool
-RegisterContextCorePOSIX_arm64::HardwareSingleStep(bool enable)
-{
- return false;
+bool RegisterContextCorePOSIX_arm64::HardwareSingleStep(bool enable) {
+ return false;
}
Modified: lldb/trunk/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_arm64.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_arm64.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_arm64.h (original)
+++ lldb/trunk/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_arm64.h Tue Sep 6 15:57:50 2016
@@ -18,50 +18,40 @@
#include "lldb/Core/DataBufferHeap.h"
#include "lldb/Core/DataExtractor.h"
-class RegisterContextCorePOSIX_arm64 :
- public RegisterContextPOSIX_arm64
-{
+class RegisterContextCorePOSIX_arm64 : public RegisterContextPOSIX_arm64 {
public:
- RegisterContextCorePOSIX_arm64 (lldb_private::Thread &thread,
- lldb_private::RegisterInfoInterface *register_info,
- const lldb_private::DataExtractor &gpregset,
- const lldb_private::DataExtractor &fpregset);
+ RegisterContextCorePOSIX_arm64(
+ lldb_private::Thread &thread,
+ lldb_private::RegisterInfoInterface *register_info,
+ const lldb_private::DataExtractor &gpregset,
+ const lldb_private::DataExtractor &fpregset);
- ~RegisterContextCorePOSIX_arm64() override;
+ ~RegisterContextCorePOSIX_arm64() override;
- bool
- ReadRegister(const lldb_private::RegisterInfo *reg_info,
- lldb_private::RegisterValue &value) override;
+ bool ReadRegister(const lldb_private::RegisterInfo *reg_info,
+ lldb_private::RegisterValue &value) override;
- bool
- WriteRegister(const lldb_private::RegisterInfo *reg_info,
- const lldb_private::RegisterValue &value) override;
+ bool WriteRegister(const lldb_private::RegisterInfo *reg_info,
+ const lldb_private::RegisterValue &value) override;
- bool
- ReadAllRegisterValues(lldb::DataBufferSP &data_sp) override;
+ bool ReadAllRegisterValues(lldb::DataBufferSP &data_sp) override;
- bool
- WriteAllRegisterValues(const lldb::DataBufferSP &data_sp) override;
+ bool WriteAllRegisterValues(const lldb::DataBufferSP &data_sp) override;
- bool
- HardwareSingleStep(bool enable) override;
+ bool HardwareSingleStep(bool enable) override;
protected:
- bool
- ReadGPR() override;
+ bool ReadGPR() override;
- bool
- ReadFPR() override;
+ bool ReadFPR() override;
- bool
- WriteGPR() override;
+ bool WriteGPR() override;
- bool
- WriteFPR() override;
+ bool WriteFPR() override;
private:
- lldb::DataBufferSP m_gpr_buffer;
- lldb_private::DataExtractor m_gpr;
+ lldb::DataBufferSP m_gpr_buffer;
+ lldb_private::DataExtractor m_gpr;
};
#endif // liblldb_RegisterContextCorePOSIX_arm64_h_
Modified: lldb/trunk/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_mips64.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_mips64.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_mips64.cpp (original)
+++ lldb/trunk/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_mips64.cpp Tue Sep 6 15:57:50 2016
@@ -14,80 +14,58 @@
using namespace lldb_private;
-RegisterContextCorePOSIX_mips64::RegisterContextCorePOSIX_mips64(Thread &thread,
- RegisterInfoInterface *register_info,
- const DataExtractor &gpregset,
- const DataExtractor &fpregset)
- : RegisterContextPOSIX_mips64(thread, 0, register_info)
-{
- m_gpr_buffer.reset(new DataBufferHeap(gpregset.GetDataStart(), gpregset.GetByteSize()));
- m_gpr.SetData(m_gpr_buffer);
- m_gpr.SetByteOrder(gpregset.GetByteOrder());
-}
-
-RegisterContextCorePOSIX_mips64::~RegisterContextCorePOSIX_mips64()
-{
-}
-
-bool
-RegisterContextCorePOSIX_mips64::ReadGPR()
-{
- return true;
+RegisterContextCorePOSIX_mips64::RegisterContextCorePOSIX_mips64(
+ Thread &thread, RegisterInfoInterface *register_info,
+ const DataExtractor &gpregset, const DataExtractor &fpregset)
+ : RegisterContextPOSIX_mips64(thread, 0, register_info) {
+ m_gpr_buffer.reset(
+ new DataBufferHeap(gpregset.GetDataStart(), gpregset.GetByteSize()));
+ m_gpr.SetData(m_gpr_buffer);
+ m_gpr.SetByteOrder(gpregset.GetByteOrder());
}
-bool
-RegisterContextCorePOSIX_mips64::ReadFPR()
-{
- return false;
-}
+RegisterContextCorePOSIX_mips64::~RegisterContextCorePOSIX_mips64() {}
+
+bool RegisterContextCorePOSIX_mips64::ReadGPR() { return true; }
-bool
-RegisterContextCorePOSIX_mips64::WriteGPR()
-{
- assert(0);
- return false;
+bool RegisterContextCorePOSIX_mips64::ReadFPR() { return false; }
+
+bool RegisterContextCorePOSIX_mips64::WriteGPR() {
+ assert(0);
+ return false;
}
-bool
-RegisterContextCorePOSIX_mips64::WriteFPR()
-{
- assert(0);
- return false;
+bool RegisterContextCorePOSIX_mips64::WriteFPR() {
+ assert(0);
+ return false;
}
-bool
-RegisterContextCorePOSIX_mips64::ReadRegister(const RegisterInfo *reg_info, RegisterValue &value)
-{
- lldb::offset_t offset = reg_info->byte_offset;
- uint64_t v = m_gpr.GetMaxU64(&offset, reg_info->byte_size);
- if (offset == reg_info->byte_offset + reg_info->byte_size)
- {
- value = v;
- return true;
- }
- return false;
+bool RegisterContextCorePOSIX_mips64::ReadRegister(const RegisterInfo *reg_info,
+ RegisterValue &value) {
+ lldb::offset_t offset = reg_info->byte_offset;
+ uint64_t v = m_gpr.GetMaxU64(&offset, reg_info->byte_size);
+ if (offset == reg_info->byte_offset + reg_info->byte_size) {
+ value = v;
+ return true;
+ }
+ return false;
}
-bool
-RegisterContextCorePOSIX_mips64::ReadAllRegisterValues(lldb::DataBufferSP &data_sp)
-{
- return false;
+bool RegisterContextCorePOSIX_mips64::ReadAllRegisterValues(
+ lldb::DataBufferSP &data_sp) {
+ return false;
}
-bool
-RegisterContextCorePOSIX_mips64::WriteRegister(const RegisterInfo *reg_info, const RegisterValue &value)
-{
- return false;
+bool RegisterContextCorePOSIX_mips64::WriteRegister(
+ const RegisterInfo *reg_info, const RegisterValue &value) {
+ return false;
}
-bool
-RegisterContextCorePOSIX_mips64::WriteAllRegisterValues(const lldb::DataBufferSP &data_sp)
-{
- return false;
+bool RegisterContextCorePOSIX_mips64::WriteAllRegisterValues(
+ const lldb::DataBufferSP &data_sp) {
+ return false;
}
-bool
-RegisterContextCorePOSIX_mips64::HardwareSingleStep(bool enable)
-{
- return false;
+bool RegisterContextCorePOSIX_mips64::HardwareSingleStep(bool enable) {
+ return false;
}
Modified: lldb/trunk/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_mips64.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_mips64.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_mips64.h (original)
+++ lldb/trunk/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_mips64.h Tue Sep 6 15:57:50 2016
@@ -18,50 +18,40 @@
#include "lldb/Core/DataBufferHeap.h"
#include "lldb/Core/DataExtractor.h"
-class RegisterContextCorePOSIX_mips64 :
- public RegisterContextPOSIX_mips64
-{
+class RegisterContextCorePOSIX_mips64 : public RegisterContextPOSIX_mips64 {
public:
- RegisterContextCorePOSIX_mips64 (lldb_private::Thread &thread,
- lldb_private::RegisterInfoInterface *register_info,
- const lldb_private::DataExtractor &gpregset,
- const lldb_private::DataExtractor &fpregset);
+ RegisterContextCorePOSIX_mips64(
+ lldb_private::Thread &thread,
+ lldb_private::RegisterInfoInterface *register_info,
+ const lldb_private::DataExtractor &gpregset,
+ const lldb_private::DataExtractor &fpregset);
- ~RegisterContextCorePOSIX_mips64() override;
+ ~RegisterContextCorePOSIX_mips64() override;
- bool
- ReadRegister(const lldb_private::RegisterInfo *reg_info,
- lldb_private::RegisterValue &value) override;
+ bool ReadRegister(const lldb_private::RegisterInfo *reg_info,
+ lldb_private::RegisterValue &value) override;
- bool
- WriteRegister(const lldb_private::RegisterInfo *reg_info,
- const lldb_private::RegisterValue &value) override;
+ bool WriteRegister(const lldb_private::RegisterInfo *reg_info,
+ const lldb_private::RegisterValue &value) override;
- bool
- ReadAllRegisterValues(lldb::DataBufferSP &data_sp) override;
+ bool ReadAllRegisterValues(lldb::DataBufferSP &data_sp) override;
- bool
- WriteAllRegisterValues(const lldb::DataBufferSP &data_sp) override;
+ bool WriteAllRegisterValues(const lldb::DataBufferSP &data_sp) override;
- bool
- HardwareSingleStep(bool enable) override;
+ bool HardwareSingleStep(bool enable) override;
protected:
- bool
- ReadGPR() override;
+ bool ReadGPR() override;
- bool
- ReadFPR() override;
+ bool ReadFPR() override;
- bool
- WriteGPR() override;
+ bool WriteGPR() override;
- bool
- WriteFPR() override;
+ bool WriteFPR() override;
private:
- lldb::DataBufferSP m_gpr_buffer;
- lldb_private::DataExtractor m_gpr;
+ lldb::DataBufferSP m_gpr_buffer;
+ lldb_private::DataExtractor m_gpr;
};
#endif // liblldb_RegisterContextCorePOSIX_mips64_h_
Modified: lldb/trunk/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_powerpc.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_powerpc.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_powerpc.cpp (original)
+++ lldb/trunk/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_powerpc.cpp Tue Sep 6 15:57:50 2016
@@ -1,4 +1,5 @@
-//===-- RegisterContextCorePOSIX_powerpc.cpp ---------------------*- C++ -*-===//
+//===-- RegisterContextCorePOSIX_powerpc.cpp ---------------------*- C++
+//-*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -15,120 +16,92 @@
using namespace lldb_private;
-RegisterContextCorePOSIX_powerpc::RegisterContextCorePOSIX_powerpc(Thread &thread,
- RegisterInfoInterface *register_info,
- const DataExtractor &gpregset,
- const DataExtractor &fpregset,
- const DataExtractor &vregset)
- : RegisterContextPOSIX_powerpc(thread, 0, register_info)
-{
- m_gpr_buffer.reset(new DataBufferHeap(gpregset.GetDataStart(), gpregset.GetByteSize()));
- m_gpr.SetData(m_gpr_buffer);
- m_gpr.SetByteOrder(gpregset.GetByteOrder());
- m_fpr_buffer.reset(new DataBufferHeap(fpregset.GetDataStart(), fpregset.GetByteSize()));
- m_fpr.SetData(m_fpr_buffer);
- m_fpr.SetByteOrder(fpregset.GetByteOrder());
- m_vec_buffer.reset(new DataBufferHeap(vregset.GetDataStart(), vregset.GetByteSize()));
- m_vec.SetData(m_vec_buffer);
- m_vec.SetByteOrder(vregset.GetByteOrder());
-}
-
-RegisterContextCorePOSIX_powerpc::~RegisterContextCorePOSIX_powerpc()
-{
-}
-
-bool
-RegisterContextCorePOSIX_powerpc::ReadGPR()
-{
- return true;
-}
-
-bool
-RegisterContextCorePOSIX_powerpc::ReadFPR()
-{
- return true;
-}
-
-bool
-RegisterContextCorePOSIX_powerpc::ReadVMX()
-{
- return true;
-}
-
-bool
-RegisterContextCorePOSIX_powerpc::WriteGPR()
-{
- assert(0);
- return false;
-}
-
-bool
-RegisterContextCorePOSIX_powerpc::WriteFPR()
-{
- assert(0);
- return false;
-}
-
-bool
-RegisterContextCorePOSIX_powerpc::WriteVMX()
-{
- assert(0);
- return false;
-}
-
-bool
-RegisterContextCorePOSIX_powerpc::ReadRegister(const RegisterInfo *reg_info, RegisterValue &value)
-{
- lldb::offset_t offset = reg_info->byte_offset;
- if (IsFPR(reg_info->kinds[lldb::eRegisterKindLLDB])) {
- uint64_t v = m_fpr.GetMaxU64(&offset, reg_info->byte_size);
- if (offset == reg_info->byte_offset + reg_info->byte_size)
- {
- value = v;
- return true;
- }
- } else if (IsVMX(reg_info->kinds[lldb::eRegisterKindLLDB])) {
- uint32_t v[4];
- offset = m_vec.CopyData(offset, reg_info->byte_size, &v);
- if (offset == reg_info->byte_size)
- {
- value.SetBytes(v, reg_info->byte_size, m_vec.GetByteOrder());
- return true;
- }
- } else {
- uint64_t v = m_gpr.GetMaxU64(&offset, reg_info->byte_size);
- if (offset == reg_info->byte_offset + reg_info->byte_size)
- {
- if (reg_info->byte_size < sizeof(v))
- value = (uint32_t)v;
- else
- value = v;
- return true;
- }
+RegisterContextCorePOSIX_powerpc::RegisterContextCorePOSIX_powerpc(
+ Thread &thread, RegisterInfoInterface *register_info,
+ const DataExtractor &gpregset, const DataExtractor &fpregset,
+ const DataExtractor &vregset)
+ : RegisterContextPOSIX_powerpc(thread, 0, register_info) {
+ m_gpr_buffer.reset(
+ new DataBufferHeap(gpregset.GetDataStart(), gpregset.GetByteSize()));
+ m_gpr.SetData(m_gpr_buffer);
+ m_gpr.SetByteOrder(gpregset.GetByteOrder());
+ m_fpr_buffer.reset(
+ new DataBufferHeap(fpregset.GetDataStart(), fpregset.GetByteSize()));
+ m_fpr.SetData(m_fpr_buffer);
+ m_fpr.SetByteOrder(fpregset.GetByteOrder());
+ m_vec_buffer.reset(
+ new DataBufferHeap(vregset.GetDataStart(), vregset.GetByteSize()));
+ m_vec.SetData(m_vec_buffer);
+ m_vec.SetByteOrder(vregset.GetByteOrder());
+}
+
+RegisterContextCorePOSIX_powerpc::~RegisterContextCorePOSIX_powerpc() {}
+
+bool RegisterContextCorePOSIX_powerpc::ReadGPR() { return true; }
+
+bool RegisterContextCorePOSIX_powerpc::ReadFPR() { return true; }
+
+bool RegisterContextCorePOSIX_powerpc::ReadVMX() { return true; }
+
+bool RegisterContextCorePOSIX_powerpc::WriteGPR() {
+ assert(0);
+ return false;
+}
+
+bool RegisterContextCorePOSIX_powerpc::WriteFPR() {
+ assert(0);
+ return false;
+}
+
+bool RegisterContextCorePOSIX_powerpc::WriteVMX() {
+ assert(0);
+ return false;
+}
+
+bool RegisterContextCorePOSIX_powerpc::ReadRegister(
+ const RegisterInfo *reg_info, RegisterValue &value) {
+ lldb::offset_t offset = reg_info->byte_offset;
+ if (IsFPR(reg_info->kinds[lldb::eRegisterKindLLDB])) {
+ uint64_t v = m_fpr.GetMaxU64(&offset, reg_info->byte_size);
+ if (offset == reg_info->byte_offset + reg_info->byte_size) {
+ value = v;
+ return true;
}
- return false;
+ } else if (IsVMX(reg_info->kinds[lldb::eRegisterKindLLDB])) {
+ uint32_t v[4];
+ offset = m_vec.CopyData(offset, reg_info->byte_size, &v);
+ if (offset == reg_info->byte_size) {
+ value.SetBytes(v, reg_info->byte_size, m_vec.GetByteOrder());
+ return true;
+ }
+ } else {
+ uint64_t v = m_gpr.GetMaxU64(&offset, reg_info->byte_size);
+ if (offset == reg_info->byte_offset + reg_info->byte_size) {
+ if (reg_info->byte_size < sizeof(v))
+ value = (uint32_t)v;
+ else
+ value = v;
+ return true;
+ }
+ }
+ return false;
}
-bool
-RegisterContextCorePOSIX_powerpc::ReadAllRegisterValues(lldb::DataBufferSP &data_sp)
-{
- return false;
+bool RegisterContextCorePOSIX_powerpc::ReadAllRegisterValues(
+ lldb::DataBufferSP &data_sp) {
+ return false;
}
-bool
-RegisterContextCorePOSIX_powerpc::WriteRegister(const RegisterInfo *reg_info, const RegisterValue &value)
-{
- return false;
+bool RegisterContextCorePOSIX_powerpc::WriteRegister(
+ const RegisterInfo *reg_info, const RegisterValue &value) {
+ return false;
}
-bool
-RegisterContextCorePOSIX_powerpc::WriteAllRegisterValues(const lldb::DataBufferSP &data_sp)
-{
- return false;
+bool RegisterContextCorePOSIX_powerpc::WriteAllRegisterValues(
+ const lldb::DataBufferSP &data_sp) {
+ return false;
}
-bool
-RegisterContextCorePOSIX_powerpc::HardwareSingleStep(bool enable)
-{
- return false;
+bool RegisterContextCorePOSIX_powerpc::HardwareSingleStep(bool enable) {
+ return false;
}
Modified: lldb/trunk/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_powerpc.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_powerpc.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_powerpc.h (original)
+++ lldb/trunk/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_powerpc.h Tue Sep 6 15:57:50 2016
@@ -17,61 +17,49 @@
#include "Plugins/Process/Utility/RegisterContextPOSIX_powerpc.h"
#include "lldb/Core/DataExtractor.h"
-class RegisterContextCorePOSIX_powerpc :
- public RegisterContextPOSIX_powerpc
-{
+class RegisterContextCorePOSIX_powerpc : public RegisterContextPOSIX_powerpc {
public:
- RegisterContextCorePOSIX_powerpc (lldb_private::Thread &thread,
- lldb_private::RegisterInfoInterface *register_info,
- const lldb_private::DataExtractor &gpregset,
- const lldb_private::DataExtractor &fpregset,
- const lldb_private::DataExtractor &vregset);
-
- ~RegisterContextCorePOSIX_powerpc() override;
-
- bool
- ReadRegister(const lldb_private::RegisterInfo *reg_info,
- lldb_private::RegisterValue &value) override;
-
- bool
- WriteRegister(const lldb_private::RegisterInfo *reg_info,
- const lldb_private::RegisterValue &value) override;
+ RegisterContextCorePOSIX_powerpc(
+ lldb_private::Thread &thread,
+ lldb_private::RegisterInfoInterface *register_info,
+ const lldb_private::DataExtractor &gpregset,
+ const lldb_private::DataExtractor &fpregset,
+ const lldb_private::DataExtractor &vregset);
- bool
- ReadAllRegisterValues(lldb::DataBufferSP &data_sp) override;
+ ~RegisterContextCorePOSIX_powerpc() override;
- bool
- WriteAllRegisterValues(const lldb::DataBufferSP &data_sp) override;
+ bool ReadRegister(const lldb_private::RegisterInfo *reg_info,
+ lldb_private::RegisterValue &value) override;
- bool
- HardwareSingleStep(bool enable) override;
+ bool WriteRegister(const lldb_private::RegisterInfo *reg_info,
+ const lldb_private::RegisterValue &value) override;
+
+ bool ReadAllRegisterValues(lldb::DataBufferSP &data_sp) override;
+
+ bool WriteAllRegisterValues(const lldb::DataBufferSP &data_sp) override;
+
+ bool HardwareSingleStep(bool enable) override;
protected:
- bool
- ReadGPR() override;
+ bool ReadGPR() override;
- bool
- ReadFPR() override;
+ bool ReadFPR() override;
- bool
- ReadVMX() override;
+ bool ReadVMX() override;
- bool
- WriteGPR() override;
+ bool WriteGPR() override;
- bool
- WriteFPR() override;
+ bool WriteFPR() override;
- bool
- WriteVMX() override;
+ bool WriteVMX() override;
private:
- lldb::DataBufferSP m_gpr_buffer;
- lldb::DataBufferSP m_fpr_buffer;
- lldb::DataBufferSP m_vec_buffer;
- lldb_private::DataExtractor m_gpr;
- lldb_private::DataExtractor m_fpr;
- lldb_private::DataExtractor m_vec;
+ lldb::DataBufferSP m_gpr_buffer;
+ lldb::DataBufferSP m_fpr_buffer;
+ lldb::DataBufferSP m_vec_buffer;
+ lldb_private::DataExtractor m_gpr;
+ lldb_private::DataExtractor m_fpr;
+ lldb_private::DataExtractor m_vec;
};
#endif // liblldb_RegisterContextCorePOSIX_powerpc_h_
Modified: lldb/trunk/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_s390x.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_s390x.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_s390x.cpp (original)
+++ lldb/trunk/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_s390x.cpp Tue Sep 6 15:57:50 2016
@@ -15,102 +15,79 @@
using namespace lldb_private;
-RegisterContextCorePOSIX_s390x::RegisterContextCorePOSIX_s390x(Thread &thread, RegisterInfoInterface *register_info,
- const DataExtractor &gpregset,
- const DataExtractor &fpregset)
- : RegisterContextPOSIX_s390x(thread, 0, register_info)
-{
- m_gpr_buffer.reset(new DataBufferHeap(gpregset.GetDataStart(), gpregset.GetByteSize()));
- m_gpr.SetData(m_gpr_buffer);
- m_gpr.SetByteOrder(gpregset.GetByteOrder());
+RegisterContextCorePOSIX_s390x::RegisterContextCorePOSIX_s390x(
+ Thread &thread, RegisterInfoInterface *register_info,
+ const DataExtractor &gpregset, const DataExtractor &fpregset)
+ : RegisterContextPOSIX_s390x(thread, 0, register_info) {
+ m_gpr_buffer.reset(
+ new DataBufferHeap(gpregset.GetDataStart(), gpregset.GetByteSize()));
+ m_gpr.SetData(m_gpr_buffer);
+ m_gpr.SetByteOrder(gpregset.GetByteOrder());
- m_fpr_buffer.reset(new DataBufferHeap(fpregset.GetDataStart(), fpregset.GetByteSize()));
- m_fpr.SetData(m_fpr_buffer);
- m_fpr.SetByteOrder(fpregset.GetByteOrder());
+ m_fpr_buffer.reset(
+ new DataBufferHeap(fpregset.GetDataStart(), fpregset.GetByteSize()));
+ m_fpr.SetData(m_fpr_buffer);
+ m_fpr.SetByteOrder(fpregset.GetByteOrder());
}
-RegisterContextCorePOSIX_s390x::~RegisterContextCorePOSIX_s390x()
-{
-}
+RegisterContextCorePOSIX_s390x::~RegisterContextCorePOSIX_s390x() {}
-bool
-RegisterContextCorePOSIX_s390x::ReadGPR()
-{
- return true;
-}
+bool RegisterContextCorePOSIX_s390x::ReadGPR() { return true; }
+
+bool RegisterContextCorePOSIX_s390x::ReadFPR() { return true; }
-bool
-RegisterContextCorePOSIX_s390x::ReadFPR()
-{
- return true;
+bool RegisterContextCorePOSIX_s390x::WriteGPR() {
+ assert(0);
+ return false;
}
-bool
-RegisterContextCorePOSIX_s390x::WriteGPR()
-{
- assert(0);
- return false;
+bool RegisterContextCorePOSIX_s390x::WriteFPR() {
+ assert(0);
+ return false;
}
-bool
-RegisterContextCorePOSIX_s390x::WriteFPR()
-{
- assert(0);
+bool RegisterContextCorePOSIX_s390x::ReadRegister(const RegisterInfo *reg_info,
+ RegisterValue &value) {
+ const uint32_t reg = reg_info->kinds[lldb::eRegisterKindLLDB];
+ if (reg == LLDB_INVALID_REGNUM)
return false;
-}
-bool
-RegisterContextCorePOSIX_s390x::ReadRegister(const RegisterInfo *reg_info, RegisterValue &value)
-{
- const uint32_t reg = reg_info->kinds[lldb::eRegisterKindLLDB];
- if (reg == LLDB_INVALID_REGNUM)
- return false;
-
- if (IsGPR(reg))
- {
- lldb::offset_t offset = reg_info->byte_offset;
- uint64_t v = m_gpr.GetMaxU64(&offset, reg_info->byte_size);
- if (offset == reg_info->byte_offset + reg_info->byte_size)
- {
- value.SetUInt(v, reg_info->byte_size);
- return true;
- }
+ if (IsGPR(reg)) {
+ lldb::offset_t offset = reg_info->byte_offset;
+ uint64_t v = m_gpr.GetMaxU64(&offset, reg_info->byte_size);
+ if (offset == reg_info->byte_offset + reg_info->byte_size) {
+ value.SetUInt(v, reg_info->byte_size);
+ return true;
}
+ }
- if (IsFPR(reg))
- {
- lldb::offset_t offset = reg_info->byte_offset;
- uint64_t v = m_fpr.GetMaxU64(&offset, reg_info->byte_size);
- if (offset == reg_info->byte_offset + reg_info->byte_size)
- {
- value.SetUInt(v, reg_info->byte_size);
- return true;
- }
+ if (IsFPR(reg)) {
+ lldb::offset_t offset = reg_info->byte_offset;
+ uint64_t v = m_fpr.GetMaxU64(&offset, reg_info->byte_size);
+ if (offset == reg_info->byte_offset + reg_info->byte_size) {
+ value.SetUInt(v, reg_info->byte_size);
+ return true;
}
+ }
- return false;
+ return false;
}
-bool
-RegisterContextCorePOSIX_s390x::ReadAllRegisterValues(lldb::DataBufferSP &data_sp)
-{
- return false;
+bool RegisterContextCorePOSIX_s390x::ReadAllRegisterValues(
+ lldb::DataBufferSP &data_sp) {
+ return false;
}
-bool
-RegisterContextCorePOSIX_s390x::WriteRegister(const RegisterInfo *reg_info, const RegisterValue &value)
-{
- return false;
+bool RegisterContextCorePOSIX_s390x::WriteRegister(const RegisterInfo *reg_info,
+ const RegisterValue &value) {
+ return false;
}
-bool
-RegisterContextCorePOSIX_s390x::WriteAllRegisterValues(const lldb::DataBufferSP &data_sp)
-{
- return false;
+bool RegisterContextCorePOSIX_s390x::WriteAllRegisterValues(
+ const lldb::DataBufferSP &data_sp) {
+ return false;
}
-bool
-RegisterContextCorePOSIX_s390x::HardwareSingleStep(bool enable)
-{
- return false;
+bool RegisterContextCorePOSIX_s390x::HardwareSingleStep(bool enable) {
+ return false;
}
Modified: lldb/trunk/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_s390x.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_s390x.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_s390x.h (original)
+++ lldb/trunk/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_s390x.h Tue Sep 6 15:57:50 2016
@@ -17,49 +17,43 @@
#include "Plugins/Process/Utility/RegisterContextPOSIX_s390x.h"
#include "lldb/Core/DataExtractor.h"
-class RegisterContextCorePOSIX_s390x : public RegisterContextPOSIX_s390x
-{
+class RegisterContextCorePOSIX_s390x : public RegisterContextPOSIX_s390x {
public:
- RegisterContextCorePOSIX_s390x(lldb_private::Thread &thread, lldb_private::RegisterInfoInterface *register_info,
- const lldb_private::DataExtractor &gpregset,
- const lldb_private::DataExtractor &fpregset);
+ RegisterContextCorePOSIX_s390x(
+ lldb_private::Thread &thread,
+ lldb_private::RegisterInfoInterface *register_info,
+ const lldb_private::DataExtractor &gpregset,
+ const lldb_private::DataExtractor &fpregset);
- ~RegisterContextCorePOSIX_s390x() override;
+ ~RegisterContextCorePOSIX_s390x() override;
- bool
- ReadRegister(const lldb_private::RegisterInfo *reg_info, lldb_private::RegisterValue &value) override;
+ bool ReadRegister(const lldb_private::RegisterInfo *reg_info,
+ lldb_private::RegisterValue &value) override;
- bool
- WriteRegister(const lldb_private::RegisterInfo *reg_info, const lldb_private::RegisterValue &value) override;
+ bool WriteRegister(const lldb_private::RegisterInfo *reg_info,
+ const lldb_private::RegisterValue &value) override;
- bool
- ReadAllRegisterValues(lldb::DataBufferSP &data_sp) override;
+ bool ReadAllRegisterValues(lldb::DataBufferSP &data_sp) override;
- bool
- WriteAllRegisterValues(const lldb::DataBufferSP &data_sp) override;
+ bool WriteAllRegisterValues(const lldb::DataBufferSP &data_sp) override;
- bool
- HardwareSingleStep(bool enable) override;
+ bool HardwareSingleStep(bool enable) override;
protected:
- bool
- ReadGPR() override;
+ bool ReadGPR() override;
- bool
- ReadFPR() override;
+ bool ReadFPR() override;
- bool
- WriteGPR() override;
+ bool WriteGPR() override;
- bool
- WriteFPR() override;
+ bool WriteFPR() override;
private:
- lldb::DataBufferSP m_gpr_buffer;
- lldb_private::DataExtractor m_gpr;
+ lldb::DataBufferSP m_gpr_buffer;
+ lldb_private::DataExtractor m_gpr;
- lldb::DataBufferSP m_fpr_buffer;
- lldb_private::DataExtractor m_fpr;
+ lldb::DataBufferSP m_fpr_buffer;
+ lldb_private::DataExtractor m_fpr;
};
#endif // liblldb_RegisterContextCorePOSIX_s390x_h_
Modified: lldb/trunk/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_x86_64.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_x86_64.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_x86_64.cpp (original)
+++ lldb/trunk/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_x86_64.cpp Tue Sep 6 15:57:50 2016
@@ -7,93 +7,71 @@
//
//===----------------------------------------------------------------------===//
+#include "RegisterContextPOSIXCore_x86_64.h"
#include "lldb/Core/DataExtractor.h"
#include "lldb/Core/RegisterValue.h"
#include "lldb/Target/Thread.h"
-#include "RegisterContextPOSIXCore_x86_64.h"
using namespace lldb_private;
-RegisterContextCorePOSIX_x86_64::RegisterContextCorePOSIX_x86_64(Thread &thread,
- RegisterInfoInterface *register_info,
- const DataExtractor &gpregset,
- const DataExtractor &fpregset)
- : RegisterContextPOSIX_x86 (thread, 0, register_info)
-{
- size_t size, len;
+RegisterContextCorePOSIX_x86_64::RegisterContextCorePOSIX_x86_64(
+ Thread &thread, RegisterInfoInterface *register_info,
+ const DataExtractor &gpregset, const DataExtractor &fpregset)
+ : RegisterContextPOSIX_x86(thread, 0, register_info) {
+ size_t size, len;
- size = GetGPRSize();
- m_gpregset = new uint8_t[size];
- len = gpregset.ExtractBytes (0, size, lldb::eByteOrderLittle, m_gpregset);
- assert(len == size);
+ size = GetGPRSize();
+ m_gpregset = new uint8_t[size];
+ len = gpregset.ExtractBytes(0, size, lldb::eByteOrderLittle, m_gpregset);
+ assert(len == size);
}
-RegisterContextCorePOSIX_x86_64::~RegisterContextCorePOSIX_x86_64()
-{
- delete [] m_gpregset;
+RegisterContextCorePOSIX_x86_64::~RegisterContextCorePOSIX_x86_64() {
+ delete[] m_gpregset;
}
-bool
-RegisterContextCorePOSIX_x86_64::ReadGPR()
-{
- return m_gpregset != NULL;
-}
+bool RegisterContextCorePOSIX_x86_64::ReadGPR() { return m_gpregset != NULL; }
-bool
-RegisterContextCorePOSIX_x86_64::ReadFPR()
-{
- return false;
-}
+bool RegisterContextCorePOSIX_x86_64::ReadFPR() { return false; }
-bool
-RegisterContextCorePOSIX_x86_64::WriteGPR()
-{
- assert(0);
- return false;
+bool RegisterContextCorePOSIX_x86_64::WriteGPR() {
+ assert(0);
+ return false;
}
-bool
-RegisterContextCorePOSIX_x86_64::WriteFPR()
-{
- assert(0);
- return false;
+bool RegisterContextCorePOSIX_x86_64::WriteFPR() {
+ assert(0);
+ return false;
}
-bool
-RegisterContextCorePOSIX_x86_64::ReadRegister(const RegisterInfo *reg_info, RegisterValue &value)
-{
- switch (reg_info->byte_size)
- {
- case 4:
- value = *(uint32_t *)(m_gpregset + reg_info->byte_offset);
- return true;
- case 8:
- value = *(uint64_t *)(m_gpregset + reg_info->byte_offset);
- return true;
- }
- return false;
+bool RegisterContextCorePOSIX_x86_64::ReadRegister(const RegisterInfo *reg_info,
+ RegisterValue &value) {
+ switch (reg_info->byte_size) {
+ case 4:
+ value = *(uint32_t *)(m_gpregset + reg_info->byte_offset);
+ return true;
+ case 8:
+ value = *(uint64_t *)(m_gpregset + reg_info->byte_offset);
+ return true;
+ }
+ return false;
}
-bool
-RegisterContextCorePOSIX_x86_64::ReadAllRegisterValues(lldb::DataBufferSP &data_sp)
-{
- return false;
+bool RegisterContextCorePOSIX_x86_64::ReadAllRegisterValues(
+ lldb::DataBufferSP &data_sp) {
+ return false;
}
-bool
-RegisterContextCorePOSIX_x86_64::WriteRegister(const RegisterInfo *reg_info, const RegisterValue &value)
-{
- return false;
+bool RegisterContextCorePOSIX_x86_64::WriteRegister(
+ const RegisterInfo *reg_info, const RegisterValue &value) {
+ return false;
}
-bool
-RegisterContextCorePOSIX_x86_64::WriteAllRegisterValues(const lldb::DataBufferSP &data_sp)
-{
- return false;
+bool RegisterContextCorePOSIX_x86_64::WriteAllRegisterValues(
+ const lldb::DataBufferSP &data_sp) {
+ return false;
}
-bool
-RegisterContextCorePOSIX_x86_64::HardwareSingleStep(bool enable)
-{
- return false;
+bool RegisterContextCorePOSIX_x86_64::HardwareSingleStep(bool enable) {
+ return false;
}
Modified: lldb/trunk/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_x86_64.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_x86_64.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_x86_64.h (original)
+++ lldb/trunk/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_x86_64.h Tue Sep 6 15:57:50 2016
@@ -16,49 +16,39 @@
// Project includes
#include "Plugins/Process/Utility/RegisterContextPOSIX_x86.h"
-class RegisterContextCorePOSIX_x86_64 :
- public RegisterContextPOSIX_x86
-{
+class RegisterContextCorePOSIX_x86_64 : public RegisterContextPOSIX_x86 {
public:
- RegisterContextCorePOSIX_x86_64 (lldb_private::Thread &thread,
- lldb_private::RegisterInfoInterface *register_info,
- const lldb_private::DataExtractor &gpregset,
- const lldb_private::DataExtractor &fpregset);
+ RegisterContextCorePOSIX_x86_64(
+ lldb_private::Thread &thread,
+ lldb_private::RegisterInfoInterface *register_info,
+ const lldb_private::DataExtractor &gpregset,
+ const lldb_private::DataExtractor &fpregset);
- ~RegisterContextCorePOSIX_x86_64() override;
+ ~RegisterContextCorePOSIX_x86_64() override;
- bool
- ReadRegister(const lldb_private::RegisterInfo *reg_info,
- lldb_private::RegisterValue &value) override;
+ bool ReadRegister(const lldb_private::RegisterInfo *reg_info,
+ lldb_private::RegisterValue &value) override;
- bool
- WriteRegister(const lldb_private::RegisterInfo *reg_info,
- const lldb_private::RegisterValue &value) override;
+ bool WriteRegister(const lldb_private::RegisterInfo *reg_info,
+ const lldb_private::RegisterValue &value) override;
- bool
- ReadAllRegisterValues(lldb::DataBufferSP &data_sp) override;
+ bool ReadAllRegisterValues(lldb::DataBufferSP &data_sp) override;
- bool
- WriteAllRegisterValues(const lldb::DataBufferSP &data_sp) override;
+ bool WriteAllRegisterValues(const lldb::DataBufferSP &data_sp) override;
- bool
- HardwareSingleStep(bool enable) override;
+ bool HardwareSingleStep(bool enable) override;
protected:
- bool
- ReadGPR() override;
+ bool ReadGPR() override;
- bool
- ReadFPR() override;
+ bool ReadFPR() override;
- bool
- WriteGPR() override;
+ bool WriteGPR() override;
- bool
- WriteFPR() override;
+ bool WriteFPR() override;
private:
- uint8_t *m_gpregset;
+ uint8_t *m_gpregset;
};
#endif // liblldb_RegisterContextCorePOSIX_x86_64_h_
Modified: lldb/trunk/source/Plugins/Process/elf-core/ThreadElfCore.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/elf-core/ThreadElfCore.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/elf-core/ThreadElfCore.cpp (original)
+++ lldb/trunk/source/Plugins/Process/elf-core/ThreadElfCore.cpp Tue Sep 6 15:57:50 2016
@@ -14,25 +14,25 @@
#include "lldb/Target/Target.h"
#include "lldb/Target/Unwind.h"
-#include "ThreadElfCore.h"
-#include "ProcessElfCore.h"
-#include "Plugins/Process/Utility/RegisterContextLinux_arm.h"
-#include "Plugins/Process/Utility/RegisterContextLinux_arm64.h"
-#include "Plugins/Process/Utility/RegisterContextLinux_s390x.h"
-#include "Plugins/Process/Utility/RegisterContextLinux_i386.h"
-#include "Plugins/Process/Utility/RegisterContextLinux_x86_64.h"
#include "Plugins/Process/Utility/RegisterContextFreeBSD_arm.h"
#include "Plugins/Process/Utility/RegisterContextFreeBSD_arm64.h"
#include "Plugins/Process/Utility/RegisterContextFreeBSD_i386.h"
#include "Plugins/Process/Utility/RegisterContextFreeBSD_mips64.h"
#include "Plugins/Process/Utility/RegisterContextFreeBSD_powerpc.h"
#include "Plugins/Process/Utility/RegisterContextFreeBSD_x86_64.h"
+#include "Plugins/Process/Utility/RegisterContextLinux_arm.h"
+#include "Plugins/Process/Utility/RegisterContextLinux_arm64.h"
+#include "Plugins/Process/Utility/RegisterContextLinux_i386.h"
+#include "Plugins/Process/Utility/RegisterContextLinux_s390x.h"
+#include "Plugins/Process/Utility/RegisterContextLinux_x86_64.h"
+#include "ProcessElfCore.h"
#include "RegisterContextPOSIXCore_arm.h"
#include "RegisterContextPOSIXCore_arm64.h"
#include "RegisterContextPOSIXCore_mips64.h"
#include "RegisterContextPOSIXCore_powerpc.h"
#include "RegisterContextPOSIXCore_s390x.h"
#include "RegisterContextPOSIXCore_x86_64.h"
+#include "ThreadElfCore.h"
using namespace lldb;
using namespace lldb_private;
@@ -40,313 +40,283 @@ using namespace lldb_private;
//----------------------------------------------------------------------
// Construct a Thread object with given data
//----------------------------------------------------------------------
-ThreadElfCore::ThreadElfCore (Process &process, const ThreadData &td) :
- Thread(process, td.tid),
- m_thread_name(td.name),
- m_thread_reg_ctx_sp (),
- m_signo(td.signo),
- m_gpregset_data(td.gpregset),
- m_fpregset_data(td.fpregset),
- m_vregset_data(td.vregset)
-{
-}
+ThreadElfCore::ThreadElfCore(Process &process, const ThreadData &td)
+ : Thread(process, td.tid), m_thread_name(td.name), m_thread_reg_ctx_sp(),
+ m_signo(td.signo), m_gpregset_data(td.gpregset),
+ m_fpregset_data(td.fpregset), m_vregset_data(td.vregset) {}
-ThreadElfCore::~ThreadElfCore ()
-{
- DestroyThread();
+ThreadElfCore::~ThreadElfCore() { DestroyThread(); }
+
+void ThreadElfCore::RefreshStateAfterStop() {
+ GetRegisterContext()->InvalidateIfNeeded(false);
}
-void
-ThreadElfCore::RefreshStateAfterStop()
-{
- GetRegisterContext()->InvalidateIfNeeded (false);
+void ThreadElfCore::ClearStackFrames() {
+ Unwind *unwinder = GetUnwinder();
+ if (unwinder)
+ unwinder->Clear();
+ Thread::ClearStackFrames();
}
-void
-ThreadElfCore::ClearStackFrames ()
-{
- Unwind *unwinder = GetUnwinder ();
- if (unwinder)
- unwinder->Clear();
- Thread::ClearStackFrames();
+RegisterContextSP ThreadElfCore::GetRegisterContext() {
+ if (m_reg_context_sp.get() == NULL) {
+ m_reg_context_sp = CreateRegisterContextForFrame(NULL);
+ }
+ return m_reg_context_sp;
}
RegisterContextSP
-ThreadElfCore::GetRegisterContext ()
-{
- if (m_reg_context_sp.get() == NULL) {
- m_reg_context_sp = CreateRegisterContextForFrame (NULL);
+ThreadElfCore::CreateRegisterContextForFrame(StackFrame *frame) {
+ RegisterContextSP reg_ctx_sp;
+ uint32_t concrete_frame_idx = 0;
+ Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_THREAD));
+
+ if (frame)
+ concrete_frame_idx = frame->GetConcreteFrameIndex();
+
+ if (concrete_frame_idx == 0) {
+ if (m_thread_reg_ctx_sp)
+ return m_thread_reg_ctx_sp;
+
+ ProcessElfCore *process = static_cast<ProcessElfCore *>(GetProcess().get());
+ ArchSpec arch = process->GetArchitecture();
+ RegisterInfoInterface *reg_interface = NULL;
+
+ switch (arch.GetTriple().getOS()) {
+ case llvm::Triple::FreeBSD: {
+ switch (arch.GetMachine()) {
+ case llvm::Triple::aarch64:
+ reg_interface = new RegisterContextFreeBSD_arm64(arch);
+ break;
+ case llvm::Triple::arm:
+ reg_interface = new RegisterContextFreeBSD_arm(arch);
+ break;
+ case llvm::Triple::ppc:
+ reg_interface = new RegisterContextFreeBSD_powerpc32(arch);
+ break;
+ case llvm::Triple::ppc64:
+ reg_interface = new RegisterContextFreeBSD_powerpc64(arch);
+ break;
+ case llvm::Triple::mips64:
+ reg_interface = new RegisterContextFreeBSD_mips64(arch);
+ break;
+ case llvm::Triple::x86:
+ reg_interface = new RegisterContextFreeBSD_i386(arch);
+ break;
+ case llvm::Triple::x86_64:
+ reg_interface = new RegisterContextFreeBSD_x86_64(arch);
+ break;
+ default:
+ break;
+ }
+ break;
}
- return m_reg_context_sp;
-}
-RegisterContextSP
-ThreadElfCore::CreateRegisterContextForFrame (StackFrame *frame)
-{
- RegisterContextSP reg_ctx_sp;
- uint32_t concrete_frame_idx = 0;
- Log *log (GetLogIfAllCategoriesSet(LIBLLDB_LOG_THREAD));
-
- if (frame)
- concrete_frame_idx = frame->GetConcreteFrameIndex ();
-
- if (concrete_frame_idx == 0)
- {
- if (m_thread_reg_ctx_sp)
- return m_thread_reg_ctx_sp;
-
- ProcessElfCore *process = static_cast<ProcessElfCore *>(GetProcess().get());
- ArchSpec arch = process->GetArchitecture();
- RegisterInfoInterface *reg_interface = NULL;
-
- switch (arch.GetTriple().getOS())
- {
- case llvm::Triple::FreeBSD:
- {
- switch (arch.GetMachine())
- {
- case llvm::Triple::aarch64:
- reg_interface = new RegisterContextFreeBSD_arm64(arch);
- break;
- case llvm::Triple::arm:
- reg_interface = new RegisterContextFreeBSD_arm(arch);
- break;
- case llvm::Triple::ppc:
- reg_interface = new RegisterContextFreeBSD_powerpc32(arch);
- break;
- case llvm::Triple::ppc64:
- reg_interface = new RegisterContextFreeBSD_powerpc64(arch);
- break;
- case llvm::Triple::mips64:
- reg_interface = new RegisterContextFreeBSD_mips64(arch);
- break;
- case llvm::Triple::x86:
- reg_interface = new RegisterContextFreeBSD_i386(arch);
- break;
- case llvm::Triple::x86_64:
- reg_interface = new RegisterContextFreeBSD_x86_64(arch);
- break;
- default:
- break;
- }
- break;
- }
-
- case llvm::Triple::Linux:
- {
- switch (arch.GetMachine())
- {
- case llvm::Triple::arm:
- reg_interface = new RegisterContextLinux_arm(arch);
- break;
- case llvm::Triple::aarch64:
- reg_interface = new RegisterContextLinux_arm64(arch);
- break;
- case llvm::Triple::systemz:
- reg_interface = new RegisterContextLinux_s390x(arch);
- break;
- case llvm::Triple::x86:
- reg_interface = new RegisterContextLinux_i386(arch);
- break;
- case llvm::Triple::x86_64:
- reg_interface = new RegisterContextLinux_x86_64(arch);
- break;
- default:
- break;
- }
- break;
- }
-
- default:
- break;
- }
-
- if (!reg_interface) {
- if (log)
- log->Printf ("elf-core::%s:: Architecture(%d) or OS(%d) not supported",
- __FUNCTION__, arch.GetMachine(), arch.GetTriple().getOS());
- assert (false && "Architecture or OS not supported");
- }
-
- switch (arch.GetMachine())
- {
- case llvm::Triple::aarch64:
- m_thread_reg_ctx_sp.reset(new RegisterContextCorePOSIX_arm64 (*this, reg_interface, m_gpregset_data, m_fpregset_data));
- break;
- case llvm::Triple::arm:
- m_thread_reg_ctx_sp.reset(new RegisterContextCorePOSIX_arm (*this, reg_interface, m_gpregset_data, m_fpregset_data));
- break;
- case llvm::Triple::mips64:
- m_thread_reg_ctx_sp.reset(new RegisterContextCorePOSIX_mips64 (*this, reg_interface, m_gpregset_data, m_fpregset_data));
- break;
- case llvm::Triple::ppc:
- case llvm::Triple::ppc64:
- m_thread_reg_ctx_sp.reset(new RegisterContextCorePOSIX_powerpc (*this, reg_interface, m_gpregset_data, m_fpregset_data, m_vregset_data));
- break;
- case llvm::Triple::systemz:
- m_thread_reg_ctx_sp.reset(new RegisterContextCorePOSIX_s390x (*this, reg_interface, m_gpregset_data, m_fpregset_data));
- break;
- case llvm::Triple::x86:
- case llvm::Triple::x86_64:
- m_thread_reg_ctx_sp.reset(new RegisterContextCorePOSIX_x86_64 (*this, reg_interface, m_gpregset_data, m_fpregset_data));
- break;
- default:
- break;
- }
+ case llvm::Triple::Linux: {
+ switch (arch.GetMachine()) {
+ case llvm::Triple::arm:
+ reg_interface = new RegisterContextLinux_arm(arch);
+ break;
+ case llvm::Triple::aarch64:
+ reg_interface = new RegisterContextLinux_arm64(arch);
+ break;
+ case llvm::Triple::systemz:
+ reg_interface = new RegisterContextLinux_s390x(arch);
+ break;
+ case llvm::Triple::x86:
+ reg_interface = new RegisterContextLinux_i386(arch);
+ break;
+ case llvm::Triple::x86_64:
+ reg_interface = new RegisterContextLinux_x86_64(arch);
+ break;
+ default:
+ break;
+ }
+ break;
+ }
- reg_ctx_sp = m_thread_reg_ctx_sp;
+ default:
+ break;
}
- else if (m_unwinder_ap.get())
- {
- reg_ctx_sp = m_unwinder_ap->CreateRegisterContextForFrame (frame);
+
+ if (!reg_interface) {
+ if (log)
+ log->Printf("elf-core::%s:: Architecture(%d) or OS(%d) not supported",
+ __FUNCTION__, arch.GetMachine(), arch.GetTriple().getOS());
+ assert(false && "Architecture or OS not supported");
}
- return reg_ctx_sp;
-}
-bool
-ThreadElfCore::CalculateStopInfo ()
-{
- ProcessSP process_sp (GetProcess());
- if (process_sp)
- {
- SetStopInfo(StopInfo::CreateStopReasonWithSignal (*this, m_signo));
- return true;
+ switch (arch.GetMachine()) {
+ case llvm::Triple::aarch64:
+ m_thread_reg_ctx_sp.reset(new RegisterContextCorePOSIX_arm64(
+ *this, reg_interface, m_gpregset_data, m_fpregset_data));
+ break;
+ case llvm::Triple::arm:
+ m_thread_reg_ctx_sp.reset(new RegisterContextCorePOSIX_arm(
+ *this, reg_interface, m_gpregset_data, m_fpregset_data));
+ break;
+ case llvm::Triple::mips64:
+ m_thread_reg_ctx_sp.reset(new RegisterContextCorePOSIX_mips64(
+ *this, reg_interface, m_gpregset_data, m_fpregset_data));
+ break;
+ case llvm::Triple::ppc:
+ case llvm::Triple::ppc64:
+ m_thread_reg_ctx_sp.reset(new RegisterContextCorePOSIX_powerpc(
+ *this, reg_interface, m_gpregset_data, m_fpregset_data,
+ m_vregset_data));
+ break;
+ case llvm::Triple::systemz:
+ m_thread_reg_ctx_sp.reset(new RegisterContextCorePOSIX_s390x(
+ *this, reg_interface, m_gpregset_data, m_fpregset_data));
+ break;
+ case llvm::Triple::x86:
+ case llvm::Triple::x86_64:
+ m_thread_reg_ctx_sp.reset(new RegisterContextCorePOSIX_x86_64(
+ *this, reg_interface, m_gpregset_data, m_fpregset_data));
+ break;
+ default:
+ break;
}
- return false;
+
+ reg_ctx_sp = m_thread_reg_ctx_sp;
+ } else if (m_unwinder_ap.get()) {
+ reg_ctx_sp = m_unwinder_ap->CreateRegisterContextForFrame(frame);
+ }
+ return reg_ctx_sp;
+}
+
+bool ThreadElfCore::CalculateStopInfo() {
+ ProcessSP process_sp(GetProcess());
+ if (process_sp) {
+ SetStopInfo(StopInfo::CreateStopReasonWithSignal(*this, m_signo));
+ return true;
+ }
+ return false;
}
//----------------------------------------------------------------
// Parse PRSTATUS from NOTE entry
//----------------------------------------------------------------
-ELFLinuxPrStatus::ELFLinuxPrStatus()
-{
- memset(this, 0, sizeof(ELFLinuxPrStatus));
+ELFLinuxPrStatus::ELFLinuxPrStatus() {
+ memset(this, 0, sizeof(ELFLinuxPrStatus));
}
-Error
-ELFLinuxPrStatus::Parse(DataExtractor &data, ArchSpec &arch)
-{
- Error error;
- ByteOrder byteorder = data.GetByteOrder();
- if (GetSize(arch) > data.GetByteSize())
- {
- error.SetErrorStringWithFormat("NT_PRSTATUS size should be %lu, but the remaining bytes are: %" PRIu64,
- GetSize(arch), data.GetByteSize());
- return error;
- }
+Error ELFLinuxPrStatus::Parse(DataExtractor &data, ArchSpec &arch) {
+ Error error;
+ ByteOrder byteorder = data.GetByteOrder();
+ if (GetSize(arch) > data.GetByteSize()) {
+ error.SetErrorStringWithFormat(
+ "NT_PRSTATUS size should be %lu, but the remaining bytes are: %" PRIu64,
+ GetSize(arch), data.GetByteSize());
+ return error;
+ }
- switch(arch.GetCore())
- {
- case ArchSpec::eCore_s390x_generic:
- case ArchSpec::eCore_x86_64_x86_64:
- data.ExtractBytes(0, sizeof(ELFLinuxPrStatus), byteorder, this);
- break;
- case ArchSpec::eCore_x86_32_i386:
- case ArchSpec::eCore_x86_32_i486:
- {
- // Parsing from a 32 bit ELF core file, and populating/reusing the structure
- // properly, because the struct is for the 64 bit version
- offset_t offset = 0;
- si_signo = data.GetU32(&offset);
- si_code = data.GetU32(&offset);
- si_errno = data.GetU32(&offset);
-
- pr_cursig = data.GetU16(&offset);
- offset += 2; // pad
-
- pr_sigpend = data.GetU32(&offset);
- pr_sighold = data.GetU32(&offset);
-
- pr_pid = data.GetU32(&offset);
- pr_ppid = data.GetU32(&offset);
- pr_pgrp = data.GetU32(&offset);
- pr_sid = data.GetU32(&offset);
-
- pr_utime.tv_sec = data.GetU32(&offset);
- pr_utime.tv_usec = data.GetU32(&offset);
-
- pr_stime.tv_sec = data.GetU32(&offset);
- pr_stime.tv_usec = data.GetU32(&offset);
-
- pr_cutime.tv_sec = data.GetU32(&offset);
- pr_cutime.tv_usec = data.GetU32(&offset);
-
- pr_cstime.tv_sec = data.GetU32(&offset);
- pr_cstime.tv_usec = data.GetU32(&offset);
-
- break;
- }
- default:
- error.SetErrorStringWithFormat("ELFLinuxPrStatus::%s Unknown architecture", __FUNCTION__);
- break;
- }
+ switch (arch.GetCore()) {
+ case ArchSpec::eCore_s390x_generic:
+ case ArchSpec::eCore_x86_64_x86_64:
+ data.ExtractBytes(0, sizeof(ELFLinuxPrStatus), byteorder, this);
+ break;
+ case ArchSpec::eCore_x86_32_i386:
+ case ArchSpec::eCore_x86_32_i486: {
+ // Parsing from a 32 bit ELF core file, and populating/reusing the structure
+ // properly, because the struct is for the 64 bit version
+ offset_t offset = 0;
+ si_signo = data.GetU32(&offset);
+ si_code = data.GetU32(&offset);
+ si_errno = data.GetU32(&offset);
+
+ pr_cursig = data.GetU16(&offset);
+ offset += 2; // pad
+
+ pr_sigpend = data.GetU32(&offset);
+ pr_sighold = data.GetU32(&offset);
+
+ pr_pid = data.GetU32(&offset);
+ pr_ppid = data.GetU32(&offset);
+ pr_pgrp = data.GetU32(&offset);
+ pr_sid = data.GetU32(&offset);
+
+ pr_utime.tv_sec = data.GetU32(&offset);
+ pr_utime.tv_usec = data.GetU32(&offset);
+
+ pr_stime.tv_sec = data.GetU32(&offset);
+ pr_stime.tv_usec = data.GetU32(&offset);
+
+ pr_cutime.tv_sec = data.GetU32(&offset);
+ pr_cutime.tv_usec = data.GetU32(&offset);
+
+ pr_cstime.tv_sec = data.GetU32(&offset);
+ pr_cstime.tv_usec = data.GetU32(&offset);
+
+ break;
+ }
+ default:
+ error.SetErrorStringWithFormat("ELFLinuxPrStatus::%s Unknown architecture",
+ __FUNCTION__);
+ break;
+ }
- return error;
+ return error;
}
//----------------------------------------------------------------
// Parse PRPSINFO from NOTE entry
//----------------------------------------------------------------
-ELFLinuxPrPsInfo::ELFLinuxPrPsInfo()
-{
- memset(this, 0, sizeof(ELFLinuxPrPsInfo));
+ELFLinuxPrPsInfo::ELFLinuxPrPsInfo() {
+ memset(this, 0, sizeof(ELFLinuxPrPsInfo));
}
-Error
-ELFLinuxPrPsInfo::Parse(DataExtractor &data, ArchSpec &arch)
-{
- Error error;
- ByteOrder byteorder = data.GetByteOrder();
- if (GetSize(arch) > data.GetByteSize())
- {
- error.SetErrorStringWithFormat("NT_PRPSINFO size should be %lu, but the remaining bytes are: %" PRIu64,
- GetSize(arch), data.GetByteSize());
- return error;
- }
+Error ELFLinuxPrPsInfo::Parse(DataExtractor &data, ArchSpec &arch) {
+ Error error;
+ ByteOrder byteorder = data.GetByteOrder();
+ if (GetSize(arch) > data.GetByteSize()) {
+ error.SetErrorStringWithFormat(
+ "NT_PRPSINFO size should be %lu, but the remaining bytes are: %" PRIu64,
+ GetSize(arch), data.GetByteSize());
+ return error;
+ }
- switch(arch.GetCore())
- {
- case ArchSpec::eCore_s390x_generic:
- case ArchSpec::eCore_x86_64_x86_64:
- data.ExtractBytes(0, sizeof(ELFLinuxPrPsInfo), byteorder, this);
- break;
- case ArchSpec::eCore_x86_32_i386:
- case ArchSpec::eCore_x86_32_i486:
- {
- // Parsing from a 32 bit ELF core file, and populating/reusing the structure
- // properly, because the struct is for the 64 bit version
- size_t size = 0;
- offset_t offset = 0;
-
- pr_state = data.GetU8(&offset);
- pr_sname = data.GetU8(&offset);
- pr_zomb = data.GetU8(&offset);
- pr_nice = data.GetU8(&offset);
-
- pr_flag = data.GetU32(&offset);
- pr_uid = data.GetU16(&offset);
- pr_gid = data.GetU16(&offset);
-
- pr_pid = data.GetU32(&offset);
- pr_ppid = data.GetU32(&offset);
- pr_pgrp = data.GetU32(&offset);
- pr_sid = data.GetU32(&offset);
-
- size = 16;
- data.ExtractBytes(offset, size, byteorder, pr_fname);
- offset += size;
-
- size = 80;
- data.ExtractBytes(offset, size, byteorder, pr_psargs);
- offset += size;
-
- break;
- }
- default:
- error.SetErrorStringWithFormat("ELFLinuxPrPsInfo::%s Unknown architecture", __FUNCTION__);
- break;
- }
+ switch (arch.GetCore()) {
+ case ArchSpec::eCore_s390x_generic:
+ case ArchSpec::eCore_x86_64_x86_64:
+ data.ExtractBytes(0, sizeof(ELFLinuxPrPsInfo), byteorder, this);
+ break;
+ case ArchSpec::eCore_x86_32_i386:
+ case ArchSpec::eCore_x86_32_i486: {
+ // Parsing from a 32 bit ELF core file, and populating/reusing the structure
+ // properly, because the struct is for the 64 bit version
+ size_t size = 0;
+ offset_t offset = 0;
+
+ pr_state = data.GetU8(&offset);
+ pr_sname = data.GetU8(&offset);
+ pr_zomb = data.GetU8(&offset);
+ pr_nice = data.GetU8(&offset);
+
+ pr_flag = data.GetU32(&offset);
+ pr_uid = data.GetU16(&offset);
+ pr_gid = data.GetU16(&offset);
+
+ pr_pid = data.GetU32(&offset);
+ pr_ppid = data.GetU32(&offset);
+ pr_pgrp = data.GetU32(&offset);
+ pr_sid = data.GetU32(&offset);
+
+ size = 16;
+ data.ExtractBytes(offset, size, byteorder, pr_fname);
+ offset += size;
+
+ size = 80;
+ data.ExtractBytes(offset, size, byteorder, pr_psargs);
+ offset += size;
+
+ break;
+ }
+ default:
+ error.SetErrorStringWithFormat("ELFLinuxPrPsInfo::%s Unknown architecture",
+ __FUNCTION__);
+ break;
+ }
- return error;
+ return error;
}
-
Modified: lldb/trunk/source/Plugins/Process/elf-core/ThreadElfCore.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/elf-core/ThreadElfCore.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/elf-core/ThreadElfCore.h (original)
+++ lldb/trunk/source/Plugins/Process/elf-core/ThreadElfCore.h Tue Sep 6 15:57:50 2016
@@ -16,188 +16,171 @@
// Other libraries and framework includes
// Project includes
-#include "lldb/Target/Thread.h"
#include "lldb/Core/DataExtractor.h"
+#include "lldb/Target/Thread.h"
-struct compat_timeval
-{
- alignas(8) uint64_t tv_sec;
- alignas(8) uint64_t tv_usec;
+struct compat_timeval {
+ alignas(8) uint64_t tv_sec;
+ alignas(8) uint64_t tv_usec;
};
// PRSTATUS structure's size differs based on architecture.
// This is the layout in the x86-64 arch.
// In the i386 case we parse it manually and fill it again
// in the same structure
-// The gp registers are also a part of this struct, but they are handled separately
+// The gp registers are also a part of this struct, but they are handled
+// separately
#undef si_signo
#undef si_code
#undef si_errno
-struct ELFLinuxPrStatus
-{
- int32_t si_signo;
- int32_t si_code;
- int32_t si_errno;
-
- int16_t pr_cursig;
-
- alignas(8) uint64_t pr_sigpend;
- alignas(8) uint64_t pr_sighold;
-
- uint32_t pr_pid;
- uint32_t pr_ppid;
- uint32_t pr_pgrp;
- uint32_t pr_sid;
-
- compat_timeval pr_utime;
- compat_timeval pr_stime;
- compat_timeval pr_cutime;
- compat_timeval pr_cstime;
-
- ELFLinuxPrStatus();
-
- lldb_private::Error
- Parse(lldb_private::DataExtractor &data, lldb_private::ArchSpec &arch);
-
- // Return the bytesize of the structure
- // 64 bit - just sizeof
- // 32 bit - hardcoded because we are reusing the struct, but some of the members are smaller -
- // so the layout is not the same
- static size_t
- GetSize(lldb_private::ArchSpec &arch)
- {
- switch(arch.GetCore())
- {
- case lldb_private::ArchSpec::eCore_s390x_generic:
- case lldb_private::ArchSpec::eCore_x86_64_x86_64:
- return sizeof(ELFLinuxPrStatus);
- case lldb_private::ArchSpec::eCore_x86_32_i386:
- case lldb_private::ArchSpec::eCore_x86_32_i486:
- return 72;
- default:
- return 0;
- }
+struct ELFLinuxPrStatus {
+ int32_t si_signo;
+ int32_t si_code;
+ int32_t si_errno;
+
+ int16_t pr_cursig;
+
+ alignas(8) uint64_t pr_sigpend;
+ alignas(8) uint64_t pr_sighold;
+
+ uint32_t pr_pid;
+ uint32_t pr_ppid;
+ uint32_t pr_pgrp;
+ uint32_t pr_sid;
+
+ compat_timeval pr_utime;
+ compat_timeval pr_stime;
+ compat_timeval pr_cutime;
+ compat_timeval pr_cstime;
+
+ ELFLinuxPrStatus();
+
+ lldb_private::Error Parse(lldb_private::DataExtractor &data,
+ lldb_private::ArchSpec &arch);
+
+ // Return the bytesize of the structure
+ // 64 bit - just sizeof
+ // 32 bit - hardcoded because we are reusing the struct, but some of the
+ // members are smaller -
+ // so the layout is not the same
+ static size_t GetSize(lldb_private::ArchSpec &arch) {
+ switch (arch.GetCore()) {
+ case lldb_private::ArchSpec::eCore_s390x_generic:
+ case lldb_private::ArchSpec::eCore_x86_64_x86_64:
+ return sizeof(ELFLinuxPrStatus);
+ case lldb_private::ArchSpec::eCore_x86_32_i386:
+ case lldb_private::ArchSpec::eCore_x86_32_i486:
+ return 72;
+ default:
+ return 0;
}
+ }
};
-static_assert(sizeof(ELFLinuxPrStatus) == 112, "sizeof ELFLinuxPrStatus is not correct!");
+static_assert(sizeof(ELFLinuxPrStatus) == 112,
+ "sizeof ELFLinuxPrStatus is not correct!");
// PRPSINFO structure's size differs based on architecture.
// This is the layout in the x86-64 arch case.
// In the i386 case we parse it manually and fill it again
// in the same structure
-struct ELFLinuxPrPsInfo
-{
- char pr_state;
- char pr_sname;
- char pr_zomb;
- char pr_nice;
- alignas(8) uint64_t pr_flag;
- uint32_t pr_uid;
- uint32_t pr_gid;
- int32_t pr_pid;
- int32_t pr_ppid;
- int32_t pr_pgrp;
- int32_t pr_sid;
- char pr_fname[16];
- char pr_psargs[80];
-
- ELFLinuxPrPsInfo();
-
- lldb_private::Error
- Parse(lldb_private::DataExtractor &data, lldb_private::ArchSpec &arch);
-
- // Return the bytesize of the structure
- // 64 bit - just sizeof
- // 32 bit - hardcoded because we are reusing the struct, but some of the members are smaller -
- // so the layout is not the same
- static size_t
- GetSize(lldb_private::ArchSpec &arch)
- {
- switch(arch.GetCore())
- {
- case lldb_private::ArchSpec::eCore_s390x_generic:
- case lldb_private::ArchSpec::eCore_x86_64_x86_64:
- return sizeof(ELFLinuxPrPsInfo);
- case lldb_private::ArchSpec::eCore_x86_32_i386:
- case lldb_private::ArchSpec::eCore_x86_32_i486:
- return 124;
- default:
- return 0;
- }
+struct ELFLinuxPrPsInfo {
+ char pr_state;
+ char pr_sname;
+ char pr_zomb;
+ char pr_nice;
+ alignas(8) uint64_t pr_flag;
+ uint32_t pr_uid;
+ uint32_t pr_gid;
+ int32_t pr_pid;
+ int32_t pr_ppid;
+ int32_t pr_pgrp;
+ int32_t pr_sid;
+ char pr_fname[16];
+ char pr_psargs[80];
+
+ ELFLinuxPrPsInfo();
+
+ lldb_private::Error Parse(lldb_private::DataExtractor &data,
+ lldb_private::ArchSpec &arch);
+
+ // Return the bytesize of the structure
+ // 64 bit - just sizeof
+ // 32 bit - hardcoded because we are reusing the struct, but some of the
+ // members are smaller -
+ // so the layout is not the same
+ static size_t GetSize(lldb_private::ArchSpec &arch) {
+ switch (arch.GetCore()) {
+ case lldb_private::ArchSpec::eCore_s390x_generic:
+ case lldb_private::ArchSpec::eCore_x86_64_x86_64:
+ return sizeof(ELFLinuxPrPsInfo);
+ case lldb_private::ArchSpec::eCore_x86_32_i386:
+ case lldb_private::ArchSpec::eCore_x86_32_i486:
+ return 124;
+ default:
+ return 0;
}
+ }
};
-static_assert(sizeof(ELFLinuxPrPsInfo) == 136, "sizeof ELFLinuxPrPsInfo is not correct!");
+static_assert(sizeof(ELFLinuxPrPsInfo) == 136,
+ "sizeof ELFLinuxPrPsInfo is not correct!");
-struct ThreadData
-{
- lldb_private::DataExtractor gpregset;
- lldb_private::DataExtractor fpregset;
- lldb_private::DataExtractor vregset;
- lldb::tid_t tid;
- int signo;
- std::string name;
+struct ThreadData {
+ lldb_private::DataExtractor gpregset;
+ lldb_private::DataExtractor fpregset;
+ lldb_private::DataExtractor vregset;
+ lldb::tid_t tid;
+ int signo;
+ std::string name;
};
-class ThreadElfCore : public lldb_private::Thread
-{
+class ThreadElfCore : public lldb_private::Thread {
public:
- ThreadElfCore (lldb_private::Process &process, const ThreadData &td);
+ ThreadElfCore(lldb_private::Process &process, const ThreadData &td);
- ~ThreadElfCore() override;
+ ~ThreadElfCore() override;
- void
- RefreshStateAfterStop() override;
+ void RefreshStateAfterStop() override;
- lldb::RegisterContextSP
- GetRegisterContext() override;
+ lldb::RegisterContextSP GetRegisterContext() override;
- lldb::RegisterContextSP
- CreateRegisterContextForFrame(lldb_private::StackFrame *frame) override;
+ lldb::RegisterContextSP
+ CreateRegisterContextForFrame(lldb_private::StackFrame *frame) override;
- void
- ClearStackFrames() override;
+ void ClearStackFrames() override;
- static bool
- ThreadIDIsValid (lldb::tid_t thread)
- {
- return thread != 0;
- }
+ static bool ThreadIDIsValid(lldb::tid_t thread) { return thread != 0; }
- const char *
- GetName() override
- {
- if (m_thread_name.empty())
- return NULL;
- return m_thread_name.c_str();
- }
+ const char *GetName() override {
+ if (m_thread_name.empty())
+ return NULL;
+ return m_thread_name.c_str();
+ }
- void
- SetName(const char *name) override
- {
- if (name && name[0])
- m_thread_name.assign (name);
- else
- m_thread_name.clear();
- }
+ void SetName(const char *name) override {
+ if (name && name[0])
+ m_thread_name.assign(name);
+ else
+ m_thread_name.clear();
+ }
protected:
- //------------------------------------------------------------------
- // Member variables.
- //------------------------------------------------------------------
- std::string m_thread_name;
- lldb::RegisterContextSP m_thread_reg_ctx_sp;
-
- int m_signo;
-
- lldb_private::DataExtractor m_gpregset_data;
- lldb_private::DataExtractor m_fpregset_data;
- lldb_private::DataExtractor m_vregset_data;
+ //------------------------------------------------------------------
+ // Member variables.
+ //------------------------------------------------------------------
+ std::string m_thread_name;
+ lldb::RegisterContextSP m_thread_reg_ctx_sp;
+
+ int m_signo;
+
+ lldb_private::DataExtractor m_gpregset_data;
+ lldb_private::DataExtractor m_fpregset_data;
+ lldb_private::DataExtractor m_vregset_data;
- bool CalculateStopInfo() override;
+ bool CalculateStopInfo() override;
};
#endif // liblldb_ThreadElfCore_h_
Modified: lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteClientBase.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteClientBase.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteClientBase.cpp (original)
+++ lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteClientBase.cpp Tue Sep 6 15:57:50 2016
@@ -29,336 +29,333 @@ static const std::chrono::seconds kInter
GDBRemoteClientBase::ContinueDelegate::~ContinueDelegate() = default;
-GDBRemoteClientBase::GDBRemoteClientBase(const char *comm_name, const char *listener_name)
- : GDBRemoteCommunication(comm_name, listener_name), m_async_count(0), m_is_running(false), m_should_stop(false)
-{
-}
-
-StateType
-GDBRemoteClientBase::SendContinuePacketAndWaitForResponse(ContinueDelegate &delegate, const UnixSignals &signals,
- llvm::StringRef payload, StringExtractorGDBRemote &response)
-{
- Log *log(ProcessGDBRemoteLog::GetLogIfAllCategoriesSet(GDBR_LOG_PROCESS));
- response.Clear();
-
- {
- std::lock_guard<std::mutex> lock(m_mutex);
- m_continue_packet = payload;
- m_should_stop = false;
- }
- ContinueLock cont_lock(*this);
- if (!cont_lock)
+GDBRemoteClientBase::GDBRemoteClientBase(const char *comm_name,
+ const char *listener_name)
+ : GDBRemoteCommunication(comm_name, listener_name), m_async_count(0),
+ m_is_running(false), m_should_stop(false) {}
+
+StateType GDBRemoteClientBase::SendContinuePacketAndWaitForResponse(
+ ContinueDelegate &delegate, const UnixSignals &signals,
+ llvm::StringRef payload, StringExtractorGDBRemote &response) {
+ Log *log(ProcessGDBRemoteLog::GetLogIfAllCategoriesSet(GDBR_LOG_PROCESS));
+ response.Clear();
+
+ {
+ std::lock_guard<std::mutex> lock(m_mutex);
+ m_continue_packet = payload;
+ m_should_stop = false;
+ }
+ ContinueLock cont_lock(*this);
+ if (!cont_lock)
+ return eStateInvalid;
+ OnRunPacketSent(true);
+
+ for (;;) {
+ PacketResult read_result = ReadPacket(
+ response,
+ std::chrono::duration_cast<std::chrono::microseconds>(kInterruptTimeout)
+ .count(),
+ false);
+ switch (read_result) {
+ case PacketResult::ErrorReplyTimeout: {
+ std::lock_guard<std::mutex> lock(m_mutex);
+ if (m_async_count == 0)
+ continue;
+ if (std::chrono::steady_clock::now() >=
+ m_interrupt_time + kInterruptTimeout)
return eStateInvalid;
- OnRunPacketSent(true);
+ }
+ case PacketResult::Success:
+ break;
+ default:
+ if (log)
+ log->Printf("GDBRemoteClientBase::%s () ReadPacket(...) => false",
+ __FUNCTION__);
+ return eStateInvalid;
+ }
+ if (response.Empty())
+ return eStateInvalid;
+
+ const char stop_type = response.GetChar();
+ if (log)
+ log->Printf("GDBRemoteClientBase::%s () got packet: %s", __FUNCTION__,
+ response.GetStringRef().c_str());
- for (;;)
- {
- PacketResult read_result = ReadPacket(
- response, std::chrono::duration_cast<std::chrono::microseconds>(kInterruptTimeout).count(), false);
- switch (read_result)
- {
- case PacketResult::ErrorReplyTimeout:
- {
- std::lock_guard<std::mutex> lock(m_mutex);
- if (m_async_count == 0)
- continue;
- if (std::chrono::steady_clock::now() >= m_interrupt_time + kInterruptTimeout)
- return eStateInvalid;
- }
- case PacketResult::Success:
- break;
- default:
- if (log)
- log->Printf("GDBRemoteClientBase::%s () ReadPacket(...) => false", __FUNCTION__);
- return eStateInvalid;
+ switch (stop_type) {
+ case 'W':
+ case 'X':
+ return eStateExited;
+ case 'E':
+ // ERROR
+ return eStateInvalid;
+ default:
+ if (log)
+ log->Printf("GDBRemoteClientBase::%s () unrecognized async packet",
+ __FUNCTION__);
+ return eStateInvalid;
+ case 'O': {
+ std::string inferior_stdout;
+ response.GetHexByteString(inferior_stdout);
+ delegate.HandleAsyncStdout(inferior_stdout);
+ break;
+ }
+ case 'A':
+ delegate.HandleAsyncMisc(
+ llvm::StringRef(response.GetStringRef()).substr(1));
+ break;
+
+ case 'J':
+ // Asynchronous JSON packet, destined for a
+ // StructuredDataPlugin.
+ {
+ // Parse the content into a StructuredData instance.
+ auto payload_index = strlen("JSON-async:");
+ StructuredData::ObjectSP json_sp = StructuredData::ParseJSON(
+ response.GetStringRef().substr(payload_index));
+ if (log) {
+ if (json_sp)
+ log->Printf("GDBRemoteCommmunicationClientBase::%s() "
+ "received Async StructuredData packet: %s",
+ __FUNCTION__,
+ response.GetStringRef().substr(payload_index).c_str());
+ else
+ log->Printf("GDBRemoteCommmunicationClientBase::%s"
+ "() received StructuredData packet:"
+ " parse failure",
+ __FUNCTION__);
}
- if (response.Empty())
- return eStateInvalid;
- const char stop_type = response.GetChar();
+ // Pass the data to the process to route to the
+ // appropriate plugin. The plugin controls what happens
+ // to it from there.
+ bool routed = delegate.HandleAsyncStructuredData(json_sp);
if (log)
- log->Printf("GDBRemoteClientBase::%s () got packet: %s", __FUNCTION__, response.GetStringRef().c_str());
-
- switch (stop_type)
- {
- case 'W':
- case 'X':
- return eStateExited;
- case 'E':
- // ERROR
- return eStateInvalid;
- default:
- if (log)
- log->Printf("GDBRemoteClientBase::%s () unrecognized async packet", __FUNCTION__);
- return eStateInvalid;
- case 'O':
- {
- std::string inferior_stdout;
- response.GetHexByteString(inferior_stdout);
- delegate.HandleAsyncStdout(inferior_stdout);
- break;
- }
- case 'A':
- delegate.HandleAsyncMisc(llvm::StringRef(response.GetStringRef()).substr(1));
- break;
-
- case 'J':
- // Asynchronous JSON packet, destined for a
- // StructuredDataPlugin.
- {
- // Parse the content into a StructuredData instance.
- auto payload_index = strlen("JSON-async:");
- StructuredData::ObjectSP json_sp =
- StructuredData::ParseJSON(response.GetStringRef()
- .substr(payload_index));
- if (log)
- {
- if (json_sp)
- log->Printf(
- "GDBRemoteCommmunicationClientBase::%s() "
- "received Async StructuredData packet: %s",
- __FUNCTION__,
- response.GetStringRef().
- substr(payload_index).c_str());
- else
- log->Printf("GDBRemoteCommmunicationClientBase::%s"
- "() received StructuredData packet:"
- " parse failure", __FUNCTION__);
- }
-
- // Pass the data to the process to route to the
- // appropriate plugin. The plugin controls what happens
- // to it from there.
- bool routed = delegate.HandleAsyncStructuredData(json_sp);
- if (log)
- log->Printf("GDBRemoteCommmunicationClientBase::%s()"
- " packet %s", __FUNCTION__,
- routed ? "handled" : "not handled");
- break;
- }
- case 'T':
- case 'S':
- // Do this with the continue lock held.
- const bool should_stop = ShouldStop(signals, response);
- response.SetFilePos(0);
-
- // The packet we should resume with. In the future
- // we should check our thread list and "do the right thing"
- // for new threads that show up while we stop and run async
- // packets. Setting the packet to 'c' to continue all threads
- // is the right thing to do 99.99% of the time because if a
- // thread was single stepping, and we sent an interrupt, we
- // will notice above that we didn't stop due to an interrupt
- // but stopped due to stepping and we would _not_ continue.
- // This packet may get modified by the async actions (e.g. to send a signal).
- m_continue_packet = 'c';
- cont_lock.unlock();
-
- delegate.HandleStopReply();
- if (should_stop)
- return eStateStopped;
-
- switch (cont_lock.lock())
- {
- case ContinueLock::LockResult::Success:
- break;
- case ContinueLock::LockResult::Failed:
- return eStateInvalid;
- case ContinueLock::LockResult::Cancelled:
- return eStateStopped;
- }
- OnRunPacketSent(false);
- break;
- }
+ log->Printf("GDBRemoteCommmunicationClientBase::%s()"
+ " packet %s",
+ __FUNCTION__, routed ? "handled" : "not handled");
+ break;
+ }
+ case 'T':
+ case 'S':
+ // Do this with the continue lock held.
+ const bool should_stop = ShouldStop(signals, response);
+ response.SetFilePos(0);
+
+ // The packet we should resume with. In the future
+ // we should check our thread list and "do the right thing"
+ // for new threads that show up while we stop and run async
+ // packets. Setting the packet to 'c' to continue all threads
+ // is the right thing to do 99.99% of the time because if a
+ // thread was single stepping, and we sent an interrupt, we
+ // will notice above that we didn't stop due to an interrupt
+ // but stopped due to stepping and we would _not_ continue.
+ // This packet may get modified by the async actions (e.g. to send a
+ // signal).
+ m_continue_packet = 'c';
+ cont_lock.unlock();
+
+ delegate.HandleStopReply();
+ if (should_stop)
+ return eStateStopped;
+
+ switch (cont_lock.lock()) {
+ case ContinueLock::LockResult::Success:
+ break;
+ case ContinueLock::LockResult::Failed:
+ return eStateInvalid;
+ case ContinueLock::LockResult::Cancelled:
+ return eStateStopped;
+ }
+ OnRunPacketSent(false);
+ break;
}
+ }
}
-bool
-GDBRemoteClientBase::SendAsyncSignal(int signo)
-{
- Lock lock(*this, true);
- if (!lock || !lock.DidInterrupt())
- return false;
-
- m_continue_packet = 'C';
- m_continue_packet += llvm::hexdigit((signo / 16) % 16);
- m_continue_packet += llvm::hexdigit(signo % 16);
- return true;
+bool GDBRemoteClientBase::SendAsyncSignal(int signo) {
+ Lock lock(*this, true);
+ if (!lock || !lock.DidInterrupt())
+ return false;
+
+ m_continue_packet = 'C';
+ m_continue_packet += llvm::hexdigit((signo / 16) % 16);
+ m_continue_packet += llvm::hexdigit(signo % 16);
+ return true;
}
-bool
-GDBRemoteClientBase::Interrupt()
-{
- Lock lock(*this, true);
- if (!lock.DidInterrupt())
- return false;
- m_should_stop = true;
- return true;
+bool GDBRemoteClientBase::Interrupt() {
+ Lock lock(*this, true);
+ if (!lock.DidInterrupt())
+ return false;
+ m_should_stop = true;
+ return true;
}
GDBRemoteCommunication::PacketResult
-GDBRemoteClientBase::SendPacketAndWaitForResponse(llvm::StringRef payload, StringExtractorGDBRemote &response,
- bool send_async)
-{
- Lock lock(*this, send_async);
- if (!lock)
- {
- if (Log *log = ProcessGDBRemoteLog::GetLogIfAllCategoriesSet(GDBR_LOG_PROCESS))
- log->Printf("GDBRemoteClientBase::%s failed to get mutex, not sending packet '%.*s' (send_async=%d)",
- __FUNCTION__, int(payload.size()), payload.data(), send_async);
- return PacketResult::ErrorSendFailed;
- }
+GDBRemoteClientBase::SendPacketAndWaitForResponse(
+ llvm::StringRef payload, StringExtractorGDBRemote &response,
+ bool send_async) {
+ Lock lock(*this, send_async);
+ if (!lock) {
+ if (Log *log =
+ ProcessGDBRemoteLog::GetLogIfAllCategoriesSet(GDBR_LOG_PROCESS))
+ log->Printf("GDBRemoteClientBase::%s failed to get mutex, not sending "
+ "packet '%.*s' (send_async=%d)",
+ __FUNCTION__, int(payload.size()), payload.data(),
+ send_async);
+ return PacketResult::ErrorSendFailed;
+ }
- return SendPacketAndWaitForResponseNoLock(payload, response);
+ return SendPacketAndWaitForResponseNoLock(payload, response);
}
GDBRemoteCommunication::PacketResult
-GDBRemoteClientBase::SendPacketAndWaitForResponseNoLock(llvm::StringRef payload, StringExtractorGDBRemote &response)
-{
- PacketResult packet_result = SendPacketNoLock(payload);
- if (packet_result != PacketResult::Success)
- return packet_result;
-
- const size_t max_response_retries = 3;
- for (size_t i = 0; i < max_response_retries; ++i)
- {
- packet_result = ReadPacket(response, GetPacketTimeoutInMicroSeconds(), true);
- // Make sure we received a response
- if (packet_result != PacketResult::Success)
- return packet_result;
- // Make sure our response is valid for the payload that was sent
- if (response.ValidateResponse())
- return packet_result;
- // Response says it wasn't valid
- Log *log = ProcessGDBRemoteLog::GetLogIfAllCategoriesSet(GDBR_LOG_PACKETS);
- if (log)
- log->Printf("error: packet with payload \"%.*s\" got invalid response \"%s\": %s", int(payload.size()),
- payload.data(), response.GetStringRef().c_str(),
- (i == (max_response_retries - 1)) ? "using invalid response and giving up"
- : "ignoring response and waiting for another");
- }
+GDBRemoteClientBase::SendPacketAndWaitForResponseNoLock(
+ llvm::StringRef payload, StringExtractorGDBRemote &response) {
+ PacketResult packet_result = SendPacketNoLock(payload);
+ if (packet_result != PacketResult::Success)
return packet_result;
-}
-
-bool
-GDBRemoteClientBase::SendvContPacket(llvm::StringRef payload, StringExtractorGDBRemote &response)
-{
- Log *log(ProcessGDBRemoteLog::GetLogIfAllCategoriesSet(GDBR_LOG_PROCESS));
- if (log)
- log->Printf("GDBRemoteCommunicationClient::%s ()", __FUNCTION__);
-
- // we want to lock down packet sending while we continue
- Lock lock(*this, true);
+ const size_t max_response_retries = 3;
+ for (size_t i = 0; i < max_response_retries; ++i) {
+ packet_result =
+ ReadPacket(response, GetPacketTimeoutInMicroSeconds(), true);
+ // Make sure we received a response
+ if (packet_result != PacketResult::Success)
+ return packet_result;
+ // Make sure our response is valid for the payload that was sent
+ if (response.ValidateResponse())
+ return packet_result;
+ // Response says it wasn't valid
+ Log *log = ProcessGDBRemoteLog::GetLogIfAllCategoriesSet(GDBR_LOG_PACKETS);
if (log)
- log->Printf("GDBRemoteCommunicationClient::%s () sending vCont packet: %.*s", __FUNCTION__, int(payload.size()),
- payload.data());
-
- if (SendPacketNoLock(payload) != PacketResult::Success)
- return false;
-
- OnRunPacketSent(true);
-
- // wait for the response to the vCont
- if (ReadPacket(response, UINT32_MAX, false) == PacketResult::Success)
- {
- if (response.IsOKResponse())
- return true;
- }
+ log->Printf(
+ "error: packet with payload \"%.*s\" got invalid response \"%s\": %s",
+ int(payload.size()), payload.data(), response.GetStringRef().c_str(),
+ (i == (max_response_retries - 1))
+ ? "using invalid response and giving up"
+ : "ignoring response and waiting for another");
+ }
+ return packet_result;
+}
+
+bool GDBRemoteClientBase::SendvContPacket(llvm::StringRef payload,
+ StringExtractorGDBRemote &response) {
+ Log *log(ProcessGDBRemoteLog::GetLogIfAllCategoriesSet(GDBR_LOG_PROCESS));
+ if (log)
+ log->Printf("GDBRemoteCommunicationClient::%s ()", __FUNCTION__);
+
+ // we want to lock down packet sending while we continue
+ Lock lock(*this, true);
+
+ if (log)
+ log->Printf(
+ "GDBRemoteCommunicationClient::%s () sending vCont packet: %.*s",
+ __FUNCTION__, int(payload.size()), payload.data());
+ if (SendPacketNoLock(payload) != PacketResult::Success)
return false;
-}
-bool
-GDBRemoteClientBase::ShouldStop(const UnixSignals &signals, StringExtractorGDBRemote &response)
-{
- std::lock_guard<std::mutex> lock(m_mutex);
- if (m_async_count == 0)
- return true; // We were not interrupted. The process stopped on its own.
+ OnRunPacketSent(true);
- // Older debugserver stubs (before April 2016) can return two
- // stop-reply packets in response to a ^C packet.
- // Additionally, all debugservers still return two stop replies if
- // the inferior stops due to some other reason before the remote
- // stub manages to interrupt it. We need to wait for this
- // additional packet to make sure the packet sequence does not get
- // skewed.
- StringExtractorGDBRemote extra_stop_reply_packet;
- uint32_t timeout_usec = 100000; // 100ms
- ReadPacket(extra_stop_reply_packet, timeout_usec, false);
-
- // Interrupting is typically done using SIGSTOP or SIGINT, so if
- // the process stops with some other signal, we definitely want to
- // stop.
- const uint8_t signo = response.GetHexU8(UINT8_MAX);
- if (signo != signals.GetSignalNumberFromName("SIGSTOP") && signo != signals.GetSignalNumberFromName("SIGINT"))
- return true;
-
- // We probably only stopped to perform some async processing, so continue after that is done.
- // TODO: This is not 100% correct, as the process may have been stopped with SIGINT or SIGSTOP
- // that was not caused by us (e.g. raise(SIGINT)). This will normally cause a stop, but if it's
- // done concurrently with a async interrupt, that stop will get eaten (llvm.org/pr20231).
- return false;
+ // wait for the response to the vCont
+ if (ReadPacket(response, UINT32_MAX, false) == PacketResult::Success) {
+ if (response.IsOKResponse())
+ return true;
+ }
+
+ return false;
+}
+bool GDBRemoteClientBase::ShouldStop(const UnixSignals &signals,
+ StringExtractorGDBRemote &response) {
+ std::lock_guard<std::mutex> lock(m_mutex);
+
+ if (m_async_count == 0)
+ return true; // We were not interrupted. The process stopped on its own.
+
+ // Older debugserver stubs (before April 2016) can return two
+ // stop-reply packets in response to a ^C packet.
+ // Additionally, all debugservers still return two stop replies if
+ // the inferior stops due to some other reason before the remote
+ // stub manages to interrupt it. We need to wait for this
+ // additional packet to make sure the packet sequence does not get
+ // skewed.
+ StringExtractorGDBRemote extra_stop_reply_packet;
+ uint32_t timeout_usec = 100000; // 100ms
+ ReadPacket(extra_stop_reply_packet, timeout_usec, false);
+
+ // Interrupting is typically done using SIGSTOP or SIGINT, so if
+ // the process stops with some other signal, we definitely want to
+ // stop.
+ const uint8_t signo = response.GetHexU8(UINT8_MAX);
+ if (signo != signals.GetSignalNumberFromName("SIGSTOP") &&
+ signo != signals.GetSignalNumberFromName("SIGINT"))
+ return true;
+
+ // We probably only stopped to perform some async processing, so continue
+ // after that is done.
+ // TODO: This is not 100% correct, as the process may have been stopped with
+ // SIGINT or SIGSTOP
+ // that was not caused by us (e.g. raise(SIGINT)). This will normally cause a
+ // stop, but if it's
+ // done concurrently with a async interrupt, that stop will get eaten
+ // (llvm.org/pr20231).
+ return false;
}
-void
-GDBRemoteClientBase::OnRunPacketSent(bool first)
-{
- if (first)
- BroadcastEvent(eBroadcastBitRunPacketSent, NULL);
+void GDBRemoteClientBase::OnRunPacketSent(bool first) {
+ if (first)
+ BroadcastEvent(eBroadcastBitRunPacketSent, NULL);
}
///////////////////////////////////////
// GDBRemoteClientBase::ContinueLock //
///////////////////////////////////////
-GDBRemoteClientBase::ContinueLock::ContinueLock(GDBRemoteClientBase &comm) : m_comm(comm), m_acquired(false)
-{
- lock();
-}
-
-GDBRemoteClientBase::ContinueLock::~ContinueLock()
-{
- if (m_acquired)
- unlock();
-}
-
-void
-GDBRemoteClientBase::ContinueLock::unlock()
-{
- lldbassert(m_acquired);
- {
- std::unique_lock<std::mutex> lock(m_comm.m_mutex);
- m_comm.m_is_running = false;
- }
- m_comm.m_cv.notify_all();
- m_acquired = false;
+GDBRemoteClientBase::ContinueLock::ContinueLock(GDBRemoteClientBase &comm)
+ : m_comm(comm), m_acquired(false) {
+ lock();
}
-GDBRemoteClientBase::ContinueLock::LockResult
-GDBRemoteClientBase::ContinueLock::lock()
-{
- Log *log = ProcessGDBRemoteLog::GetLogIfAllCategoriesSet(GDBR_LOG_PROCESS);
- if (log)
- log->Printf("GDBRemoteClientBase::ContinueLock::%s() resuming with %s", __FUNCTION__,
- m_comm.m_continue_packet.c_str());
+GDBRemoteClientBase::ContinueLock::~ContinueLock() {
+ if (m_acquired)
+ unlock();
+}
- lldbassert(!m_acquired);
+void GDBRemoteClientBase::ContinueLock::unlock() {
+ lldbassert(m_acquired);
+ {
std::unique_lock<std::mutex> lock(m_comm.m_mutex);
- m_comm.m_cv.wait(lock, [this] { return m_comm.m_async_count == 0; });
- if (m_comm.m_should_stop)
- {
- m_comm.m_should_stop = false;
- if (log)
- log->Printf("GDBRemoteClientBase::ContinueLock::%s() cancelled", __FUNCTION__);
- return LockResult::Cancelled;
- }
- if (m_comm.SendPacketNoLock(m_comm.m_continue_packet) != PacketResult::Success)
- return LockResult::Failed;
+ m_comm.m_is_running = false;
+ }
+ m_comm.m_cv.notify_all();
+ m_acquired = false;
+}
- lldbassert(!m_comm.m_is_running);
- m_comm.m_is_running = true;
- m_acquired = true;
- return LockResult::Success;
+GDBRemoteClientBase::ContinueLock::LockResult
+GDBRemoteClientBase::ContinueLock::lock() {
+ Log *log = ProcessGDBRemoteLog::GetLogIfAllCategoriesSet(GDBR_LOG_PROCESS);
+ if (log)
+ log->Printf("GDBRemoteClientBase::ContinueLock::%s() resuming with %s",
+ __FUNCTION__, m_comm.m_continue_packet.c_str());
+
+ lldbassert(!m_acquired);
+ std::unique_lock<std::mutex> lock(m_comm.m_mutex);
+ m_comm.m_cv.wait(lock, [this] { return m_comm.m_async_count == 0; });
+ if (m_comm.m_should_stop) {
+ m_comm.m_should_stop = false;
+ if (log)
+ log->Printf("GDBRemoteClientBase::ContinueLock::%s() cancelled",
+ __FUNCTION__);
+ return LockResult::Cancelled;
+ }
+ if (m_comm.SendPacketNoLock(m_comm.m_continue_packet) !=
+ PacketResult::Success)
+ return LockResult::Failed;
+
+ lldbassert(!m_comm.m_is_running);
+ m_comm.m_is_running = true;
+ m_acquired = true;
+ return LockResult::Success;
}
///////////////////////////////
@@ -366,54 +363,51 @@ GDBRemoteClientBase::ContinueLock::lock(
///////////////////////////////
GDBRemoteClientBase::Lock::Lock(GDBRemoteClientBase &comm, bool interrupt)
- : m_async_lock(comm.m_async_mutex, std::defer_lock), m_comm(comm), m_acquired(false), m_did_interrupt(false)
-{
- SyncWithContinueThread(interrupt);
- if (m_acquired)
- m_async_lock.lock();
-}
-
-void
-GDBRemoteClientBase::Lock::SyncWithContinueThread(bool interrupt)
-{
- Log *log(ProcessGDBRemoteLog::GetLogIfAllCategoriesSet(GDBR_LOG_PROCESS));
- std::unique_lock<std::mutex> lock(m_comm.m_mutex);
- if (m_comm.m_is_running && !interrupt)
- return; // We were asked to avoid interrupting the sender. Lock is not acquired.
-
- ++m_comm.m_async_count;
- if (m_comm.m_is_running)
- {
- if (m_comm.m_async_count == 1)
- {
- // The sender has sent the continue packet and we are the first async packet. Let's interrupt it.
- const char ctrl_c = '\x03';
- ConnectionStatus status = eConnectionStatusSuccess;
- size_t bytes_written = m_comm.Write(&ctrl_c, 1, status, NULL);
- if (bytes_written == 0)
- {
- --m_comm.m_async_count;
- if (log)
- log->Printf("GDBRemoteClientBase::Lock::Lock failed to send interrupt packet");
- return;
- }
- if (log)
- log->PutCString("GDBRemoteClientBase::Lock::Lock sent packet: \\x03");
- m_comm.m_interrupt_time = std::chrono::steady_clock::now();
- }
- m_comm.m_cv.wait(lock, [this] { return m_comm.m_is_running == false; });
- m_did_interrupt = true;
+ : m_async_lock(comm.m_async_mutex, std::defer_lock), m_comm(comm),
+ m_acquired(false), m_did_interrupt(false) {
+ SyncWithContinueThread(interrupt);
+ if (m_acquired)
+ m_async_lock.lock();
+}
+
+void GDBRemoteClientBase::Lock::SyncWithContinueThread(bool interrupt) {
+ Log *log(ProcessGDBRemoteLog::GetLogIfAllCategoriesSet(GDBR_LOG_PROCESS));
+ std::unique_lock<std::mutex> lock(m_comm.m_mutex);
+ if (m_comm.m_is_running && !interrupt)
+ return; // We were asked to avoid interrupting the sender. Lock is not
+ // acquired.
+
+ ++m_comm.m_async_count;
+ if (m_comm.m_is_running) {
+ if (m_comm.m_async_count == 1) {
+ // The sender has sent the continue packet and we are the first async
+ // packet. Let's interrupt it.
+ const char ctrl_c = '\x03';
+ ConnectionStatus status = eConnectionStatusSuccess;
+ size_t bytes_written = m_comm.Write(&ctrl_c, 1, status, NULL);
+ if (bytes_written == 0) {
+ --m_comm.m_async_count;
+ if (log)
+ log->Printf("GDBRemoteClientBase::Lock::Lock failed to send "
+ "interrupt packet");
+ return;
+ }
+ if (log)
+ log->PutCString("GDBRemoteClientBase::Lock::Lock sent packet: \\x03");
+ m_comm.m_interrupt_time = std::chrono::steady_clock::now();
}
- m_acquired = true;
+ m_comm.m_cv.wait(lock, [this] { return m_comm.m_is_running == false; });
+ m_did_interrupt = true;
+ }
+ m_acquired = true;
}
-GDBRemoteClientBase::Lock::~Lock()
-{
- if (!m_acquired)
- return;
- {
- std::unique_lock<std::mutex> lock(m_comm.m_mutex);
- --m_comm.m_async_count;
- }
- m_comm.m_cv.notify_one();
+GDBRemoteClientBase::Lock::~Lock() {
+ if (!m_acquired)
+ return;
+ {
+ std::unique_lock<std::mutex> lock(m_comm.m_mutex);
+ --m_comm.m_async_count;
+ }
+ m_comm.m_cv.notify_one();
}
Modified: lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteClientBase.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteClientBase.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteClientBase.h (original)
+++ lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteClientBase.h Tue Sep 6 15:57:50 2016
@@ -14,147 +14,136 @@
#include <condition_variable>
-namespace lldb_private
-{
-namespace process_gdb_remote
-{
+namespace lldb_private {
+namespace process_gdb_remote {
-class GDBRemoteClientBase : public GDBRemoteCommunication
-{
+class GDBRemoteClientBase : public GDBRemoteCommunication {
public:
- struct ContinueDelegate
- {
- virtual ~ContinueDelegate();
- virtual void
- HandleAsyncStdout(llvm::StringRef out) = 0;
- virtual void
- HandleAsyncMisc(llvm::StringRef data) = 0;
- virtual void
- HandleStopReply() = 0;
-
- //
- /// Processes async structured data.
- ///
- /// @return
- /// true if the data was handled; otherwise, false.
- //
- virtual bool
- HandleAsyncStructuredData(const StructuredData::ObjectSP
- &object_sp) = 0;
- };
-
- GDBRemoteClientBase(const char *comm_name, const char *listener_name);
-
- bool
- SendAsyncSignal(int signo);
-
- bool
- Interrupt();
-
- lldb::StateType
- SendContinuePacketAndWaitForResponse(ContinueDelegate &delegate, const UnixSignals &signals,
- llvm::StringRef payload, StringExtractorGDBRemote &response);
-
- PacketResult
- SendPacketAndWaitForResponse(const char *payload, size_t len, StringExtractorGDBRemote &response, bool send_async)
- {
- return SendPacketAndWaitForResponse(llvm::StringRef(payload, len), response, send_async);
- }
-
- PacketResult
- SendPacketAndWaitForResponse(llvm::StringRef payload, StringExtractorGDBRemote &response, bool send_async);
-
- bool
- SendvContPacket(llvm::StringRef payload, StringExtractorGDBRemote &response);
-
- class Lock
- {
- public:
- Lock(GDBRemoteClientBase &comm, bool interrupt);
- ~Lock();
-
- explicit operator bool() { return m_acquired; }
-
- // Whether we had to interrupt the continue thread to acquire the connection.
- bool
- DidInterrupt() const
- {
- return m_did_interrupt;
- }
-
- private:
- std::unique_lock<std::recursive_mutex> m_async_lock;
- GDBRemoteClientBase &m_comm;
- bool m_acquired;
- bool m_did_interrupt;
-
- void
- SyncWithContinueThread(bool interrupt);
- };
+ struct ContinueDelegate {
+ virtual ~ContinueDelegate();
+ virtual void HandleAsyncStdout(llvm::StringRef out) = 0;
+ virtual void HandleAsyncMisc(llvm::StringRef data) = 0;
+ virtual void HandleStopReply() = 0;
+
+ //
+ /// Processes async structured data.
+ ///
+ /// @return
+ /// true if the data was handled; otherwise, false.
+ //
+ virtual bool
+ HandleAsyncStructuredData(const StructuredData::ObjectSP &object_sp) = 0;
+ };
+
+ GDBRemoteClientBase(const char *comm_name, const char *listener_name);
+
+ bool SendAsyncSignal(int signo);
+
+ bool Interrupt();
+
+ lldb::StateType SendContinuePacketAndWaitForResponse(
+ ContinueDelegate &delegate, const UnixSignals &signals,
+ llvm::StringRef payload, StringExtractorGDBRemote &response);
+
+ PacketResult SendPacketAndWaitForResponse(const char *payload, size_t len,
+ StringExtractorGDBRemote &response,
+ bool send_async) {
+ return SendPacketAndWaitForResponse(llvm::StringRef(payload, len), response,
+ send_async);
+ }
+
+ PacketResult SendPacketAndWaitForResponse(llvm::StringRef payload,
+ StringExtractorGDBRemote &response,
+ bool send_async);
+
+ bool SendvContPacket(llvm::StringRef payload,
+ StringExtractorGDBRemote &response);
+
+ class Lock {
+ public:
+ Lock(GDBRemoteClientBase &comm, bool interrupt);
+ ~Lock();
+
+ explicit operator bool() { return m_acquired; }
+
+ // Whether we had to interrupt the continue thread to acquire the
+ // connection.
+ bool DidInterrupt() const { return m_did_interrupt; }
+
+ private:
+ std::unique_lock<std::recursive_mutex> m_async_lock;
+ GDBRemoteClientBase &m_comm;
+ bool m_acquired;
+ bool m_did_interrupt;
+
+ void SyncWithContinueThread(bool interrupt);
+ };
protected:
- PacketResult
- SendPacketAndWaitForResponseNoLock(llvm::StringRef payload, StringExtractorGDBRemote &response);
+ PacketResult
+ SendPacketAndWaitForResponseNoLock(llvm::StringRef payload,
+ StringExtractorGDBRemote &response);
- virtual void
- OnRunPacketSent(bool first);
+ virtual void OnRunPacketSent(bool first);
private:
- // Variables handling synchronization between the Continue thread and any other threads
- // wishing to send packets over the connection. Either the continue thread has control over
- // the connection (m_is_running == true) or the connection is free for an arbitrary number of
- // other senders to take which indicate their interest by incrementing m_async_count.
- // Semantics of individual states:
- // - m_continue_packet == false, m_async_count == 0: connection is free
- // - m_continue_packet == true, m_async_count == 0: only continue thread is present
- // - m_continue_packet == true, m_async_count > 0: continue thread has control, async threads
- // should interrupt it and wait for it to set m_continue_packet to false
- // - m_continue_packet == false, m_async_count > 0: async threads have control, continue
- // thread needs to wait for them to finish (m_async_count goes down to 0).
- std::mutex m_mutex;
- std::condition_variable m_cv;
- // Packet with which to resume after an async interrupt. Can be changed by an async thread
- // e.g. to inject a signal.
- std::string m_continue_packet;
- // When was the interrupt packet sent. Used to make sure we time out if the stub does not
- // respond to interrupt requests.
- std::chrono::time_point<std::chrono::steady_clock> m_interrupt_time;
- uint32_t m_async_count;
- bool m_is_running;
- bool m_should_stop; // Whether we should resume after a stop.
- // end of continue thread synchronization block
-
- // This handles the synchronization between individual async threads. For now they just use a
- // simple mutex.
- std::recursive_mutex m_async_mutex;
-
- bool
- ShouldStop(const UnixSignals &signals, StringExtractorGDBRemote &response);
-
- class ContinueLock
- {
- public:
- enum class LockResult
- {
- Success,
- Cancelled,
- Failed
- };
-
- explicit ContinueLock(GDBRemoteClientBase &comm);
- ~ContinueLock();
- explicit operator bool() { return m_acquired; }
-
- LockResult
- lock();
-
- void
- unlock();
-
- private:
- GDBRemoteClientBase &m_comm;
- bool m_acquired;
- };
+ // Variables handling synchronization between the Continue thread and any
+ // other threads
+ // wishing to send packets over the connection. Either the continue thread has
+ // control over
+ // the connection (m_is_running == true) or the connection is free for an
+ // arbitrary number of
+ // other senders to take which indicate their interest by incrementing
+ // m_async_count.
+ // Semantics of individual states:
+ // - m_continue_packet == false, m_async_count == 0: connection is free
+ // - m_continue_packet == true, m_async_count == 0: only continue thread is
+ // present
+ // - m_continue_packet == true, m_async_count > 0: continue thread has
+ // control, async threads
+ // should interrupt it and wait for it to set m_continue_packet to false
+ // - m_continue_packet == false, m_async_count > 0: async threads have
+ // control, continue
+ // thread needs to wait for them to finish (m_async_count goes down to 0).
+ std::mutex m_mutex;
+ std::condition_variable m_cv;
+ // Packet with which to resume after an async interrupt. Can be changed by an
+ // async thread
+ // e.g. to inject a signal.
+ std::string m_continue_packet;
+ // When was the interrupt packet sent. Used to make sure we time out if the
+ // stub does not
+ // respond to interrupt requests.
+ std::chrono::time_point<std::chrono::steady_clock> m_interrupt_time;
+ uint32_t m_async_count;
+ bool m_is_running;
+ bool m_should_stop; // Whether we should resume after a stop.
+ // end of continue thread synchronization block
+
+ // This handles the synchronization between individual async threads. For now
+ // they just use a
+ // simple mutex.
+ std::recursive_mutex m_async_mutex;
+
+ bool ShouldStop(const UnixSignals &signals,
+ StringExtractorGDBRemote &response);
+
+ class ContinueLock {
+ public:
+ enum class LockResult { Success, Cancelled, Failed };
+
+ explicit ContinueLock(GDBRemoteClientBase &comm);
+ ~ContinueLock();
+ explicit operator bool() { return m_acquired; }
+
+ LockResult lock();
+
+ void unlock();
+
+ private:
+ GDBRemoteClientBase &m_comm;
+ bool m_acquired;
+ };
};
} // namespace process_gdb_remote
Modified: lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp (original)
+++ lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp Tue Sep 6 15:57:50 2016
@@ -7,7 +7,6 @@
//
//===----------------------------------------------------------------------===//
-
#include "GDBRemoteCommunication.h"
// C Includes
@@ -39,16 +38,16 @@
#include "ProcessGDBRemoteLog.h"
#if defined(__APPLE__)
-# define DEBUGSERVER_BASENAME "debugserver"
+#define DEBUGSERVER_BASENAME "debugserver"
#else
-# define DEBUGSERVER_BASENAME "lldb-server"
+#define DEBUGSERVER_BASENAME "lldb-server"
#endif
-#if defined (HAVE_LIBCOMPRESSION)
+#if defined(HAVE_LIBCOMPRESSION)
#include <compression.h>
#endif
-#if defined (HAVE_LIBZ)
+#if defined(HAVE_LIBZ)
#include <zlib.h>
#endif
@@ -56,1434 +55,1328 @@ using namespace lldb;
using namespace lldb_private;
using namespace lldb_private::process_gdb_remote;
-GDBRemoteCommunication::History::History (uint32_t size) :
- m_packets(),
- m_curr_idx (0),
- m_total_packet_count (0),
- m_dumped_to_log (false)
-{
- m_packets.resize(size);
-}
-
-GDBRemoteCommunication::History::~History ()
-{
-}
-
-void
-GDBRemoteCommunication::History::AddPacket (char packet_char,
- PacketType type,
- uint32_t bytes_transmitted)
-{
- const size_t size = m_packets.size();
- if (size > 0)
- {
- const uint32_t idx = GetNextIndex();
- m_packets[idx].packet.assign (1, packet_char);
- m_packets[idx].type = type;
- m_packets[idx].bytes_transmitted = bytes_transmitted;
- m_packets[idx].packet_idx = m_total_packet_count;
- m_packets[idx].tid = Host::GetCurrentThreadID();
- }
-}
-
-void
-GDBRemoteCommunication::History::AddPacket (const std::string &src,
- uint32_t src_len,
- PacketType type,
- uint32_t bytes_transmitted)
-{
- const size_t size = m_packets.size();
- if (size > 0)
- {
- const uint32_t idx = GetNextIndex();
- m_packets[idx].packet.assign (src, 0, src_len);
- m_packets[idx].type = type;
- m_packets[idx].bytes_transmitted = bytes_transmitted;
- m_packets[idx].packet_idx = m_total_packet_count;
- m_packets[idx].tid = Host::GetCurrentThreadID();
- }
-}
-
-void
-GDBRemoteCommunication::History::Dump (Stream &strm) const
-{
- const uint32_t size = GetNumPacketsInHistory ();
- const uint32_t first_idx = GetFirstSavedPacketIndex ();
+GDBRemoteCommunication::History::History(uint32_t size)
+ : m_packets(), m_curr_idx(0), m_total_packet_count(0),
+ m_dumped_to_log(false) {
+ m_packets.resize(size);
+}
+
+GDBRemoteCommunication::History::~History() {}
+
+void GDBRemoteCommunication::History::AddPacket(char packet_char,
+ PacketType type,
+ uint32_t bytes_transmitted) {
+ const size_t size = m_packets.size();
+ if (size > 0) {
+ const uint32_t idx = GetNextIndex();
+ m_packets[idx].packet.assign(1, packet_char);
+ m_packets[idx].type = type;
+ m_packets[idx].bytes_transmitted = bytes_transmitted;
+ m_packets[idx].packet_idx = m_total_packet_count;
+ m_packets[idx].tid = Host::GetCurrentThreadID();
+ }
+}
+
+void GDBRemoteCommunication::History::AddPacket(const std::string &src,
+ uint32_t src_len,
+ PacketType type,
+ uint32_t bytes_transmitted) {
+ const size_t size = m_packets.size();
+ if (size > 0) {
+ const uint32_t idx = GetNextIndex();
+ m_packets[idx].packet.assign(src, 0, src_len);
+ m_packets[idx].type = type;
+ m_packets[idx].bytes_transmitted = bytes_transmitted;
+ m_packets[idx].packet_idx = m_total_packet_count;
+ m_packets[idx].tid = Host::GetCurrentThreadID();
+ }
+}
+
+void GDBRemoteCommunication::History::Dump(Stream &strm) const {
+ const uint32_t size = GetNumPacketsInHistory();
+ const uint32_t first_idx = GetFirstSavedPacketIndex();
+ const uint32_t stop_idx = m_curr_idx + size;
+ for (uint32_t i = first_idx; i < stop_idx; ++i) {
+ const uint32_t idx = NormalizeIndex(i);
+ const Entry &entry = m_packets[idx];
+ if (entry.type == ePacketTypeInvalid || entry.packet.empty())
+ break;
+ strm.Printf("history[%u] tid=0x%4.4" PRIx64 " <%4u> %s packet: %s\n",
+ entry.packet_idx, entry.tid, entry.bytes_transmitted,
+ (entry.type == ePacketTypeSend) ? "send" : "read",
+ entry.packet.c_str());
+ }
+}
+
+void GDBRemoteCommunication::History::Dump(Log *log) const {
+ if (log && !m_dumped_to_log) {
+ m_dumped_to_log = true;
+ const uint32_t size = GetNumPacketsInHistory();
+ const uint32_t first_idx = GetFirstSavedPacketIndex();
const uint32_t stop_idx = m_curr_idx + size;
- for (uint32_t i = first_idx; i < stop_idx; ++i)
- {
- const uint32_t idx = NormalizeIndex (i);
- const Entry &entry = m_packets[idx];
- if (entry.type == ePacketTypeInvalid || entry.packet.empty())
- break;
- strm.Printf ("history[%u] tid=0x%4.4" PRIx64 " <%4u> %s packet: %s\n",
- entry.packet_idx,
- entry.tid,
- entry.bytes_transmitted,
- (entry.type == ePacketTypeSend) ? "send" : "read",
- entry.packet.c_str());
- }
-}
-
-void
-GDBRemoteCommunication::History::Dump (Log *log) const
-{
- if (log && !m_dumped_to_log)
- {
- m_dumped_to_log = true;
- const uint32_t size = GetNumPacketsInHistory ();
- const uint32_t first_idx = GetFirstSavedPacketIndex ();
- const uint32_t stop_idx = m_curr_idx + size;
- for (uint32_t i = first_idx; i < stop_idx; ++i)
- {
- const uint32_t idx = NormalizeIndex (i);
- const Entry &entry = m_packets[idx];
- if (entry.type == ePacketTypeInvalid || entry.packet.empty())
- break;
- log->Printf ("history[%u] tid=0x%4.4" PRIx64 " <%4u> %s packet: %s",
- entry.packet_idx,
- entry.tid,
- entry.bytes_transmitted,
- (entry.type == ePacketTypeSend) ? "send" : "read",
- entry.packet.c_str());
- }
+ for (uint32_t i = first_idx; i < stop_idx; ++i) {
+ const uint32_t idx = NormalizeIndex(i);
+ const Entry &entry = m_packets[idx];
+ if (entry.type == ePacketTypeInvalid || entry.packet.empty())
+ break;
+ log->Printf("history[%u] tid=0x%4.4" PRIx64 " <%4u> %s packet: %s",
+ entry.packet_idx, entry.tid, entry.bytes_transmitted,
+ (entry.type == ePacketTypeSend) ? "send" : "read",
+ entry.packet.c_str());
}
+ }
}
//----------------------------------------------------------------------
// GDBRemoteCommunication constructor
//----------------------------------------------------------------------
-GDBRemoteCommunication::GDBRemoteCommunication(const char *comm_name, const char *listener_name)
+GDBRemoteCommunication::GDBRemoteCommunication(const char *comm_name,
+ const char *listener_name)
: Communication(comm_name),
#ifdef LLDB_CONFIGURATION_DEBUG
m_packet_timeout(1000),
#else
m_packet_timeout(1),
#endif
- m_echo_number(0),
- m_supports_qEcho(eLazyBoolCalculate),
- m_history(512),
- m_send_acks(true),
- m_compression_type(CompressionType::None),
- m_listen_url()
-{
+ m_echo_number(0), m_supports_qEcho(eLazyBoolCalculate), m_history(512),
+ m_send_acks(true), m_compression_type(CompressionType::None),
+ m_listen_url() {
}
//----------------------------------------------------------------------
// Destructor
//----------------------------------------------------------------------
-GDBRemoteCommunication::~GDBRemoteCommunication()
-{
- if (IsConnected())
- {
- Disconnect();
- }
-
- // Stop the communications read thread which is used to parse all
- // incoming packets. This function will block until the read
- // thread returns.
- if (m_read_thread_enabled)
- StopReadThread();
-}
-
-char
-GDBRemoteCommunication::CalculcateChecksum (llvm::StringRef payload)
-{
- int checksum = 0;
-
- for (char c : payload)
- checksum += c;
-
- return checksum & 255;
-}
-
-size_t
-GDBRemoteCommunication::SendAck ()
-{
- Log *log (ProcessGDBRemoteLog::GetLogIfAllCategoriesSet (GDBR_LOG_PACKETS));
- ConnectionStatus status = eConnectionStatusSuccess;
- char ch = '+';
- const size_t bytes_written = Write (&ch, 1, status, NULL);
- if (log)
- log->Printf ("<%4" PRIu64 "> send packet: %c", (uint64_t)bytes_written, ch);
- m_history.AddPacket (ch, History::ePacketTypeSend, bytes_written);
- return bytes_written;
-}
-
-size_t
-GDBRemoteCommunication::SendNack ()
-{
- Log *log (ProcessGDBRemoteLog::GetLogIfAllCategoriesSet (GDBR_LOG_PACKETS));
- ConnectionStatus status = eConnectionStatusSuccess;
- char ch = '-';
- const size_t bytes_written = Write (&ch, 1, status, NULL);
- if (log)
- log->Printf("<%4" PRIu64 "> send packet: %c", (uint64_t)bytes_written, ch);
- m_history.AddPacket (ch, History::ePacketTypeSend, bytes_written);
- return bytes_written;
+GDBRemoteCommunication::~GDBRemoteCommunication() {
+ if (IsConnected()) {
+ Disconnect();
+ }
+
+ // Stop the communications read thread which is used to parse all
+ // incoming packets. This function will block until the read
+ // thread returns.
+ if (m_read_thread_enabled)
+ StopReadThread();
+}
+
+char GDBRemoteCommunication::CalculcateChecksum(llvm::StringRef payload) {
+ int checksum = 0;
+
+ for (char c : payload)
+ checksum += c;
+
+ return checksum & 255;
+}
+
+size_t GDBRemoteCommunication::SendAck() {
+ Log *log(ProcessGDBRemoteLog::GetLogIfAllCategoriesSet(GDBR_LOG_PACKETS));
+ ConnectionStatus status = eConnectionStatusSuccess;
+ char ch = '+';
+ const size_t bytes_written = Write(&ch, 1, status, NULL);
+ if (log)
+ log->Printf("<%4" PRIu64 "> send packet: %c", (uint64_t)bytes_written, ch);
+ m_history.AddPacket(ch, History::ePacketTypeSend, bytes_written);
+ return bytes_written;
+}
+
+size_t GDBRemoteCommunication::SendNack() {
+ Log *log(ProcessGDBRemoteLog::GetLogIfAllCategoriesSet(GDBR_LOG_PACKETS));
+ ConnectionStatus status = eConnectionStatusSuccess;
+ char ch = '-';
+ const size_t bytes_written = Write(&ch, 1, status, NULL);
+ if (log)
+ log->Printf("<%4" PRIu64 "> send packet: %c", (uint64_t)bytes_written, ch);
+ m_history.AddPacket(ch, History::ePacketTypeSend, bytes_written);
+ return bytes_written;
}
GDBRemoteCommunication::PacketResult
-GDBRemoteCommunication::SendPacketNoLock (llvm::StringRef payload)
-{
- if (IsConnected())
- {
- StreamString packet(0, 4, eByteOrderBig);
-
- packet.PutChar('$');
- packet.Write (payload.data(), payload.size());
- packet.PutChar('#');
- packet.PutHex8(CalculcateChecksum (payload));
-
- Log *log (ProcessGDBRemoteLog::GetLogIfAllCategoriesSet (GDBR_LOG_PACKETS));
- ConnectionStatus status = eConnectionStatusSuccess;
- const char *packet_data = packet.GetData();
- const size_t packet_length = packet.GetSize();
- size_t bytes_written = Write (packet_data, packet_length, status, NULL);
- if (log)
- {
- size_t binary_start_offset = 0;
- if (strncmp(packet_data, "$vFile:pwrite:", strlen("$vFile:pwrite:")) == 0)
- {
- const char *first_comma = strchr(packet_data, ',');
- if (first_comma)
- {
- const char *second_comma = strchr(first_comma + 1, ',');
- if (second_comma)
- binary_start_offset = second_comma - packet_data + 1;
- }
- }
+GDBRemoteCommunication::SendPacketNoLock(llvm::StringRef payload) {
+ if (IsConnected()) {
+ StreamString packet(0, 4, eByteOrderBig);
+
+ packet.PutChar('$');
+ packet.Write(payload.data(), payload.size());
+ packet.PutChar('#');
+ packet.PutHex8(CalculcateChecksum(payload));
- // If logging was just enabled and we have history, then dump out what
- // we have to the log so we get the historical context. The Dump() call that
- // logs all of the packet will set a boolean so that we don't dump this more
- // than once
- if (!m_history.DidDumpToLog ())
- m_history.Dump (log);
-
- if (binary_start_offset)
- {
- StreamString strm;
- // Print non binary data header
- strm.Printf("<%4" PRIu64 "> send packet: %.*s", (uint64_t)bytes_written, (int)binary_start_offset, packet_data);
- const uint8_t *p;
- // Print binary data exactly as sent
- for (p = (const uint8_t*)packet_data + binary_start_offset; *p != '#'; ++p)
- strm.Printf("\\x%2.2x", *p);
- // Print the checksum
- strm.Printf("%*s", (int)3, p);
- log->PutCString(strm.GetString().c_str());
- }
- else
- log->Printf("<%4" PRIu64 "> send packet: %.*s", (uint64_t)bytes_written, (int)packet_length, packet_data);
- }
-
- m_history.AddPacket (packet.GetString(), packet_length, History::ePacketTypeSend, bytes_written);
-
-
- if (bytes_written == packet_length)
- {
- if (GetSendAcks ())
- return GetAck ();
- else
- return PacketResult::Success;
- }
- else
- {
- if (log)
- log->Printf ("error: failed to send packet: %.*s", (int)packet_length, packet_data);
- }
- }
- return PacketResult::ErrorSendFailed;
-}
-
-GDBRemoteCommunication::PacketResult
-GDBRemoteCommunication::GetAck ()
-{
- StringExtractorGDBRemote packet;
- PacketResult result = ReadPacket (packet, GetPacketTimeoutInMicroSeconds (), false);
- if (result == PacketResult::Success)
- {
- if (packet.GetResponseType() == StringExtractorGDBRemote::ResponseType::eAck)
- return PacketResult::Success;
- else
- return PacketResult::ErrorSendAck;
- }
- return result;
+ Log *log(ProcessGDBRemoteLog::GetLogIfAllCategoriesSet(GDBR_LOG_PACKETS));
+ ConnectionStatus status = eConnectionStatusSuccess;
+ const char *packet_data = packet.GetData();
+ const size_t packet_length = packet.GetSize();
+ size_t bytes_written = Write(packet_data, packet_length, status, NULL);
+ if (log) {
+ size_t binary_start_offset = 0;
+ if (strncmp(packet_data, "$vFile:pwrite:", strlen("$vFile:pwrite:")) ==
+ 0) {
+ const char *first_comma = strchr(packet_data, ',');
+ if (first_comma) {
+ const char *second_comma = strchr(first_comma + 1, ',');
+ if (second_comma)
+ binary_start_offset = second_comma - packet_data + 1;
+ }
+ }
+
+ // If logging was just enabled and we have history, then dump out what
+ // we have to the log so we get the historical context. The Dump() call
+ // that
+ // logs all of the packet will set a boolean so that we don't dump this
+ // more
+ // than once
+ if (!m_history.DidDumpToLog())
+ m_history.Dump(log);
+
+ if (binary_start_offset) {
+ StreamString strm;
+ // Print non binary data header
+ strm.Printf("<%4" PRIu64 "> send packet: %.*s", (uint64_t)bytes_written,
+ (int)binary_start_offset, packet_data);
+ const uint8_t *p;
+ // Print binary data exactly as sent
+ for (p = (const uint8_t *)packet_data + binary_start_offset; *p != '#';
+ ++p)
+ strm.Printf("\\x%2.2x", *p);
+ // Print the checksum
+ strm.Printf("%*s", (int)3, p);
+ log->PutCString(strm.GetString().c_str());
+ } else
+ log->Printf("<%4" PRIu64 "> send packet: %.*s", (uint64_t)bytes_written,
+ (int)packet_length, packet_data);
+ }
+
+ m_history.AddPacket(packet.GetString(), packet_length,
+ History::ePacketTypeSend, bytes_written);
+
+ if (bytes_written == packet_length) {
+ if (GetSendAcks())
+ return GetAck();
+ else
+ return PacketResult::Success;
+ } else {
+ if (log)
+ log->Printf("error: failed to send packet: %.*s", (int)packet_length,
+ packet_data);
+ }
+ }
+ return PacketResult::ErrorSendFailed;
+}
+
+GDBRemoteCommunication::PacketResult GDBRemoteCommunication::GetAck() {
+ StringExtractorGDBRemote packet;
+ PacketResult result =
+ ReadPacket(packet, GetPacketTimeoutInMicroSeconds(), false);
+ if (result == PacketResult::Success) {
+ if (packet.GetResponseType() ==
+ StringExtractorGDBRemote::ResponseType::eAck)
+ return PacketResult::Success;
+ else
+ return PacketResult::ErrorSendAck;
+ }
+ return result;
}
GDBRemoteCommunication::PacketResult
-GDBRemoteCommunication::ReadPacket (StringExtractorGDBRemote &response, uint32_t timeout_usec, bool sync_on_timeout)
-{
- if (m_read_thread_enabled)
- return PopPacketFromQueue (response, timeout_usec);
- else
- return WaitForPacketWithTimeoutMicroSecondsNoLock (response, timeout_usec, sync_on_timeout);
+GDBRemoteCommunication::ReadPacket(StringExtractorGDBRemote &response,
+ uint32_t timeout_usec,
+ bool sync_on_timeout) {
+ if (m_read_thread_enabled)
+ return PopPacketFromQueue(response, timeout_usec);
+ else
+ return WaitForPacketWithTimeoutMicroSecondsNoLock(response, timeout_usec,
+ sync_on_timeout);
}
-
// This function is called when a packet is requested.
// A whole packet is popped from the packet queue and returned to the caller.
// Packets are placed into this queue from the communication read thread.
// See GDBRemoteCommunication::AppendBytesToCache.
GDBRemoteCommunication::PacketResult
-GDBRemoteCommunication::PopPacketFromQueue (StringExtractorGDBRemote &response, uint32_t timeout_usec)
-{
- auto until = std::chrono::system_clock::now() + std::chrono::microseconds(timeout_usec);
-
- while (true)
- {
- // scope for the mutex
- {
- // lock down the packet queue
- std::unique_lock<std::mutex> lock(m_packet_queue_mutex);
-
- // Wait on condition variable.
- if (m_packet_queue.size() == 0)
- {
- std::cv_status result = m_condition_queue_not_empty.wait_until(lock, until);
- if (result == std::cv_status::timeout)
- break;
- }
+GDBRemoteCommunication::PopPacketFromQueue(StringExtractorGDBRemote &response,
+ uint32_t timeout_usec) {
+ auto until = std::chrono::system_clock::now() +
+ std::chrono::microseconds(timeout_usec);
+
+ while (true) {
+ // scope for the mutex
+ {
+ // lock down the packet queue
+ std::unique_lock<std::mutex> lock(m_packet_queue_mutex);
+
+ // Wait on condition variable.
+ if (m_packet_queue.size() == 0) {
+ std::cv_status result =
+ m_condition_queue_not_empty.wait_until(lock, until);
+ if (result == std::cv_status::timeout)
+ break;
+ }
+
+ if (m_packet_queue.size() > 0) {
+ // get the front element of the queue
+ response = m_packet_queue.front();
- if (m_packet_queue.size() > 0)
- {
- // get the front element of the queue
- response = m_packet_queue.front();
+ // remove the front element
+ m_packet_queue.pop();
- // remove the front element
- m_packet_queue.pop();
-
- // we got a packet
- return PacketResult::Success;
- }
- }
+ // we got a packet
+ return PacketResult::Success;
+ }
+ }
- // Disconnected
- if (!IsConnected())
- return PacketResult::ErrorDisconnected;
+ // Disconnected
+ if (!IsConnected())
+ return PacketResult::ErrorDisconnected;
- // Loop while not timed out
- }
+ // Loop while not timed out
+ }
- return PacketResult::ErrorReplyTimeout;
+ return PacketResult::ErrorReplyTimeout;
}
-
GDBRemoteCommunication::PacketResult
-GDBRemoteCommunication::WaitForPacketWithTimeoutMicroSecondsNoLock (StringExtractorGDBRemote &packet, uint32_t timeout_usec, bool sync_on_timeout)
-{
- uint8_t buffer[8192];
- Error error;
+GDBRemoteCommunication::WaitForPacketWithTimeoutMicroSecondsNoLock(
+ StringExtractorGDBRemote &packet, uint32_t timeout_usec,
+ bool sync_on_timeout) {
+ uint8_t buffer[8192];
+ Error error;
+
+ Log *log(ProcessGDBRemoteLog::GetLogIfAllCategoriesSet(GDBR_LOG_PACKETS |
+ GDBR_LOG_VERBOSE));
+
+ // Check for a packet from our cache first without trying any reading...
+ if (CheckForPacket(NULL, 0, packet) != PacketType::Invalid)
+ return PacketResult::Success;
+
+ bool timed_out = false;
+ bool disconnected = false;
+ while (IsConnected() && !timed_out) {
+ lldb::ConnectionStatus status = eConnectionStatusNoConnection;
+ size_t bytes_read =
+ Read(buffer, sizeof(buffer), timeout_usec, status, &error);
- Log *log (ProcessGDBRemoteLog::GetLogIfAllCategoriesSet (GDBR_LOG_PACKETS | GDBR_LOG_VERBOSE));
+ if (log)
+ log->Printf("%s: Read (buffer, (sizeof(buffer), timeout_usec = 0x%x, "
+ "status = %s, error = %s) => bytes_read = %" PRIu64,
+ LLVM_PRETTY_FUNCTION, timeout_usec,
+ Communication::ConnectionStatusAsCString(status),
+ error.AsCString(), (uint64_t)bytes_read);
- // Check for a packet from our cache first without trying any reading...
- if (CheckForPacket(NULL, 0, packet) != PacketType::Invalid)
+ if (bytes_read > 0) {
+ if (CheckForPacket(buffer, bytes_read, packet) != PacketType::Invalid)
return PacketResult::Success;
+ } else {
+ switch (status) {
+ case eConnectionStatusTimedOut:
+ case eConnectionStatusInterrupted:
+ if (sync_on_timeout) {
+ //------------------------------------------------------------------
+ /// Sync the remote GDB server and make sure we get a response that
+ /// corresponds to what we send.
+ ///
+ /// Sends a "qEcho" packet and makes sure it gets the exact packet
+ /// echoed back. If the qEcho packet isn't supported, we send a qC
+ /// packet and make sure we get a valid thread ID back. We use the
+ /// "qC" packet since its response if very unique: is responds with
+ /// "QC%x" where %x is the thread ID of the current thread. This
+ /// makes the response unique enough from other packet responses to
+ /// ensure we are back on track.
+ ///
+ /// This packet is needed after we time out sending a packet so we
+ /// can ensure that we are getting the response for the packet we
+ /// are sending. There are no sequence IDs in the GDB remote
+ /// protocol (there used to be, but they are not supported anymore)
+ /// so if you timeout sending packet "abc", you might then send
+ /// packet "cde" and get the response for the previous "abc" packet.
+ /// Many responses are "OK" or "" (unsupported) or "EXX" (error) so
+ /// many responses for packets can look like responses for other
+ /// packets. So if we timeout, we need to ensure that we can get
+ /// back on track. If we can't get back on track, we must
+ /// disconnect.
+ //------------------------------------------------------------------
+ bool sync_success = false;
+ bool got_actual_response = false;
+ // We timed out, we need to sync back up with the
+ char echo_packet[32];
+ int echo_packet_len = 0;
+ RegularExpression response_regex;
+
+ if (m_supports_qEcho == eLazyBoolYes) {
+ echo_packet_len = ::snprintf(echo_packet, sizeof(echo_packet),
+ "qEcho:%u", ++m_echo_number);
+ std::string regex_str = "^";
+ regex_str += echo_packet;
+ regex_str += "$";
+ response_regex.Compile(regex_str.c_str());
+ } else {
+ echo_packet_len =
+ ::snprintf(echo_packet, sizeof(echo_packet), "qC");
+ response_regex.Compile("^QC[0-9A-Fa-f]+$");
+ }
+
+ PacketResult echo_packet_result =
+ SendPacketNoLock(llvm::StringRef(echo_packet, echo_packet_len));
+ if (echo_packet_result == PacketResult::Success) {
+ const uint32_t max_retries = 3;
+ uint32_t successful_responses = 0;
+ for (uint32_t i = 0; i < max_retries; ++i) {
+ StringExtractorGDBRemote echo_response;
+ echo_packet_result = WaitForPacketWithTimeoutMicroSecondsNoLock(
+ echo_response, timeout_usec, false);
+ if (echo_packet_result == PacketResult::Success) {
+ ++successful_responses;
+ if (response_regex.Execute(
+ echo_response.GetStringRef().c_str())) {
+ sync_success = true;
+ break;
+ } else if (successful_responses == 1) {
+ // We got something else back as the first successful
+ // response, it probably is
+ // the response to the packet we actually wanted, so copy it
+ // over if this
+ // is the first success and continue to try to get the qEcho
+ // response
+ packet = echo_response;
+ got_actual_response = true;
+ }
+ } else if (echo_packet_result == PacketResult::ErrorReplyTimeout)
+ continue; // Packet timed out, continue waiting for a response
+ else
+ break; // Something else went wrong getting the packet back, we
+ // failed and are done trying
+ }
+ }
- bool timed_out = false;
- bool disconnected = false;
- while (IsConnected() && !timed_out)
- {
- lldb::ConnectionStatus status = eConnectionStatusNoConnection;
- size_t bytes_read = Read (buffer, sizeof(buffer), timeout_usec, status, &error);
-
- if (log)
- log->Printf ("%s: Read (buffer, (sizeof(buffer), timeout_usec = 0x%x, status = %s, error = %s) => bytes_read = %" PRIu64,
- LLVM_PRETTY_FUNCTION,
- timeout_usec,
- Communication::ConnectionStatusAsCString (status),
- error.AsCString(),
- (uint64_t)bytes_read);
-
- if (bytes_read > 0)
- {
- if (CheckForPacket(buffer, bytes_read, packet) != PacketType::Invalid)
- return PacketResult::Success;
- }
- else
- {
- switch (status)
- {
- case eConnectionStatusTimedOut:
- case eConnectionStatusInterrupted:
- if (sync_on_timeout)
- {
- //------------------------------------------------------------------
- /// Sync the remote GDB server and make sure we get a response that
- /// corresponds to what we send.
- ///
- /// Sends a "qEcho" packet and makes sure it gets the exact packet
- /// echoed back. If the qEcho packet isn't supported, we send a qC
- /// packet and make sure we get a valid thread ID back. We use the
- /// "qC" packet since its response if very unique: is responds with
- /// "QC%x" where %x is the thread ID of the current thread. This
- /// makes the response unique enough from other packet responses to
- /// ensure we are back on track.
- ///
- /// This packet is needed after we time out sending a packet so we
- /// can ensure that we are getting the response for the packet we
- /// are sending. There are no sequence IDs in the GDB remote
- /// protocol (there used to be, but they are not supported anymore)
- /// so if you timeout sending packet "abc", you might then send
- /// packet "cde" and get the response for the previous "abc" packet.
- /// Many responses are "OK" or "" (unsupported) or "EXX" (error) so
- /// many responses for packets can look like responses for other
- /// packets. So if we timeout, we need to ensure that we can get
- /// back on track. If we can't get back on track, we must
- /// disconnect.
- //------------------------------------------------------------------
- bool sync_success = false;
- bool got_actual_response = false;
- // We timed out, we need to sync back up with the
- char echo_packet[32];
- int echo_packet_len = 0;
- RegularExpression response_regex;
-
- if (m_supports_qEcho == eLazyBoolYes)
- {
- echo_packet_len = ::snprintf (echo_packet, sizeof(echo_packet), "qEcho:%u", ++m_echo_number);
- std::string regex_str = "^";
- regex_str += echo_packet;
- regex_str += "$";
- response_regex.Compile(regex_str.c_str());
- }
- else
- {
- echo_packet_len = ::snprintf (echo_packet, sizeof(echo_packet), "qC");
- response_regex.Compile("^QC[0-9A-Fa-f]+$");
- }
-
- PacketResult echo_packet_result = SendPacketNoLock (llvm::StringRef(echo_packet, echo_packet_len));
- if (echo_packet_result == PacketResult::Success)
- {
- const uint32_t max_retries = 3;
- uint32_t successful_responses = 0;
- for (uint32_t i=0; i<max_retries; ++i)
- {
- StringExtractorGDBRemote echo_response;
- echo_packet_result = WaitForPacketWithTimeoutMicroSecondsNoLock (echo_response, timeout_usec, false);
- if (echo_packet_result == PacketResult::Success)
- {
- ++successful_responses;
- if (response_regex.Execute(echo_response.GetStringRef().c_str()))
- {
- sync_success = true;
- break;
- }
- else if (successful_responses == 1)
- {
- // We got something else back as the first successful response, it probably is
- // the response to the packet we actually wanted, so copy it over if this
- // is the first success and continue to try to get the qEcho response
- packet = echo_response;
- got_actual_response = true;
- }
- }
- else if (echo_packet_result == PacketResult::ErrorReplyTimeout)
- continue; // Packet timed out, continue waiting for a response
- else
- break; // Something else went wrong getting the packet back, we failed and are done trying
- }
- }
-
- // We weren't able to sync back up with the server, we must abort otherwise
- // all responses might not be from the right packets...
- if (sync_success)
- {
- // We timed out, but were able to recover
- if (got_actual_response)
- {
- // We initially timed out, but we did get a response that came in before the successful
- // reply to our qEcho packet, so lets say everything is fine...
- return PacketResult::Success;
- }
- }
- else
- {
- disconnected = true;
- Disconnect();
- }
- }
- timed_out = true;
- break;
- case eConnectionStatusSuccess:
- //printf ("status = success but error = %s\n", error.AsCString("<invalid>"));
- break;
-
- case eConnectionStatusEndOfFile:
- case eConnectionStatusNoConnection:
- case eConnectionStatusLostConnection:
- case eConnectionStatusError:
- disconnected = true;
- Disconnect();
- break;
+ // We weren't able to sync back up with the server, we must abort
+ // otherwise
+ // all responses might not be from the right packets...
+ if (sync_success) {
+ // We timed out, but were able to recover
+ if (got_actual_response) {
+ // We initially timed out, but we did get a response that came in
+ // before the successful
+ // reply to our qEcho packet, so lets say everything is fine...
+ return PacketResult::Success;
}
- }
+ } else {
+ disconnected = true;
+ Disconnect();
+ }
+ }
+ timed_out = true;
+ break;
+ case eConnectionStatusSuccess:
+ // printf ("status = success but error = %s\n",
+ // error.AsCString("<invalid>"));
+ break;
+
+ case eConnectionStatusEndOfFile:
+ case eConnectionStatusNoConnection:
+ case eConnectionStatusLostConnection:
+ case eConnectionStatusError:
+ disconnected = true;
+ Disconnect();
+ break;
+ }
}
- packet.Clear ();
- if (disconnected)
- return PacketResult::ErrorDisconnected;
- if (timed_out)
- return PacketResult::ErrorReplyTimeout;
- else
- return PacketResult::ErrorReplyFailed;
+ }
+ packet.Clear();
+ if (disconnected)
+ return PacketResult::ErrorDisconnected;
+ if (timed_out)
+ return PacketResult::ErrorReplyTimeout;
+ else
+ return PacketResult::ErrorReplyFailed;
}
-bool
-GDBRemoteCommunication::DecompressPacket ()
-{
- Log *log (ProcessGDBRemoteLog::GetLogIfAllCategoriesSet (GDBR_LOG_PACKETS));
-
- if (!CompressionIsEnabled())
- return true;
-
- size_t pkt_size = m_bytes.size();
-
- // Smallest possible compressed packet is $N#00 - an uncompressed empty reply, most commonly indicating
- // an unsupported packet. Anything less than 5 characters, it's definitely not a compressed packet.
- if (pkt_size < 5)
- return true;
-
- if (m_bytes[0] != '$' && m_bytes[0] != '%')
- return true;
- if (m_bytes[1] != 'C' && m_bytes[1] != 'N')
- return true;
+bool GDBRemoteCommunication::DecompressPacket() {
+ Log *log(ProcessGDBRemoteLog::GetLogIfAllCategoriesSet(GDBR_LOG_PACKETS));
- size_t hash_mark_idx = m_bytes.find ('#');
- if (hash_mark_idx == std::string::npos)
- return true;
- if (hash_mark_idx + 2 >= m_bytes.size())
- return true;
-
- if (!::isxdigit (m_bytes[hash_mark_idx + 1]) || !::isxdigit (m_bytes[hash_mark_idx + 2]))
- return true;
+ if (!CompressionIsEnabled())
+ return true;
- size_t content_length = pkt_size - 5; // not counting '$', 'C' | 'N', '#', & the two hex checksum chars
- size_t content_start = 2; // The first character of the compressed/not-compressed text of the packet
- size_t checksum_idx = hash_mark_idx + 1; // The first character of the two hex checksum characters
+ size_t pkt_size = m_bytes.size();
- // Normally size_of_first_packet == m_bytes.size() but m_bytes may contain multiple packets.
- // size_of_first_packet is the size of the initial packet which we'll replace with the decompressed
- // version of, leaving the rest of m_bytes unmodified.
- size_t size_of_first_packet = hash_mark_idx + 3;
+ // Smallest possible compressed packet is $N#00 - an uncompressed empty reply,
+ // most commonly indicating
+ // an unsupported packet. Anything less than 5 characters, it's definitely
+ // not a compressed packet.
+ if (pkt_size < 5)
+ return true;
- // Compressed packets ("$C") start with a base10 number which is the size of the uncompressed payload,
- // then a : and then the compressed data. e.g. $C1024:<binary>#00
- // Update content_start and content_length to only include the <binary> part of the packet.
+ if (m_bytes[0] != '$' && m_bytes[0] != '%')
+ return true;
+ if (m_bytes[1] != 'C' && m_bytes[1] != 'N')
+ return true;
- uint64_t decompressed_bufsize = ULONG_MAX;
- if (m_bytes[1] == 'C')
- {
- size_t i = content_start;
- while (i < hash_mark_idx && isdigit(m_bytes[i]))
- i++;
- if (i < hash_mark_idx && m_bytes[i] == ':')
- {
- i++;
- content_start = i;
- content_length = hash_mark_idx - content_start;
- std::string bufsize_str (m_bytes.data() + 2, i - 2 - 1);
- errno = 0;
- decompressed_bufsize = ::strtoul (bufsize_str.c_str(), NULL, 10);
- if (errno != 0 || decompressed_bufsize == ULONG_MAX)
- {
- m_bytes.erase (0, size_of_first_packet);
- return false;
- }
- }
- }
+ size_t hash_mark_idx = m_bytes.find('#');
+ if (hash_mark_idx == std::string::npos)
+ return true;
+ if (hash_mark_idx + 2 >= m_bytes.size())
+ return true;
- if (GetSendAcks ())
- {
- char packet_checksum_cstr[3];
- packet_checksum_cstr[0] = m_bytes[checksum_idx];
- packet_checksum_cstr[1] = m_bytes[checksum_idx + 1];
- packet_checksum_cstr[2] = '\0';
- long packet_checksum = strtol (packet_checksum_cstr, NULL, 16);
-
- long actual_checksum = CalculcateChecksum (llvm::StringRef(m_bytes).substr(1, hash_mark_idx - 1));
- bool success = packet_checksum == actual_checksum;
- if (!success)
- {
- if (log)
- log->Printf ("error: checksum mismatch: %.*s expected 0x%2.2x, got 0x%2.2x",
- (int)(pkt_size),
- m_bytes.c_str(),
- (uint8_t)packet_checksum,
- (uint8_t)actual_checksum);
- }
- // Send the ack or nack if needed
- if (!success)
- {
- SendNack();
- m_bytes.erase (0, size_of_first_packet);
- return false;
- }
- else
- {
- SendAck();
- }
- }
+ if (!::isxdigit(m_bytes[hash_mark_idx + 1]) ||
+ !::isxdigit(m_bytes[hash_mark_idx + 2]))
+ return true;
- if (m_bytes[1] == 'N')
- {
- // This packet was not compressed -- delete the 'N' character at the
- // start and the packet may be processed as-is.
- m_bytes.erase(1, 1);
- return true;
- }
+ size_t content_length =
+ pkt_size -
+ 5; // not counting '$', 'C' | 'N', '#', & the two hex checksum chars
+ size_t content_start = 2; // The first character of the
+ // compressed/not-compressed text of the packet
+ size_t checksum_idx =
+ hash_mark_idx +
+ 1; // The first character of the two hex checksum characters
+
+ // Normally size_of_first_packet == m_bytes.size() but m_bytes may contain
+ // multiple packets.
+ // size_of_first_packet is the size of the initial packet which we'll replace
+ // with the decompressed
+ // version of, leaving the rest of m_bytes unmodified.
+ size_t size_of_first_packet = hash_mark_idx + 3;
+
+ // Compressed packets ("$C") start with a base10 number which is the size of
+ // the uncompressed payload,
+ // then a : and then the compressed data. e.g. $C1024:<binary>#00
+ // Update content_start and content_length to only include the <binary> part
+ // of the packet.
- // Reverse the gdb-remote binary escaping that was done to the compressed text to
- // guard characters like '$', '#', '}', etc.
- std::vector<uint8_t> unescaped_content;
- unescaped_content.reserve (content_length);
+ uint64_t decompressed_bufsize = ULONG_MAX;
+ if (m_bytes[1] == 'C') {
size_t i = content_start;
- while (i < hash_mark_idx)
- {
- if (m_bytes[i] == '}')
- {
- i++;
- unescaped_content.push_back (m_bytes[i] ^ 0x20);
- }
- else
- {
- unescaped_content.push_back (m_bytes[i]);
- }
- i++;
+ while (i < hash_mark_idx && isdigit(m_bytes[i]))
+ i++;
+ if (i < hash_mark_idx && m_bytes[i] == ':') {
+ i++;
+ content_start = i;
+ content_length = hash_mark_idx - content_start;
+ std::string bufsize_str(m_bytes.data() + 2, i - 2 - 1);
+ errno = 0;
+ decompressed_bufsize = ::strtoul(bufsize_str.c_str(), NULL, 10);
+ if (errno != 0 || decompressed_bufsize == ULONG_MAX) {
+ m_bytes.erase(0, size_of_first_packet);
+ return false;
+ }
}
+ }
- uint8_t *decompressed_buffer = nullptr;
- size_t decompressed_bytes = 0;
-
- if (decompressed_bufsize != ULONG_MAX)
- {
- decompressed_buffer = (uint8_t *) malloc (decompressed_bufsize + 1);
- if (decompressed_buffer == nullptr)
- {
- m_bytes.erase (0, size_of_first_packet);
- return false;
- }
-
- }
+ if (GetSendAcks()) {
+ char packet_checksum_cstr[3];
+ packet_checksum_cstr[0] = m_bytes[checksum_idx];
+ packet_checksum_cstr[1] = m_bytes[checksum_idx + 1];
+ packet_checksum_cstr[2] = '\0';
+ long packet_checksum = strtol(packet_checksum_cstr, NULL, 16);
+
+ long actual_checksum = CalculcateChecksum(
+ llvm::StringRef(m_bytes).substr(1, hash_mark_idx - 1));
+ bool success = packet_checksum == actual_checksum;
+ if (!success) {
+ if (log)
+ log->Printf(
+ "error: checksum mismatch: %.*s expected 0x%2.2x, got 0x%2.2x",
+ (int)(pkt_size), m_bytes.c_str(), (uint8_t)packet_checksum,
+ (uint8_t)actual_checksum);
+ }
+ // Send the ack or nack if needed
+ if (!success) {
+ SendNack();
+ m_bytes.erase(0, size_of_first_packet);
+ return false;
+ } else {
+ SendAck();
+ }
+ }
+
+ if (m_bytes[1] == 'N') {
+ // This packet was not compressed -- delete the 'N' character at the
+ // start and the packet may be processed as-is.
+ m_bytes.erase(1, 1);
+ return true;
+ }
-#if defined (HAVE_LIBCOMPRESSION)
- // libcompression is weak linked so check that compression_decode_buffer() is available
- if (compression_decode_buffer != NULL &&
- (m_compression_type == CompressionType::ZlibDeflate
- || m_compression_type == CompressionType::LZFSE
- || m_compression_type == CompressionType::LZ4))
- {
- compression_algorithm compression_type;
- if (m_compression_type == CompressionType::ZlibDeflate)
- compression_type = COMPRESSION_ZLIB;
- else if (m_compression_type == CompressionType::LZFSE)
- compression_type = COMPRESSION_LZFSE;
- else if (m_compression_type == CompressionType::LZ4)
- compression_type = COMPRESSION_LZ4_RAW;
- else if (m_compression_type == CompressionType::LZMA)
- compression_type = COMPRESSION_LZMA;
-
-
- // If we have the expected size of the decompressed payload, we can allocate
- // the right-sized buffer and do it. If we don't have that information, we'll
- // need to try decoding into a big buffer and if the buffer wasn't big enough,
- // increase it and try again.
-
- if (decompressed_bufsize != ULONG_MAX && decompressed_buffer != nullptr)
- {
- decompressed_bytes = compression_decode_buffer (decompressed_buffer, decompressed_bufsize + 10 ,
- (uint8_t*) unescaped_content.data(),
- unescaped_content.size(),
- NULL,
- compression_type);
- }
+ // Reverse the gdb-remote binary escaping that was done to the compressed text
+ // to
+ // guard characters like '$', '#', '}', etc.
+ std::vector<uint8_t> unescaped_content;
+ unescaped_content.reserve(content_length);
+ size_t i = content_start;
+ while (i < hash_mark_idx) {
+ if (m_bytes[i] == '}') {
+ i++;
+ unescaped_content.push_back(m_bytes[i] ^ 0x20);
+ } else {
+ unescaped_content.push_back(m_bytes[i]);
+ }
+ i++;
+ }
+
+ uint8_t *decompressed_buffer = nullptr;
+ size_t decompressed_bytes = 0;
+
+ if (decompressed_bufsize != ULONG_MAX) {
+ decompressed_buffer = (uint8_t *)malloc(decompressed_bufsize + 1);
+ if (decompressed_buffer == nullptr) {
+ m_bytes.erase(0, size_of_first_packet);
+ return false;
+ }
+ }
+
+#if defined(HAVE_LIBCOMPRESSION)
+ // libcompression is weak linked so check that compression_decode_buffer() is
+ // available
+ if (compression_decode_buffer != NULL &&
+ (m_compression_type == CompressionType::ZlibDeflate ||
+ m_compression_type == CompressionType::LZFSE ||
+ m_compression_type == CompressionType::LZ4)) {
+ compression_algorithm compression_type;
+ if (m_compression_type == CompressionType::ZlibDeflate)
+ compression_type = COMPRESSION_ZLIB;
+ else if (m_compression_type == CompressionType::LZFSE)
+ compression_type = COMPRESSION_LZFSE;
+ else if (m_compression_type == CompressionType::LZ4)
+ compression_type = COMPRESSION_LZ4_RAW;
+ else if (m_compression_type == CompressionType::LZMA)
+ compression_type = COMPRESSION_LZMA;
+
+ // If we have the expected size of the decompressed payload, we can allocate
+ // the right-sized buffer and do it. If we don't have that information,
+ // we'll
+ // need to try decoding into a big buffer and if the buffer wasn't big
+ // enough,
+ // increase it and try again.
+
+ if (decompressed_bufsize != ULONG_MAX && decompressed_buffer != nullptr) {
+ decompressed_bytes = compression_decode_buffer(
+ decompressed_buffer, decompressed_bufsize + 10,
+ (uint8_t *)unescaped_content.data(), unescaped_content.size(), NULL,
+ compression_type);
}
+ }
#endif
-#if defined (HAVE_LIBZ)
- if (decompressed_bytes == 0
- && decompressed_bufsize != ULONG_MAX
- && decompressed_buffer != nullptr
- && m_compression_type == CompressionType::ZlibDeflate)
- {
- z_stream stream;
- memset (&stream, 0, sizeof (z_stream));
- stream.next_in = (Bytef *) unescaped_content.data();
- stream.avail_in = (uInt) unescaped_content.size();
- stream.total_in = 0;
- stream.next_out = (Bytef *) decompressed_buffer;
- stream.avail_out = decompressed_bufsize;
- stream.total_out = 0;
- stream.zalloc = Z_NULL;
- stream.zfree = Z_NULL;
- stream.opaque = Z_NULL;
-
- if (inflateInit2 (&stream, -15) == Z_OK)
- {
- int status = inflate (&stream, Z_NO_FLUSH);
- inflateEnd (&stream);
- if (status == Z_STREAM_END)
- {
- decompressed_bytes = stream.total_out;
- }
- }
+#if defined(HAVE_LIBZ)
+ if (decompressed_bytes == 0 && decompressed_bufsize != ULONG_MAX &&
+ decompressed_buffer != nullptr &&
+ m_compression_type == CompressionType::ZlibDeflate) {
+ z_stream stream;
+ memset(&stream, 0, sizeof(z_stream));
+ stream.next_in = (Bytef *)unescaped_content.data();
+ stream.avail_in = (uInt)unescaped_content.size();
+ stream.total_in = 0;
+ stream.next_out = (Bytef *)decompressed_buffer;
+ stream.avail_out = decompressed_bufsize;
+ stream.total_out = 0;
+ stream.zalloc = Z_NULL;
+ stream.zfree = Z_NULL;
+ stream.opaque = Z_NULL;
+
+ if (inflateInit2(&stream, -15) == Z_OK) {
+ int status = inflate(&stream, Z_NO_FLUSH);
+ inflateEnd(&stream);
+ if (status == Z_STREAM_END) {
+ decompressed_bytes = stream.total_out;
+ }
}
+ }
#endif
- if (decompressed_bytes == 0 || decompressed_buffer == nullptr)
- {
- if (decompressed_buffer)
- free (decompressed_buffer);
- m_bytes.erase (0, size_of_first_packet);
- return false;
- }
-
- std::string new_packet;
- new_packet.reserve (decompressed_bytes + 6);
- new_packet.push_back (m_bytes[0]);
- new_packet.append ((const char *) decompressed_buffer, decompressed_bytes);
- new_packet.push_back ('#');
- if (GetSendAcks ())
- {
- uint8_t decompressed_checksum = CalculcateChecksum (llvm::StringRef((const char *) decompressed_buffer, decompressed_bytes));
- char decompressed_checksum_str[3];
- snprintf (decompressed_checksum_str, 3, "%02x", decompressed_checksum);
- new_packet.append (decompressed_checksum_str);
- }
- else
- {
- new_packet.push_back ('0');
- new_packet.push_back ('0');
- }
+ if (decompressed_bytes == 0 || decompressed_buffer == nullptr) {
+ if (decompressed_buffer)
+ free(decompressed_buffer);
+ m_bytes.erase(0, size_of_first_packet);
+ return false;
+ }
+
+ std::string new_packet;
+ new_packet.reserve(decompressed_bytes + 6);
+ new_packet.push_back(m_bytes[0]);
+ new_packet.append((const char *)decompressed_buffer, decompressed_bytes);
+ new_packet.push_back('#');
+ if (GetSendAcks()) {
+ uint8_t decompressed_checksum = CalculcateChecksum(
+ llvm::StringRef((const char *)decompressed_buffer, decompressed_bytes));
+ char decompressed_checksum_str[3];
+ snprintf(decompressed_checksum_str, 3, "%02x", decompressed_checksum);
+ new_packet.append(decompressed_checksum_str);
+ } else {
+ new_packet.push_back('0');
+ new_packet.push_back('0');
+ }
- m_bytes.replace (0, size_of_first_packet, new_packet.data(), new_packet.size());
+ m_bytes.replace(0, size_of_first_packet, new_packet.data(),
+ new_packet.size());
- free (decompressed_buffer);
- return true;
+ free(decompressed_buffer);
+ return true;
}
GDBRemoteCommunication::PacketType
-GDBRemoteCommunication::CheckForPacket (const uint8_t *src, size_t src_len, StringExtractorGDBRemote &packet)
-{
- // Put the packet data into the buffer in a thread safe fashion
- std::lock_guard<std::recursive_mutex> guard(m_bytes_mutex);
-
- Log *log (ProcessGDBRemoteLog::GetLogIfAllCategoriesSet (GDBR_LOG_PACKETS));
-
- if (src && src_len > 0)
- {
- if (log && log->GetVerbose())
- {
- StreamString s;
- log->Printf ("GDBRemoteCommunication::%s adding %u bytes: %.*s",
- __FUNCTION__,
- (uint32_t)src_len,
- (uint32_t)src_len,
- src);
- }
- m_bytes.append ((const char *)src, src_len);
- }
-
- bool isNotifyPacket = false;
-
- // Parse up the packets into gdb remote packets
- if (!m_bytes.empty())
- {
- // end_idx must be one past the last valid packet byte. Start
- // it off with an invalid value that is the same as the current
- // index.
- size_t content_start = 0;
- size_t content_length = 0;
- size_t total_length = 0;
- size_t checksum_idx = std::string::npos;
-
- // Size of packet before it is decompressed, for logging purposes
- size_t original_packet_size = m_bytes.size();
- if (CompressionIsEnabled())
- {
- if (DecompressPacket() == false)
- {
- packet.Clear();
- return GDBRemoteCommunication::PacketType::Standard;
+GDBRemoteCommunication::CheckForPacket(const uint8_t *src, size_t src_len,
+ StringExtractorGDBRemote &packet) {
+ // Put the packet data into the buffer in a thread safe fashion
+ std::lock_guard<std::recursive_mutex> guard(m_bytes_mutex);
+
+ Log *log(ProcessGDBRemoteLog::GetLogIfAllCategoriesSet(GDBR_LOG_PACKETS));
+
+ if (src && src_len > 0) {
+ if (log && log->GetVerbose()) {
+ StreamString s;
+ log->Printf("GDBRemoteCommunication::%s adding %u bytes: %.*s",
+ __FUNCTION__, (uint32_t)src_len, (uint32_t)src_len, src);
+ }
+ m_bytes.append((const char *)src, src_len);
+ }
+
+ bool isNotifyPacket = false;
+
+ // Parse up the packets into gdb remote packets
+ if (!m_bytes.empty()) {
+ // end_idx must be one past the last valid packet byte. Start
+ // it off with an invalid value that is the same as the current
+ // index.
+ size_t content_start = 0;
+ size_t content_length = 0;
+ size_t total_length = 0;
+ size_t checksum_idx = std::string::npos;
+
+ // Size of packet before it is decompressed, for logging purposes
+ size_t original_packet_size = m_bytes.size();
+ if (CompressionIsEnabled()) {
+ if (DecompressPacket() == false) {
+ packet.Clear();
+ return GDBRemoteCommunication::PacketType::Standard;
+ }
+ }
+
+ switch (m_bytes[0]) {
+ case '+': // Look for ack
+ case '-': // Look for cancel
+ case '\x03': // ^C to halt target
+ content_length = total_length = 1; // The command is one byte long...
+ break;
+
+ case '%': // Async notify packet
+ isNotifyPacket = true;
+ LLVM_FALLTHROUGH;
+
+ case '$':
+ // Look for a standard gdb packet?
+ {
+ size_t hash_pos = m_bytes.find('#');
+ if (hash_pos != std::string::npos) {
+ if (hash_pos + 2 < m_bytes.size()) {
+ checksum_idx = hash_pos + 1;
+ // Skip the dollar sign
+ content_start = 1;
+ // Don't include the # in the content or the $ in the content length
+ content_length = hash_pos - 1;
+
+ total_length =
+ hash_pos + 3; // Skip the # and the two hex checksum bytes
+ } else {
+ // Checksum bytes aren't all here yet
+ content_length = std::string::npos;
+ }
+ }
+ }
+ break;
+
+ default: {
+ // We have an unexpected byte and we need to flush all bad
+ // data that is in m_bytes, so we need to find the first
+ // byte that is a '+' (ACK), '-' (NACK), \x03 (CTRL+C interrupt),
+ // or '$' character (start of packet header) or of course,
+ // the end of the data in m_bytes...
+ const size_t bytes_len = m_bytes.size();
+ bool done = false;
+ uint32_t idx;
+ for (idx = 1; !done && idx < bytes_len; ++idx) {
+ switch (m_bytes[idx]) {
+ case '+':
+ case '-':
+ case '\x03':
+ case '%':
+ case '$':
+ done = true;
+ break;
+
+ default:
+ break;
+ }
+ }
+ if (log)
+ log->Printf("GDBRemoteCommunication::%s tossing %u junk bytes: '%.*s'",
+ __FUNCTION__, idx - 1, idx - 1, m_bytes.c_str());
+ m_bytes.erase(0, idx - 1);
+ } break;
+ }
+
+ if (content_length == std::string::npos) {
+ packet.Clear();
+ return GDBRemoteCommunication::PacketType::Invalid;
+ } else if (total_length > 0) {
+
+ // We have a valid packet...
+ assert(content_length <= m_bytes.size());
+ assert(total_length <= m_bytes.size());
+ assert(content_length <= total_length);
+ size_t content_end = content_start + content_length;
+
+ bool success = true;
+ std::string &packet_str = packet.GetStringRef();
+ if (log) {
+ // If logging was just enabled and we have history, then dump out what
+ // we have to the log so we get the historical context. The Dump() call
+ // that
+ // logs all of the packet will set a boolean so that we don't dump this
+ // more
+ // than once
+ if (!m_history.DidDumpToLog())
+ m_history.Dump(log);
+
+ bool binary = false;
+ // Only detect binary for packets that start with a '$' and have a '#CC'
+ // checksum
+ if (m_bytes[0] == '$' && total_length > 4) {
+ for (size_t i = 0; !binary && i < total_length; ++i) {
+ if (isprint(m_bytes[i]) == 0 && isspace(m_bytes[i]) == 0) {
+ binary = true;
}
+ }
}
-
- switch (m_bytes[0])
- {
- case '+': // Look for ack
- case '-': // Look for cancel
- case '\x03': // ^C to halt target
- content_length = total_length = 1; // The command is one byte long...
- break;
-
- case '%': // Async notify packet
- isNotifyPacket = true;
- LLVM_FALLTHROUGH;
-
- case '$':
- // Look for a standard gdb packet?
- {
- size_t hash_pos = m_bytes.find('#');
- if (hash_pos != std::string::npos)
- {
- if (hash_pos + 2 < m_bytes.size())
- {
- checksum_idx = hash_pos + 1;
- // Skip the dollar sign
- content_start = 1;
- // Don't include the # in the content or the $ in the content length
- content_length = hash_pos - 1;
-
- total_length = hash_pos + 3; // Skip the # and the two hex checksum bytes
- }
- else
- {
- // Checksum bytes aren't all here yet
- content_length = std::string::npos;
- }
- }
- }
- break;
-
- default:
- {
- // We have an unexpected byte and we need to flush all bad
- // data that is in m_bytes, so we need to find the first
- // byte that is a '+' (ACK), '-' (NACK), \x03 (CTRL+C interrupt),
- // or '$' character (start of packet header) or of course,
- // the end of the data in m_bytes...
- const size_t bytes_len = m_bytes.size();
- bool done = false;
- uint32_t idx;
- for (idx = 1; !done && idx < bytes_len; ++idx)
- {
- switch (m_bytes[idx])
- {
- case '+':
- case '-':
- case '\x03':
- case '%':
- case '$':
- done = true;
- break;
-
- default:
- break;
- }
- }
- if (log)
- log->Printf ("GDBRemoteCommunication::%s tossing %u junk bytes: '%.*s'",
- __FUNCTION__, idx - 1, idx - 1, m_bytes.c_str());
- m_bytes.erase(0, idx - 1);
- }
- break;
- }
-
- if (content_length == std::string::npos)
- {
- packet.Clear();
- return GDBRemoteCommunication::PacketType::Invalid;
- }
- else if (total_length > 0)
- {
-
- // We have a valid packet...
- assert (content_length <= m_bytes.size());
- assert (total_length <= m_bytes.size());
- assert (content_length <= total_length);
- size_t content_end = content_start + content_length;
-
- bool success = true;
- std::string &packet_str = packet.GetStringRef();
- if (log)
- {
- // If logging was just enabled and we have history, then dump out what
- // we have to the log so we get the historical context. The Dump() call that
- // logs all of the packet will set a boolean so that we don't dump this more
- // than once
- if (!m_history.DidDumpToLog ())
- m_history.Dump (log);
-
- bool binary = false;
- // Only detect binary for packets that start with a '$' and have a '#CC' checksum
- if (m_bytes[0] == '$' && total_length > 4)
- {
- for (size_t i=0; !binary && i<total_length; ++i)
- {
- if (isprint (m_bytes[i]) == 0 && isspace (m_bytes[i]) == 0)
- {
- binary = true;
- }
- }
- }
- if (binary)
- {
- StreamString strm;
- // Packet header...
- if (CompressionIsEnabled())
- strm.Printf("<%4" PRIu64 ":%" PRIu64 "> read packet: %c", (uint64_t) original_packet_size, (uint64_t)total_length, m_bytes[0]);
- else
- strm.Printf("<%4" PRIu64 "> read packet: %c", (uint64_t)total_length, m_bytes[0]);
- for (size_t i=content_start; i<content_end; ++i)
- {
- // Remove binary escaped bytes when displaying the packet...
- const char ch = m_bytes[i];
- if (ch == 0x7d)
- {
- // 0x7d is the escape character. The next character is to
- // be XOR'd with 0x20.
- const char escapee = m_bytes[++i] ^ 0x20;
- strm.Printf("%2.2x", escapee);
- }
- else
- {
- strm.Printf("%2.2x", (uint8_t)ch);
- }
- }
- // Packet footer...
- strm.Printf("%c%c%c", m_bytes[total_length-3], m_bytes[total_length-2], m_bytes[total_length-1]);
- log->PutCString(strm.GetString().c_str());
- }
- else
- {
- if (CompressionIsEnabled())
- log->Printf("<%4" PRIu64 ":%" PRIu64 "> read packet: %.*s", (uint64_t) original_packet_size, (uint64_t)total_length, (int)(total_length), m_bytes.c_str());
- else
- log->Printf("<%4" PRIu64 "> read packet: %.*s", (uint64_t)total_length, (int)(total_length), m_bytes.c_str());
- }
- }
-
- m_history.AddPacket (m_bytes.c_str(), total_length, History::ePacketTypeRecv, total_length);
-
- // Clear packet_str in case there is some existing data in it.
- packet_str.clear();
- // Copy the packet from m_bytes to packet_str expanding the
- // run-length encoding in the process.
- // Reserve enough byte for the most common case (no RLE used)
- packet_str.reserve(m_bytes.length());
- for (std::string::const_iterator c = m_bytes.begin() + content_start; c != m_bytes.begin() + content_end; ++c)
- {
- if (*c == '*')
- {
- // '*' indicates RLE. Next character will give us the
- // repeat count and previous character is what is to be
- // repeated.
- char char_to_repeat = packet_str.back();
- // Number of time the previous character is repeated
- int repeat_count = *++c + 3 - ' ';
- // We have the char_to_repeat and repeat_count. Now push
- // it in the packet.
- for (int i = 0; i < repeat_count; ++i)
- packet_str.push_back(char_to_repeat);
- }
- else if (*c == 0x7d)
- {
- // 0x7d is the escape character. The next character is to
- // be XOR'd with 0x20.
- char escapee = *++c ^ 0x20;
- packet_str.push_back(escapee);
- }
- else
- {
- packet_str.push_back(*c);
- }
+ if (binary) {
+ StreamString strm;
+ // Packet header...
+ if (CompressionIsEnabled())
+ strm.Printf("<%4" PRIu64 ":%" PRIu64 "> read packet: %c",
+ (uint64_t)original_packet_size, (uint64_t)total_length,
+ m_bytes[0]);
+ else
+ strm.Printf("<%4" PRIu64 "> read packet: %c",
+ (uint64_t)total_length, m_bytes[0]);
+ for (size_t i = content_start; i < content_end; ++i) {
+ // Remove binary escaped bytes when displaying the packet...
+ const char ch = m_bytes[i];
+ if (ch == 0x7d) {
+ // 0x7d is the escape character. The next character is to
+ // be XOR'd with 0x20.
+ const char escapee = m_bytes[++i] ^ 0x20;
+ strm.Printf("%2.2x", escapee);
+ } else {
+ strm.Printf("%2.2x", (uint8_t)ch);
}
-
- if (m_bytes[0] == '$' || m_bytes[0] == '%')
- {
- assert (checksum_idx < m_bytes.size());
- if (::isxdigit (m_bytes[checksum_idx+0]) ||
- ::isxdigit (m_bytes[checksum_idx+1]))
- {
- if (GetSendAcks ())
- {
- const char *packet_checksum_cstr = &m_bytes[checksum_idx];
- char packet_checksum = strtol (packet_checksum_cstr, NULL, 16);
- char actual_checksum = CalculcateChecksum (packet_str);
- success = packet_checksum == actual_checksum;
- if (!success)
- {
- if (log)
- log->Printf ("error: checksum mismatch: %.*s expected 0x%2.2x, got 0x%2.2x",
- (int)(total_length),
- m_bytes.c_str(),
- (uint8_t)packet_checksum,
- (uint8_t)actual_checksum);
- }
- // Send the ack or nack if needed
- if (!success)
- SendNack();
- else
- SendAck();
- }
- }
- else
- {
- success = false;
- if (log)
- log->Printf ("error: invalid checksum in packet: '%s'\n", m_bytes.c_str());
- }
+ }
+ // Packet footer...
+ strm.Printf("%c%c%c", m_bytes[total_length - 3],
+ m_bytes[total_length - 2], m_bytes[total_length - 1]);
+ log->PutCString(strm.GetString().c_str());
+ } else {
+ if (CompressionIsEnabled())
+ log->Printf("<%4" PRIu64 ":%" PRIu64 "> read packet: %.*s",
+ (uint64_t)original_packet_size, (uint64_t)total_length,
+ (int)(total_length), m_bytes.c_str());
+ else
+ log->Printf("<%4" PRIu64 "> read packet: %.*s",
+ (uint64_t)total_length, (int)(total_length),
+ m_bytes.c_str());
+ }
+ }
+
+ m_history.AddPacket(m_bytes.c_str(), total_length,
+ History::ePacketTypeRecv, total_length);
+
+ // Clear packet_str in case there is some existing data in it.
+ packet_str.clear();
+ // Copy the packet from m_bytes to packet_str expanding the
+ // run-length encoding in the process.
+ // Reserve enough byte for the most common case (no RLE used)
+ packet_str.reserve(m_bytes.length());
+ for (std::string::const_iterator c = m_bytes.begin() + content_start;
+ c != m_bytes.begin() + content_end; ++c) {
+ if (*c == '*') {
+ // '*' indicates RLE. Next character will give us the
+ // repeat count and previous character is what is to be
+ // repeated.
+ char char_to_repeat = packet_str.back();
+ // Number of time the previous character is repeated
+ int repeat_count = *++c + 3 - ' ';
+ // We have the char_to_repeat and repeat_count. Now push
+ // it in the packet.
+ for (int i = 0; i < repeat_count; ++i)
+ packet_str.push_back(char_to_repeat);
+ } else if (*c == 0x7d) {
+ // 0x7d is the escape character. The next character is to
+ // be XOR'd with 0x20.
+ char escapee = *++c ^ 0x20;
+ packet_str.push_back(escapee);
+ } else {
+ packet_str.push_back(*c);
+ }
+ }
+
+ if (m_bytes[0] == '$' || m_bytes[0] == '%') {
+ assert(checksum_idx < m_bytes.size());
+ if (::isxdigit(m_bytes[checksum_idx + 0]) ||
+ ::isxdigit(m_bytes[checksum_idx + 1])) {
+ if (GetSendAcks()) {
+ const char *packet_checksum_cstr = &m_bytes[checksum_idx];
+ char packet_checksum = strtol(packet_checksum_cstr, NULL, 16);
+ char actual_checksum = CalculcateChecksum(packet_str);
+ success = packet_checksum == actual_checksum;
+ if (!success) {
+ if (log)
+ log->Printf("error: checksum mismatch: %.*s expected 0x%2.2x, "
+ "got 0x%2.2x",
+ (int)(total_length), m_bytes.c_str(),
+ (uint8_t)packet_checksum, (uint8_t)actual_checksum);
}
-
- m_bytes.erase(0, total_length);
- packet.SetFilePos(0);
-
- if (isNotifyPacket)
- return GDBRemoteCommunication::PacketType::Notify;
+ // Send the ack or nack if needed
+ if (!success)
+ SendNack();
else
- return GDBRemoteCommunication::PacketType::Standard;
- }
- }
- packet.Clear();
- return GDBRemoteCommunication::PacketType::Invalid;
+ SendAck();
+ }
+ } else {
+ success = false;
+ if (log)
+ log->Printf("error: invalid checksum in packet: '%s'\n",
+ m_bytes.c_str());
+ }
+ }
+
+ m_bytes.erase(0, total_length);
+ packet.SetFilePos(0);
+
+ if (isNotifyPacket)
+ return GDBRemoteCommunication::PacketType::Notify;
+ else
+ return GDBRemoteCommunication::PacketType::Standard;
+ }
+ }
+ packet.Clear();
+ return GDBRemoteCommunication::PacketType::Invalid;
+}
+
+Error GDBRemoteCommunication::StartListenThread(const char *hostname,
+ uint16_t port) {
+ Error error;
+ if (m_listen_thread.IsJoinable()) {
+ error.SetErrorString("listen thread already running");
+ } else {
+ char listen_url[512];
+ if (hostname && hostname[0])
+ snprintf(listen_url, sizeof(listen_url), "listen://%s:%i", hostname,
+ port);
+ else
+ snprintf(listen_url, sizeof(listen_url), "listen://%i", port);
+ m_listen_url = listen_url;
+ SetConnection(new ConnectionFileDescriptor());
+ m_listen_thread = ThreadLauncher::LaunchThread(
+ listen_url, GDBRemoteCommunication::ListenThread, this, &error);
+ }
+ return error;
}
-Error
-GDBRemoteCommunication::StartListenThread (const char *hostname, uint16_t port)
-{
- Error error;
- if (m_listen_thread.IsJoinable())
- {
- error.SetErrorString("listen thread already running");
- }
- else
- {
- char listen_url[512];
- if (hostname && hostname[0])
- snprintf(listen_url, sizeof(listen_url), "listen://%s:%i", hostname, port);
- else
- snprintf(listen_url, sizeof(listen_url), "listen://%i", port);
- m_listen_url = listen_url;
- SetConnection(new ConnectionFileDescriptor());
- m_listen_thread = ThreadLauncher::LaunchThread(listen_url, GDBRemoteCommunication::ListenThread, this, &error);
- }
- return error;
-}
-
-bool
-GDBRemoteCommunication::JoinListenThread ()
-{
- if (m_listen_thread.IsJoinable())
- m_listen_thread.Join(nullptr);
- return true;
+bool GDBRemoteCommunication::JoinListenThread() {
+ if (m_listen_thread.IsJoinable())
+ m_listen_thread.Join(nullptr);
+ return true;
}
lldb::thread_result_t
-GDBRemoteCommunication::ListenThread (lldb::thread_arg_t arg)
-{
- GDBRemoteCommunication *comm = (GDBRemoteCommunication *)arg;
- Error error;
- ConnectionFileDescriptor *connection = (ConnectionFileDescriptor *)comm->GetConnection ();
-
- if (connection)
- {
- // Do the listen on another thread so we can continue on...
- if (connection->Connect(comm->m_listen_url.c_str(), &error) != eConnectionStatusSuccess)
- comm->SetConnection(NULL);
- }
- return NULL;
-}
-
-Error
-GDBRemoteCommunication::StartDebugserverProcess (const char *url,
- Platform *platform,
- ProcessLaunchInfo &launch_info,
- uint16_t *port,
- const Args* inferior_args,
- int pass_comm_fd)
-{
- Log *log (ProcessGDBRemoteLog::GetLogIfAllCategoriesSet (GDBR_LOG_PROCESS));
+GDBRemoteCommunication::ListenThread(lldb::thread_arg_t arg) {
+ GDBRemoteCommunication *comm = (GDBRemoteCommunication *)arg;
+ Error error;
+ ConnectionFileDescriptor *connection =
+ (ConnectionFileDescriptor *)comm->GetConnection();
+
+ if (connection) {
+ // Do the listen on another thread so we can continue on...
+ if (connection->Connect(comm->m_listen_url.c_str(), &error) !=
+ eConnectionStatusSuccess)
+ comm->SetConnection(NULL);
+ }
+ return NULL;
+}
+
+Error GDBRemoteCommunication::StartDebugserverProcess(
+ const char *url, Platform *platform, ProcessLaunchInfo &launch_info,
+ uint16_t *port, const Args *inferior_args, int pass_comm_fd) {
+ Log *log(ProcessGDBRemoteLog::GetLogIfAllCategoriesSet(GDBR_LOG_PROCESS));
+ if (log)
+ log->Printf("GDBRemoteCommunication::%s(url=%s, port=%" PRIu16 ")",
+ __FUNCTION__, url ? url : "<empty>",
+ port ? *port : uint16_t(0));
+
+ Error error;
+ // If we locate debugserver, keep that located version around
+ static FileSpec g_debugserver_file_spec;
+
+ char debugserver_path[PATH_MAX];
+ FileSpec &debugserver_file_spec = launch_info.GetExecutableFile();
+
+ // Always check to see if we have an environment override for the path
+ // to the debugserver to use and use it if we do.
+ const char *env_debugserver_path = getenv("LLDB_DEBUGSERVER_PATH");
+ if (env_debugserver_path) {
+ debugserver_file_spec.SetFile(env_debugserver_path, false);
if (log)
- log->Printf ("GDBRemoteCommunication::%s(url=%s, port=%" PRIu16 ")", __FUNCTION__, url ? url : "<empty>", port ? *port : uint16_t(0));
-
- Error error;
- // If we locate debugserver, keep that located version around
- static FileSpec g_debugserver_file_spec;
-
- char debugserver_path[PATH_MAX];
- FileSpec &debugserver_file_spec = launch_info.GetExecutableFile();
-
- // Always check to see if we have an environment override for the path
- // to the debugserver to use and use it if we do.
- const char *env_debugserver_path = getenv("LLDB_DEBUGSERVER_PATH");
- if (env_debugserver_path)
- {
- debugserver_file_spec.SetFile (env_debugserver_path, false);
+ log->Printf("GDBRemoteCommunication::%s() gdb-remote stub exe path set "
+ "from environment variable: %s",
+ __FUNCTION__, env_debugserver_path);
+ } else
+ debugserver_file_spec = g_debugserver_file_spec;
+ bool debugserver_exists = debugserver_file_spec.Exists();
+ if (!debugserver_exists) {
+ // The debugserver binary is in the LLDB.framework/Resources
+ // directory.
+ if (HostInfo::GetLLDBPath(ePathTypeSupportExecutableDir,
+ debugserver_file_spec)) {
+ debugserver_file_spec.AppendPathComponent(DEBUGSERVER_BASENAME);
+ debugserver_exists = debugserver_file_spec.Exists();
+ if (debugserver_exists) {
if (log)
- log->Printf ("GDBRemoteCommunication::%s() gdb-remote stub exe path set from environment variable: %s", __FUNCTION__, env_debugserver_path);
- }
- else
- debugserver_file_spec = g_debugserver_file_spec;
- bool debugserver_exists = debugserver_file_spec.Exists();
- if (!debugserver_exists)
- {
- // The debugserver binary is in the LLDB.framework/Resources
- // directory.
- if (HostInfo::GetLLDBPath(ePathTypeSupportExecutableDir, debugserver_file_spec))
- {
- debugserver_file_spec.AppendPathComponent (DEBUGSERVER_BASENAME);
- debugserver_exists = debugserver_file_spec.Exists();
- if (debugserver_exists)
- {
- if (log)
- log->Printf ("GDBRemoteCommunication::%s() found gdb-remote stub exe '%s'", __FUNCTION__, debugserver_file_spec.GetPath ().c_str ());
-
- g_debugserver_file_spec = debugserver_file_spec;
- }
- else
- {
- debugserver_file_spec = platform->LocateExecutable(DEBUGSERVER_BASENAME);
- if (debugserver_file_spec)
- {
- // Platform::LocateExecutable() wouldn't return a path if it doesn't exist
- debugserver_exists = true;
- }
- else
- {
- if (log)
- log->Printf ("GDBRemoteCommunication::%s() could not find gdb-remote stub exe '%s'", __FUNCTION__, debugserver_file_spec.GetPath ().c_str ());
- }
- // Don't cache the platform specific GDB server binary as it could change
- // from platform to platform
- g_debugserver_file_spec.Clear();
- }
- }
- }
-
- if (debugserver_exists)
- {
- debugserver_file_spec.GetPath (debugserver_path, sizeof(debugserver_path));
+ log->Printf(
+ "GDBRemoteCommunication::%s() found gdb-remote stub exe '%s'",
+ __FUNCTION__, debugserver_file_spec.GetPath().c_str());
+
+ g_debugserver_file_spec = debugserver_file_spec;
+ } else {
+ debugserver_file_spec =
+ platform->LocateExecutable(DEBUGSERVER_BASENAME);
+ if (debugserver_file_spec) {
+ // Platform::LocateExecutable() wouldn't return a path if it doesn't
+ // exist
+ debugserver_exists = true;
+ } else {
+ if (log)
+ log->Printf("GDBRemoteCommunication::%s() could not find "
+ "gdb-remote stub exe '%s'",
+ __FUNCTION__, debugserver_file_spec.GetPath().c_str());
+ }
+ // Don't cache the platform specific GDB server binary as it could
+ // change
+ // from platform to platform
+ g_debugserver_file_spec.Clear();
+ }
+ }
+ }
+
+ if (debugserver_exists) {
+ debugserver_file_spec.GetPath(debugserver_path, sizeof(debugserver_path));
+
+ Args &debugserver_args = launch_info.GetArguments();
+ debugserver_args.Clear();
+ char arg_cstr[PATH_MAX];
- Args &debugserver_args = launch_info.GetArguments();
- debugserver_args.Clear();
- char arg_cstr[PATH_MAX];
-
- // Start args with "debugserver /file/path -r --"
- debugserver_args.AppendArgument(debugserver_path);
+ // Start args with "debugserver /file/path -r --"
+ debugserver_args.AppendArgument(debugserver_path);
#if !defined(__APPLE__)
- // First argument to lldb-server must be mode in which to run.
- debugserver_args.AppendArgument("gdbserver");
+ // First argument to lldb-server must be mode in which to run.
+ debugserver_args.AppendArgument("gdbserver");
#endif
- // If a url is supplied then use it
- if (url)
- debugserver_args.AppendArgument(url);
-
- if (pass_comm_fd >= 0)
- {
- StreamString fd_arg;
- fd_arg.Printf("--fd=%i", pass_comm_fd);
- debugserver_args.AppendArgument(fd_arg.GetData());
- // Send "pass_comm_fd" down to the inferior so it can use it to
- // communicate back with this process
- launch_info.AppendDuplicateFileAction(pass_comm_fd, pass_comm_fd);
- }
-
- // use native registers, not the GDB registers
- debugserver_args.AppendArgument("--native-regs");
-
- if (launch_info.GetLaunchInSeparateProcessGroup())
- {
- debugserver_args.AppendArgument("--setsid");
- }
+ // If a url is supplied then use it
+ if (url)
+ debugserver_args.AppendArgument(url);
+
+ if (pass_comm_fd >= 0) {
+ StreamString fd_arg;
+ fd_arg.Printf("--fd=%i", pass_comm_fd);
+ debugserver_args.AppendArgument(fd_arg.GetData());
+ // Send "pass_comm_fd" down to the inferior so it can use it to
+ // communicate back with this process
+ launch_info.AppendDuplicateFileAction(pass_comm_fd, pass_comm_fd);
+ }
+
+ // use native registers, not the GDB registers
+ debugserver_args.AppendArgument("--native-regs");
+
+ if (launch_info.GetLaunchInSeparateProcessGroup()) {
+ debugserver_args.AppendArgument("--setsid");
+ }
+
+ llvm::SmallString<PATH_MAX> named_pipe_path;
+ // socket_pipe is used by debug server to communicate back either
+ // TCP port or domain socket name which it listens on.
+ // The second purpose of the pipe to serve as a synchronization point -
+ // once data is written to the pipe, debug server is up and running.
+ Pipe socket_pipe;
+
+ // port is null when debug server should listen on domain socket -
+ // we're not interested in port value but rather waiting for debug server
+ // to become available.
+ if (pass_comm_fd == -1 &&
+ ((port != nullptr && *port == 0) || port == nullptr)) {
+ if (url) {
+// Create a temporary file to get the stdout/stderr and redirect the
+// output of the command into this file. We will later read this file
+// if all goes well and fill the data into "command_output_ptr"
- llvm::SmallString<PATH_MAX> named_pipe_path;
- // socket_pipe is used by debug server to communicate back either
- // TCP port or domain socket name which it listens on.
- // The second purpose of the pipe to serve as a synchronization point -
- // once data is written to the pipe, debug server is up and running.
- Pipe socket_pipe;
-
- // port is null when debug server should listen on domain socket -
- // we're not interested in port value but rather waiting for debug server
- // to become available.
- if (pass_comm_fd == -1 && ((port != nullptr && *port == 0) || port == nullptr))
- {
- if (url)
- {
- // Create a temporary file to get the stdout/stderr and redirect the
- // output of the command into this file. We will later read this file
- // if all goes well and fill the data into "command_output_ptr"
-
#if defined(__APPLE__)
- // Binding to port zero, we need to figure out what port it ends up
- // using using a named pipe...
- error = socket_pipe.CreateWithUniqueName("debugserver-named-pipe", false, named_pipe_path);
- if (error.Fail())
- {
- if (log)
- log->Printf("GDBRemoteCommunication::%s() "
- "named pipe creation failed: %s",
- __FUNCTION__, error.AsCString());
- return error;
- }
- debugserver_args.AppendArgument("--named-pipe");
- debugserver_args.AppendArgument(named_pipe_path.c_str());
+ // Binding to port zero, we need to figure out what port it ends up
+ // using using a named pipe...
+ error = socket_pipe.CreateWithUniqueName("debugserver-named-pipe",
+ false, named_pipe_path);
+ if (error.Fail()) {
+ if (log)
+ log->Printf("GDBRemoteCommunication::%s() "
+ "named pipe creation failed: %s",
+ __FUNCTION__, error.AsCString());
+ return error;
+ }
+ debugserver_args.AppendArgument("--named-pipe");
+ debugserver_args.AppendArgument(named_pipe_path.c_str());
#else
- // Binding to port zero, we need to figure out what port it ends up
- // using using an unnamed pipe...
- error = socket_pipe.CreateNew(true);
- if (error.Fail())
- {
- if (log)
- log->Printf("GDBRemoteCommunication::%s() "
- "unnamed pipe creation failed: %s",
- __FUNCTION__, error.AsCString());
- return error;
- }
- int write_fd = socket_pipe.GetWriteFileDescriptor();
- debugserver_args.AppendArgument("--pipe");
- debugserver_args.AppendArgument(llvm::to_string(write_fd).c_str());
- launch_info.AppendCloseFileAction(socket_pipe.GetReadFileDescriptor());
+ // Binding to port zero, we need to figure out what port it ends up
+ // using using an unnamed pipe...
+ error = socket_pipe.CreateNew(true);
+ if (error.Fail()) {
+ if (log)
+ log->Printf("GDBRemoteCommunication::%s() "
+ "unnamed pipe creation failed: %s",
+ __FUNCTION__, error.AsCString());
+ return error;
+ }
+ int write_fd = socket_pipe.GetWriteFileDescriptor();
+ debugserver_args.AppendArgument("--pipe");
+ debugserver_args.AppendArgument(llvm::to_string(write_fd).c_str());
+ launch_info.AppendCloseFileAction(socket_pipe.GetReadFileDescriptor());
#endif
- }
- else
- {
- // No host and port given, so lets listen on our end and make the debugserver
- // connect to us..
- error = StartListenThread ("127.0.0.1", 0);
- if (error.Fail())
- {
- if (log)
- log->Printf ("GDBRemoteCommunication::%s() unable to start listen thread: %s", __FUNCTION__, error.AsCString());
- return error;
- }
-
- ConnectionFileDescriptor *connection = (ConnectionFileDescriptor *)GetConnection ();
- // Wait for 10 seconds to resolve the bound port
- uint16_t port_ = connection->GetListeningPort(10);
- if (port_ > 0)
- {
- char port_cstr[32];
- snprintf(port_cstr, sizeof(port_cstr), "127.0.0.1:%i", port_);
- // Send the host and port down that debugserver and specify an option
- // so that it connects back to the port we are listening to in this process
- debugserver_args.AppendArgument("--reverse-connect");
- debugserver_args.AppendArgument(port_cstr);
- if (port)
- *port = port_;
- }
- else
- {
- error.SetErrorString ("failed to bind to port 0 on 127.0.0.1");
- if (log)
- log->Printf ("GDBRemoteCommunication::%s() failed: %s", __FUNCTION__, error.AsCString());
- return error;
- }
- }
- }
-
- const char *env_debugserver_log_file = getenv("LLDB_DEBUGSERVER_LOG_FILE");
- if (env_debugserver_log_file)
- {
- ::snprintf (arg_cstr, sizeof(arg_cstr), "--log-file=%s", env_debugserver_log_file);
- debugserver_args.AppendArgument(arg_cstr);
- }
-
+ } else {
+ // No host and port given, so lets listen on our end and make the
+ // debugserver
+ // connect to us..
+ error = StartListenThread("127.0.0.1", 0);
+ if (error.Fail()) {
+ if (log)
+ log->Printf("GDBRemoteCommunication::%s() unable to start listen "
+ "thread: %s",
+ __FUNCTION__, error.AsCString());
+ return error;
+ }
+
+ ConnectionFileDescriptor *connection =
+ (ConnectionFileDescriptor *)GetConnection();
+ // Wait for 10 seconds to resolve the bound port
+ uint16_t port_ = connection->GetListeningPort(10);
+ if (port_ > 0) {
+ char port_cstr[32];
+ snprintf(port_cstr, sizeof(port_cstr), "127.0.0.1:%i", port_);
+ // Send the host and port down that debugserver and specify an option
+ // so that it connects back to the port we are listening to in this
+ // process
+ debugserver_args.AppendArgument("--reverse-connect");
+ debugserver_args.AppendArgument(port_cstr);
+ if (port)
+ *port = port_;
+ } else {
+ error.SetErrorString("failed to bind to port 0 on 127.0.0.1");
+ if (log)
+ log->Printf("GDBRemoteCommunication::%s() failed: %s", __FUNCTION__,
+ error.AsCString());
+ return error;
+ }
+ }
+ }
+
+ const char *env_debugserver_log_file = getenv("LLDB_DEBUGSERVER_LOG_FILE");
+ if (env_debugserver_log_file) {
+ ::snprintf(arg_cstr, sizeof(arg_cstr), "--log-file=%s",
+ env_debugserver_log_file);
+ debugserver_args.AppendArgument(arg_cstr);
+ }
+
#if defined(__APPLE__)
- const char *env_debugserver_log_flags = getenv("LLDB_DEBUGSERVER_LOG_FLAGS");
- if (env_debugserver_log_flags)
- {
- ::snprintf (arg_cstr, sizeof(arg_cstr), "--log-flags=%s", env_debugserver_log_flags);
- debugserver_args.AppendArgument(arg_cstr);
- }
+ const char *env_debugserver_log_flags =
+ getenv("LLDB_DEBUGSERVER_LOG_FLAGS");
+ if (env_debugserver_log_flags) {
+ ::snprintf(arg_cstr, sizeof(arg_cstr), "--log-flags=%s",
+ env_debugserver_log_flags);
+ debugserver_args.AppendArgument(arg_cstr);
+ }
#else
- const char *env_debugserver_log_channels = getenv("LLDB_SERVER_LOG_CHANNELS");
- if (env_debugserver_log_channels)
- {
- ::snprintf (arg_cstr, sizeof(arg_cstr), "--log-channels=%s", env_debugserver_log_channels);
- debugserver_args.AppendArgument(arg_cstr);
- }
+ const char *env_debugserver_log_channels =
+ getenv("LLDB_SERVER_LOG_CHANNELS");
+ if (env_debugserver_log_channels) {
+ ::snprintf(arg_cstr, sizeof(arg_cstr), "--log-channels=%s",
+ env_debugserver_log_channels);
+ debugserver_args.AppendArgument(arg_cstr);
+ }
#endif
- // Add additional args, starting with LLDB_DEBUGSERVER_EXTRA_ARG_1 until an env var doesn't come back.
- uint32_t env_var_index = 1;
- bool has_env_var;
- do
- {
- char env_var_name[64];
- snprintf (env_var_name, sizeof (env_var_name), "LLDB_DEBUGSERVER_EXTRA_ARG_%" PRIu32, env_var_index++);
- const char *extra_arg = getenv(env_var_name);
- has_env_var = extra_arg != nullptr;
-
- if (has_env_var)
- {
- debugserver_args.AppendArgument (extra_arg);
- if (log)
- log->Printf ("GDBRemoteCommunication::%s adding env var %s contents to stub command line (%s)", __FUNCTION__, env_var_name, extra_arg);
- }
- } while (has_env_var);
-
- if (inferior_args && inferior_args->GetArgumentCount() > 0)
- {
- debugserver_args.AppendArgument ("--");
- debugserver_args.AppendArguments (*inferior_args);
- }
-
- // Copy the current environment to the gdbserver/debugserver instance
- StringList env;
- if (Host::GetEnvironment(env))
- {
- for (size_t i = 0; i < env.GetSize(); ++i)
- launch_info.GetEnvironmentEntries().AppendArgument(env[i].c_str());
- }
-
- // Close STDIN, STDOUT and STDERR.
- launch_info.AppendCloseFileAction (STDIN_FILENO);
- launch_info.AppendCloseFileAction (STDOUT_FILENO);
- launch_info.AppendCloseFileAction (STDERR_FILENO);
-
- // Redirect STDIN, STDOUT and STDERR to "/dev/null".
- launch_info.AppendSuppressFileAction (STDIN_FILENO, true, false);
- launch_info.AppendSuppressFileAction (STDOUT_FILENO, false, true);
- launch_info.AppendSuppressFileAction (STDERR_FILENO, false, true);
+ // Add additional args, starting with LLDB_DEBUGSERVER_EXTRA_ARG_1 until an
+ // env var doesn't come back.
+ uint32_t env_var_index = 1;
+ bool has_env_var;
+ do {
+ char env_var_name[64];
+ snprintf(env_var_name, sizeof(env_var_name),
+ "LLDB_DEBUGSERVER_EXTRA_ARG_%" PRIu32, env_var_index++);
+ const char *extra_arg = getenv(env_var_name);
+ has_env_var = extra_arg != nullptr;
+ if (has_env_var) {
+ debugserver_args.AppendArgument(extra_arg);
if (log)
- {
- StreamString string_stream;
- Platform *const platform = nullptr;
- launch_info.Dump(string_stream, platform);
- log->Printf("launch info for gdb-remote stub:\n%s", string_stream.GetString().c_str());
- }
- error = Host::LaunchProcess(launch_info);
-
- if (error.Success() && (launch_info.GetProcessID() != LLDB_INVALID_PROCESS_ID) && pass_comm_fd == -1)
- {
- if (named_pipe_path.size() > 0)
- {
- error = socket_pipe.OpenAsReader(named_pipe_path, false);
- if (error.Fail())
- if (log)
- log->Printf("GDBRemoteCommunication::%s() "
- "failed to open named pipe %s for reading: %s",
- __FUNCTION__, named_pipe_path.c_str(), error.AsCString());
- }
-
- if (socket_pipe.CanWrite())
- socket_pipe.CloseWriteFileDescriptor();
- if (socket_pipe.CanRead())
- {
- char port_cstr[PATH_MAX] = {0};
- port_cstr[0] = '\0';
- size_t num_bytes = sizeof(port_cstr);
- // Read port from pipe with 10 second timeout.
- error = socket_pipe.ReadWithTimeout(port_cstr, num_bytes,
- std::chrono::seconds{10}, num_bytes);
- if (error.Success() && (port != nullptr))
- {
- assert(num_bytes > 0 && port_cstr[num_bytes-1] == '\0');
- *port = StringConvert::ToUInt32(port_cstr, 0);
- if (log)
- log->Printf("GDBRemoteCommunication::%s() "
- "debugserver listens %u port",
- __FUNCTION__, *port);
- }
- else
- {
- if (log)
- log->Printf("GDBRemoteCommunication::%s() "
- "failed to read a port value from pipe %s: %s",
- __FUNCTION__, named_pipe_path.c_str(), error.AsCString());
-
- }
- socket_pipe.Close();
- }
+ log->Printf("GDBRemoteCommunication::%s adding env var %s contents "
+ "to stub command line (%s)",
+ __FUNCTION__, env_var_name, extra_arg);
+ }
+ } while (has_env_var);
+
+ if (inferior_args && inferior_args->GetArgumentCount() > 0) {
+ debugserver_args.AppendArgument("--");
+ debugserver_args.AppendArguments(*inferior_args);
+ }
+
+ // Copy the current environment to the gdbserver/debugserver instance
+ StringList env;
+ if (Host::GetEnvironment(env)) {
+ for (size_t i = 0; i < env.GetSize(); ++i)
+ launch_info.GetEnvironmentEntries().AppendArgument(env[i].c_str());
+ }
+
+ // Close STDIN, STDOUT and STDERR.
+ launch_info.AppendCloseFileAction(STDIN_FILENO);
+ launch_info.AppendCloseFileAction(STDOUT_FILENO);
+ launch_info.AppendCloseFileAction(STDERR_FILENO);
+
+ // Redirect STDIN, STDOUT and STDERR to "/dev/null".
+ launch_info.AppendSuppressFileAction(STDIN_FILENO, true, false);
+ launch_info.AppendSuppressFileAction(STDOUT_FILENO, false, true);
+ launch_info.AppendSuppressFileAction(STDERR_FILENO, false, true);
+
+ if (log) {
+ StreamString string_stream;
+ Platform *const platform = nullptr;
+ launch_info.Dump(string_stream, platform);
+ log->Printf("launch info for gdb-remote stub:\n%s",
+ string_stream.GetString().c_str());
+ }
+ error = Host::LaunchProcess(launch_info);
+
+ if (error.Success() &&
+ (launch_info.GetProcessID() != LLDB_INVALID_PROCESS_ID) &&
+ pass_comm_fd == -1) {
+ if (named_pipe_path.size() > 0) {
+ error = socket_pipe.OpenAsReader(named_pipe_path, false);
+ if (error.Fail())
+ if (log)
+ log->Printf("GDBRemoteCommunication::%s() "
+ "failed to open named pipe %s for reading: %s",
+ __FUNCTION__, named_pipe_path.c_str(),
+ error.AsCString());
+ }
+
+ if (socket_pipe.CanWrite())
+ socket_pipe.CloseWriteFileDescriptor();
+ if (socket_pipe.CanRead()) {
+ char port_cstr[PATH_MAX] = {0};
+ port_cstr[0] = '\0';
+ size_t num_bytes = sizeof(port_cstr);
+ // Read port from pipe with 10 second timeout.
+ error = socket_pipe.ReadWithTimeout(
+ port_cstr, num_bytes, std::chrono::seconds{10}, num_bytes);
+ if (error.Success() && (port != nullptr)) {
+ assert(num_bytes > 0 && port_cstr[num_bytes - 1] == '\0');
+ *port = StringConvert::ToUInt32(port_cstr, 0);
+ if (log)
+ log->Printf("GDBRemoteCommunication::%s() "
+ "debugserver listens %u port",
+ __FUNCTION__, *port);
+ } else {
+ if (log)
+ log->Printf("GDBRemoteCommunication::%s() "
+ "failed to read a port value from pipe %s: %s",
+ __FUNCTION__, named_pipe_path.c_str(),
+ error.AsCString());
+ }
+ socket_pipe.Close();
+ }
+
+ if (named_pipe_path.size() > 0) {
+ const auto err = socket_pipe.Delete(named_pipe_path);
+ if (err.Fail()) {
+ if (log)
+ log->Printf(
+ "GDBRemoteCommunication::%s failed to delete pipe %s: %s",
+ __FUNCTION__, named_pipe_path.c_str(), err.AsCString());
+ }
+ }
+
+ // Make sure we actually connect with the debugserver...
+ JoinListenThread();
+ }
+ } else {
+ error.SetErrorStringWithFormat("unable to locate " DEBUGSERVER_BASENAME);
+ }
- if (named_pipe_path.size() > 0)
- {
- const auto err = socket_pipe.Delete(named_pipe_path);
- if (err.Fail())
- {
- if (log)
- log->Printf ("GDBRemoteCommunication::%s failed to delete pipe %s: %s",
- __FUNCTION__, named_pipe_path.c_str(), err.AsCString());
- }
- }
-
- // Make sure we actually connect with the debugserver...
- JoinListenThread();
- }
- }
- else
- {
- error.SetErrorStringWithFormat ("unable to locate " DEBUGSERVER_BASENAME );
- }
-
- if (error.Fail())
- {
- if (log)
- log->Printf ("GDBRemoteCommunication::%s() failed: %s", __FUNCTION__, error.AsCString());
- }
+ if (error.Fail()) {
+ if (log)
+ log->Printf("GDBRemoteCommunication::%s() failed: %s", __FUNCTION__,
+ error.AsCString());
+ }
- return error;
+ return error;
}
-void
-GDBRemoteCommunication::DumpHistory(Stream &strm)
-{
- m_history.Dump (strm);
-}
+void GDBRemoteCommunication::DumpHistory(Stream &strm) { m_history.Dump(strm); }
-GDBRemoteCommunication::ScopedTimeout::ScopedTimeout (GDBRemoteCommunication& gdb_comm,
- uint32_t timeout) :
- m_gdb_comm (gdb_comm)
-{
- m_saved_timeout = m_gdb_comm.SetPacketTimeout (timeout);
+GDBRemoteCommunication::ScopedTimeout::ScopedTimeout(
+ GDBRemoteCommunication &gdb_comm, uint32_t timeout)
+ : m_gdb_comm(gdb_comm) {
+ m_saved_timeout = m_gdb_comm.SetPacketTimeout(timeout);
}
-GDBRemoteCommunication::ScopedTimeout::~ScopedTimeout ()
-{
- m_gdb_comm.SetPacketTimeout (m_saved_timeout);
+GDBRemoteCommunication::ScopedTimeout::~ScopedTimeout() {
+ m_gdb_comm.SetPacketTimeout(m_saved_timeout);
}
-// This function is called via the Communications class read thread when bytes become available
-// for this connection. This function will consume all incoming bytes and try to parse whole
-// packets as they become available. Full packets are placed in a queue, so that all packet
-// requests can simply pop from this queue. Async notification packets will be dispatched
+// This function is called via the Communications class read thread when bytes
+// become available
+// for this connection. This function will consume all incoming bytes and try to
+// parse whole
+// packets as they become available. Full packets are placed in a queue, so that
+// all packet
+// requests can simply pop from this queue. Async notification packets will be
+// dispatched
// immediately to the ProcessGDBRemote Async thread via an event.
-void GDBRemoteCommunication::AppendBytesToCache (const uint8_t * bytes, size_t len, bool broadcast, lldb::ConnectionStatus status)
-{
- StringExtractorGDBRemote packet;
-
- while (true)
- {
- PacketType type = CheckForPacket(bytes, len, packet);
-
- // scrub the data so we do not pass it back to CheckForPacket
- // on future passes of the loop
- bytes = nullptr;
- len = 0;
-
- // we may have received no packet so lets bail out
- if (type == PacketType::Invalid)
- break;
-
- if (type == PacketType::Standard)
- {
- // scope for the mutex
- {
- // lock down the packet queue
- std::lock_guard<std::mutex> guard(m_packet_queue_mutex);
- // push a new packet into the queue
- m_packet_queue.push(packet);
- // Signal condition variable that we have a packet
- m_condition_queue_not_empty.notify_one();
- }
- }
-
- if (type == PacketType::Notify)
- {
- // put this packet into an event
- const char *pdata = packet.GetStringRef().c_str();
-
- // as the communication class, we are a broadcaster and the
- // async thread is tuned to listen to us
- BroadcastEvent(
- eBroadcastBitGdbReadThreadGotNotify,
- new EventDataBytes(pdata));
- }
+void GDBRemoteCommunication::AppendBytesToCache(const uint8_t *bytes,
+ size_t len, bool broadcast,
+ lldb::ConnectionStatus status) {
+ StringExtractorGDBRemote packet;
+
+ while (true) {
+ PacketType type = CheckForPacket(bytes, len, packet);
+
+ // scrub the data so we do not pass it back to CheckForPacket
+ // on future passes of the loop
+ bytes = nullptr;
+ len = 0;
+
+ // we may have received no packet so lets bail out
+ if (type == PacketType::Invalid)
+ break;
+
+ if (type == PacketType::Standard) {
+ // scope for the mutex
+ {
+ // lock down the packet queue
+ std::lock_guard<std::mutex> guard(m_packet_queue_mutex);
+ // push a new packet into the queue
+ m_packet_queue.push(packet);
+ // Signal condition variable that we have a packet
+ m_condition_queue_not_empty.notify_one();
+ }
+ }
+
+ if (type == PacketType::Notify) {
+ // put this packet into an event
+ const char *pdata = packet.GetStringRef().c_str();
+
+ // as the communication class, we are a broadcaster and the
+ // async thread is tuned to listen to us
+ BroadcastEvent(eBroadcastBitGdbReadThreadGotNotify,
+ new EventDataBytes(pdata));
}
+ }
}
Modified: lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.h?rev=280751&r1=280750&r2=280751&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.h (original)
+++ lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.h Tue Sep 6 15:57:50 2016
@@ -14,334 +14,277 @@
// C++ Includes
#include <condition_variable>
#include <mutex>
-#include <string>
#include <queue>
+#include <string>
#include <vector>
// Other libraries and framework includes
// Project includes
-#include "lldb/lldb-public.h"
#include "lldb/Core/Communication.h"
#include "lldb/Core/Listener.h"
#include "lldb/Host/HostThread.h"
#include "lldb/Host/Predicate.h"
#include "lldb/Host/TimeValue.h"
#include "lldb/Interpreter/Args.h"
+#include "lldb/lldb-public.h"
#include "Utility/StringExtractorGDBRemote.h"
namespace lldb_private {
namespace process_gdb_remote {
-typedef enum
-{
- eStoppointInvalid = -1,
- eBreakpointSoftware = 0,
- eBreakpointHardware,
- eWatchpointWrite,
- eWatchpointRead,
- eWatchpointReadWrite
+typedef enum {
+ eStoppointInvalid = -1,
+ eBreakpointSoftware = 0,
+ eBreakpointHardware,
+ eWatchpointWrite,
+ eWatchpointRead,
+ eWatchpointReadWrite
} GDBStoppointType;
-enum class CompressionType
-{
- None = 0, // no compression
- ZlibDeflate, // zlib's deflate compression scheme, requires zlib or Apple's libcompression
- LZFSE, // an Apple compression scheme, requires Apple's libcompression
- LZ4, // lz compression - called "lz4 raw" in libcompression terms, compat with https://code.google.com/p/lz4/
- LZMA, // LempelâZivâMarkov chain algorithm
+enum class CompressionType {
+ None = 0, // no compression
+ ZlibDeflate, // zlib's deflate compression scheme, requires zlib or Apple's
+ // libcompression
+ LZFSE, // an Apple compression scheme, requires Apple's libcompression
+ LZ4, // lz compression - called "lz4 raw" in libcompression terms, compat with
+ // https://code.google.com/p/lz4/
+ LZMA, // LempelâZivâMarkov chain algorithm
};
class ProcessGDBRemote;
-class GDBRemoteCommunication : public Communication
-{
+class GDBRemoteCommunication : public Communication {
public:
- enum
- {
- eBroadcastBitRunPacketSent = kLoUserBroadcastBit,
- eBroadcastBitGdbReadThreadGotNotify = kLoUserBroadcastBit << 1 // Sent when we received a notify packet.
- };
+ enum {
+ eBroadcastBitRunPacketSent = kLoUserBroadcastBit,
+ eBroadcastBitGdbReadThreadGotNotify =
+ kLoUserBroadcastBit << 1 // Sent when we received a notify packet.
+ };
+
+ enum class PacketType { Invalid = 0, Standard, Notify };
+
+ enum class PacketResult {
+ Success = 0, // Success
+ ErrorSendFailed, // Error sending the packet
+ ErrorSendAck, // Didn't get an ack back after sending a packet
+ ErrorReplyFailed, // Error getting the reply
+ ErrorReplyTimeout, // Timed out waiting for reply
+ ErrorReplyInvalid, // Got a reply but it wasn't valid for the packet that
+ // was sent
+ ErrorReplyAck, // Sending reply ack failed
+ ErrorDisconnected, // We were disconnected
+ ErrorNoSequenceLock // We couldn't get the sequence lock for a multi-packet
+ // request
+ };
+
+ // Class to change the timeout for a given scope and restore it to the
+ // original value when the
+ // created ScopedTimeout object got out of scope
+ class ScopedTimeout {
+ public:
+ ScopedTimeout(GDBRemoteCommunication &gdb_comm, uint32_t timeout);
+ ~ScopedTimeout();
+
+ private:
+ GDBRemoteCommunication &m_gdb_comm;
+ uint32_t m_saved_timeout;
+ };
+
+ GDBRemoteCommunication(const char *comm_name, const char *listener_name);
+
+ ~GDBRemoteCommunication() override;
+
+ PacketResult GetAck();
+
+ size_t SendAck();
+
+ size_t SendNack();
+
+ char CalculcateChecksum(llvm::StringRef payload);
+
+ PacketType CheckForPacket(const uint8_t *src, size_t src_len,
+ StringExtractorGDBRemote &packet);
+
+ bool GetSendAcks() { return m_send_acks; }
+
+ //------------------------------------------------------------------
+ // Set the global packet timeout.
+ //
+ // For clients, this is the timeout that gets used when sending
+ // packets and waiting for responses. For servers, this might not
+ // get used, and if it doesn't this should be moved to the
+ // GDBRemoteCommunicationClient.
+ //------------------------------------------------------------------
+ uint32_t SetPacketTimeout(uint32_t packet_timeout) {
+ const uint32_t old_packet_timeout = m_packet_timeout;
+ m_packet_timeout = packet_timeout;
+ return old_packet_timeout;
+ }
+
+ uint32_t GetPacketTimeoutInMicroSeconds() const {
+ return m_packet_timeout * TimeValue::MicroSecPerSec;
+ }
+
+ //------------------------------------------------------------------
+ // Start a debugserver instance on the current host using the
+ // supplied connection URL.
+ //------------------------------------------------------------------
+ Error StartDebugserverProcess(
+ const char *url,
+ Platform *platform, // If non nullptr, then check with the platform for
+ // the GDB server binary if it can't be located
+ ProcessLaunchInfo &launch_info, uint16_t *port, const Args *inferior_args,
+ int pass_comm_fd); // Communication file descriptor to pass during
+ // fork/exec to avoid having to connect/accept
- enum class PacketType
- {
- Invalid = 0,
- Standard,
- Notify
- };
+ void DumpHistory(Stream &strm);
- enum class PacketResult
- {
- Success = 0, // Success
- ErrorSendFailed, // Error sending the packet
- ErrorSendAck, // Didn't get an ack back after sending a packet
- ErrorReplyFailed, // Error getting the reply
- ErrorReplyTimeout, // Timed out waiting for reply
- ErrorReplyInvalid, // Got a reply but it wasn't valid for the packet that was sent
- ErrorReplyAck, // Sending reply ack failed
- ErrorDisconnected, // We were disconnected
- ErrorNoSequenceLock // We couldn't get the sequence lock for a multi-packet request
+protected:
+ class History {
+ public:
+ enum PacketType {
+ ePacketTypeInvalid = 0,
+ ePacketTypeSend,
+ ePacketTypeRecv
};
- // Class to change the timeout for a given scope and restore it to the original value when the
- // created ScopedTimeout object got out of scope
- class ScopedTimeout
- {
- public:
- ScopedTimeout (GDBRemoteCommunication& gdb_comm, uint32_t timeout);
- ~ScopedTimeout ();
-
- private:
- GDBRemoteCommunication& m_gdb_comm;
- uint32_t m_saved_timeout;
+ struct Entry {
+ Entry()
+ : packet(), type(ePacketTypeInvalid), bytes_transmitted(0),
+ packet_idx(0), tid(LLDB_INVALID_THREAD_ID) {}
+
+ void Clear() {
+ packet.clear();
+ type = ePacketTypeInvalid;
+ bytes_transmitted = 0;
+ packet_idx = 0;
+ tid = LLDB_INVALID_THREAD_ID;
+ }
+ std::string packet;
+ PacketType type;
+ uint32_t bytes_transmitted;
+ uint32_t packet_idx;
+ lldb::tid_t tid;
};
- GDBRemoteCommunication(const char *comm_name,
- const char *listener_name);
+ History(uint32_t size);
- ~GDBRemoteCommunication() override;
+ ~History();
- PacketResult
- GetAck ();
+ // For single char packets for ack, nack and /x03
+ void AddPacket(char packet_char, PacketType type,
+ uint32_t bytes_transmitted);
- size_t
- SendAck ();
+ void AddPacket(const std::string &src, uint32_t src_len, PacketType type,
+ uint32_t bytes_transmitted);
- size_t
- SendNack ();
+ void Dump(Stream &strm) const;
- char
- CalculcateChecksum (llvm::StringRef payload);
+ void Dump(Log *log) const;
- PacketType
- CheckForPacket (const uint8_t *src,
- size_t src_len,
- StringExtractorGDBRemote &packet);
+ bool DidDumpToLog() const { return m_dumped_to_log; }
- bool
- GetSendAcks ()
- {
- return m_send_acks;
+ protected:
+ uint32_t GetFirstSavedPacketIndex() const {
+ if (m_total_packet_count < m_packets.size())
+ return 0;
+ else
+ return m_curr_idx + 1;
}
- //------------------------------------------------------------------
- // Set the global packet timeout.
- //
- // For clients, this is the timeout that gets used when sending
- // packets and waiting for responses. For servers, this might not
- // get used, and if it doesn't this should be moved to the
- // GDBRemoteCommunicationClient.
- //------------------------------------------------------------------
- uint32_t
- SetPacketTimeout (uint32_t packet_timeout)
- {
- const uint32_t old_packet_timeout = m_packet_timeout;
- m_packet_timeout = packet_timeout;
- return old_packet_timeout;
+ uint32_t GetNumPacketsInHistory() const {
+ if (m_total_packet_count < m_packets.size())
+ return m_total_packet_count;
+ else
+ return (uint32_t)m_packets.size();
}
- uint32_t
- GetPacketTimeoutInMicroSeconds () const
- {
- return m_packet_timeout * TimeValue::MicroSecPerSec;
+ uint32_t GetNextIndex() {
+ ++m_total_packet_count;
+ const uint32_t idx = m_curr_idx;
+ m_curr_idx = NormalizeIndex(idx + 1);
+ return idx;
}
- //------------------------------------------------------------------
- // Start a debugserver instance on the current host using the
- // supplied connection URL.
- //------------------------------------------------------------------
- Error
- StartDebugserverProcess(const char *url,
- Platform *platform, // If non nullptr, then check with the platform for the GDB server binary if it can't be located
- ProcessLaunchInfo &launch_info,
- uint16_t *port,
- const Args *inferior_args,
- int pass_comm_fd); // Communication file descriptor to pass during fork/exec to avoid having to connect/accept
-
- void
- DumpHistory(Stream &strm);
-
-protected:
- class History
- {
- public:
- enum PacketType
- {
- ePacketTypeInvalid = 0,
- ePacketTypeSend,
- ePacketTypeRecv
- };
-
- struct Entry
- {
- Entry() :
- packet(),
- type (ePacketTypeInvalid),
- bytes_transmitted (0),
- packet_idx (0),
- tid (LLDB_INVALID_THREAD_ID)
- {
- }
-
- void
- Clear ()
- {
- packet.clear();
- type = ePacketTypeInvalid;
- bytes_transmitted = 0;
- packet_idx = 0;
- tid = LLDB_INVALID_THREAD_ID;
- }
- std::string packet;
- PacketType type;
- uint32_t bytes_transmitted;
- uint32_t packet_idx;
- lldb::tid_t tid;
- };
-
- History (uint32_t size);
-
- ~History ();
-
- // For single char packets for ack, nack and /x03
- void
- AddPacket (char packet_char,
- PacketType type,
- uint32_t bytes_transmitted);
-
- void
- AddPacket (const std::string &src,
- uint32_t src_len,
- PacketType type,
- uint32_t bytes_transmitted);
-
- void
- Dump (Stream &strm) const;
-
- void
- Dump (Log *log) const;
-
- bool
- DidDumpToLog () const
- {
- return m_dumped_to_log;
- }
-
- protected:
- uint32_t
- GetFirstSavedPacketIndex () const
- {
- if (m_total_packet_count < m_packets.size())
- return 0;
- else
- return m_curr_idx + 1;
- }
-
- uint32_t
- GetNumPacketsInHistory () const
- {
- if (m_total_packet_count < m_packets.size())
- return m_total_packet_count;
- else
- return (uint32_t)m_packets.size();
- }
-
- uint32_t
- GetNextIndex()
- {
- ++m_total_packet_count;
- const uint32_t idx = m_curr_idx;
- m_curr_idx = NormalizeIndex(idx + 1);
- return idx;
- }
-
- uint32_t
- NormalizeIndex (uint32_t i) const
- {
- return i % m_packets.size();
- }
-
- std::vector<Entry> m_packets;
- uint32_t m_curr_idx;
- uint32_t m_total_packet_count;
- mutable bool m_dumped_to_log;
- };
-
- uint32_t m_packet_timeout;
- uint32_t m_echo_number;
- LazyBool m_supports_qEcho;
- History m_history;
- bool m_send_acks;
- bool m_is_platform; // Set to true if this class represents a platform,
- // false if this class represents a debug session for
- // a single process
-
- CompressionType m_compression_type;
-
- PacketResult
- SendPacketNoLock (llvm::StringRef payload);
-
- PacketResult
- ReadPacket (StringExtractorGDBRemote &response, uint32_t timeout_usec, bool sync_on_timeout);
-
- // Pop a packet from the queue in a thread safe manner
- PacketResult
- PopPacketFromQueue (StringExtractorGDBRemote &response, uint32_t timeout_usec);
-
- PacketResult
- WaitForPacketWithTimeoutMicroSecondsNoLock (StringExtractorGDBRemote &response,
- uint32_t timeout_usec,
- bool sync_on_timeout);
-
- bool
- CompressionIsEnabled ()
- {
- return m_compression_type != CompressionType::None;
- }
+ uint32_t NormalizeIndex(uint32_t i) const { return i % m_packets.size(); }
- // If compression is enabled, decompress the packet in m_bytes and update
- // m_bytes with the uncompressed version.
- // Returns 'true' packet was decompressed and m_bytes is the now-decompressed text.
- // Returns 'false' if unable to decompress or if the checksum was invalid.
- //
- // NB: Once the packet has been decompressed, checksum cannot be computed based
- // on m_bytes. The checksum was for the compressed packet.
- bool
- DecompressPacket ();
-
- Error
- StartListenThread (const char *hostname = "127.0.0.1", uint16_t port = 0);
-
- bool
- JoinListenThread ();
-
- static lldb::thread_result_t
- ListenThread (lldb::thread_arg_t arg);
-
- // GDB-Remote read thread
- // . this thread constantly tries to read from the communication
- // class and stores all packets received in a queue. The usual
- // threads read requests simply pop packets off the queue in the
- // usual order.
- // This setup allows us to intercept and handle async packets, such
- // as the notify packet.
-
- // This method is defined as part of communication.h
- // when the read thread gets any bytes it will pass them on to this function
- void AppendBytesToCache(const uint8_t * bytes,
- size_t len,
- bool broadcast,
- lldb::ConnectionStatus status) override;
+ std::vector<Entry> m_packets;
+ uint32_t m_curr_idx;
+ uint32_t m_total_packet_count;
+ mutable bool m_dumped_to_log;
+ };
+
+ uint32_t m_packet_timeout;
+ uint32_t m_echo_number;
+ LazyBool m_supports_qEcho;
+ History m_history;
+ bool m_send_acks;
+ bool m_is_platform; // Set to true if this class represents a platform,
+ // false if this class represents a debug session for
+ // a single process
+
+ CompressionType m_compression_type;
+
+ PacketResult SendPacketNoLock(llvm::StringRef payload);
+
+ PacketResult ReadPacket(StringExtractorGDBRemote &response,
+ uint32_t timeout_usec, bool sync_on_timeout);
+
+ // Pop a packet from the queue in a thread safe manner
+ PacketResult PopPacketFromQueue(StringExtractorGDBRemote &response,
+ uint32_t timeout_usec);
+
+ PacketResult
+ WaitForPacketWithTimeoutMicroSecondsNoLock(StringExtractorGDBRemote &response,
+ uint32_t timeout_usec,
+ bool sync_on_timeout);
+
+ bool CompressionIsEnabled() {
+ return m_compression_type != CompressionType::None;
+ }
+
+ // If compression is enabled, decompress the packet in m_bytes and update
+ // m_bytes with the uncompressed version.
+ // Returns 'true' packet was decompressed and m_bytes is the now-decompressed
+ // text.
+ // Returns 'false' if unable to decompress or if the checksum was invalid.
+ //
+ // NB: Once the packet has been decompressed, checksum cannot be computed
+ // based
+ // on m_bytes. The checksum was for the compressed packet.
+ bool DecompressPacket();
+
+ Error StartListenThread(const char *hostname = "127.0.0.1",
+ uint16_t port = 0);
+
+ bool JoinListenThread();
+
+ static lldb::thread_result_t ListenThread(lldb::thread_arg_t arg);
+
+ // GDB-Remote read thread
+ // . this thread constantly tries to read from the communication
+ // class and stores all packets received in a queue. The usual
+ // threads read requests simply pop packets off the queue in the
+ // usual order.
+ // This setup allows us to intercept and handle async packets, such
+ // as the notify packet.
+
+ // This method is defined as part of communication.h
+ // when the read thread gets any bytes it will pass them on to this function
+ void AppendBytesToCache(const uint8_t *bytes, size_t len, bool broadcast,
+ lldb::ConnectionStatus status) override;
private:
- std::queue<StringExtractorGDBRemote> m_packet_queue; // The packet queue
- std::mutex m_packet_queue_mutex; // Mutex for accessing queue
- std::condition_variable m_condition_queue_not_empty; // Condition variable to wait for packets
+ std::queue<StringExtractorGDBRemote> m_packet_queue; // The packet queue
+ std::mutex m_packet_queue_mutex; // Mutex for accessing queue
+ std::condition_variable
+ m_condition_queue_not_empty; // Condition variable to wait for packets
- HostThread m_listen_thread;
- std::string m_listen_url;
+ HostThread m_listen_thread;
+ std::string m_listen_url;
- DISALLOW_COPY_AND_ASSIGN (GDBRemoteCommunication);
+ DISALLOW_COPY_AND_ASSIGN(GDBRemoteCommunication);
};
} // namespace process_gdb_remote
More information about the lldb-commits
mailing list