@@ -809,7 +809,7 @@ bool x86AssemblyInspectionEngine::local_branch_p (
809
809
// Branch target is before the start of this function
810
810
return false ;
811
811
}
812
- if (offset + next_pc_value > func_range.GetByteSize ()) {
812
+ if (offset + next_pc_value >= func_range.GetByteSize ()) {
813
813
// Branch targets outside this function's bounds
814
814
return false ;
815
815
}
@@ -967,6 +967,8 @@ bool x86AssemblyInspectionEngine::GetNonCallSiteUnwindPlanFromAssembly(
967
967
968
968
bool in_epilogue = false ; // we're in the middle of an epilogue sequence
969
969
bool row_updated = false ; // The UnwindPlan::Row 'row' has been updated
970
+ bool current_sp_offset_updated =
971
+ false ; // current_sp_bytes_offset_from_fa has been updated this insn
970
972
971
973
m_cur_insn = data + current_func_text_offset;
972
974
if (!instruction_length (m_cur_insn, insn_len, size - current_func_text_offset)
@@ -1013,8 +1015,10 @@ bool x86AssemblyInspectionEngine::GetNonCallSiteUnwindPlanFromAssembly(
1013
1015
afa_value.SetUnspecified ();
1014
1016
row_updated = true ;
1015
1017
}
1016
- if (fa_value_ptr->GetRegisterNumber () == m_lldb_fp_regnum)
1018
+ if (fa_value_ptr->GetRegisterNumber () == m_lldb_fp_regnum) {
1017
1019
current_sp_bytes_offset_from_fa = fa_value_ptr->GetOffset ();
1020
+ current_sp_offset_updated = true ;
1021
+ }
1018
1022
}
1019
1023
1020
1024
else if (mov_rbx_rsp_pattern_p ()) {
@@ -1025,8 +1029,10 @@ bool x86AssemblyInspectionEngine::GetNonCallSiteUnwindPlanFromAssembly(
1025
1029
afa_value.SetUnspecified ();
1026
1030
row_updated = true ;
1027
1031
}
1028
- if (fa_value_ptr->GetRegisterNumber () == m_lldb_alt_fp_regnum)
1032
+ if (fa_value_ptr->GetRegisterNumber () == m_lldb_alt_fp_regnum) {
1029
1033
current_sp_bytes_offset_from_fa = fa_value_ptr->GetOffset ();
1034
+ current_sp_offset_updated = true ;
1035
+ }
1030
1036
}
1031
1037
1032
1038
// This is the start() function (or a pthread equivalent), it starts with a
@@ -1039,6 +1045,7 @@ bool x86AssemblyInspectionEngine::GetNonCallSiteUnwindPlanFromAssembly(
1039
1045
1040
1046
else if (push_reg_p (machine_regno)) {
1041
1047
current_sp_bytes_offset_from_fa += m_wordsize;
1048
+ current_sp_offset_updated = true ;
1042
1049
// the PUSH instruction has moved the stack pointer - if the FA is set
1043
1050
// in terms of the stack pointer, we need to add a new row of
1044
1051
// instructions.
@@ -1064,6 +1071,7 @@ bool x86AssemblyInspectionEngine::GetNonCallSiteUnwindPlanFromAssembly(
1064
1071
1065
1072
else if (pop_reg_p (machine_regno)) {
1066
1073
current_sp_bytes_offset_from_fa -= m_wordsize;
1074
+ current_sp_offset_updated = true ;
1067
1075
1068
1076
if (nonvolatile_reg_p (machine_regno) &&
1069
1077
machine_regno_to_lldb_regno (machine_regno, lldb_regno) &&
@@ -1091,6 +1099,7 @@ bool x86AssemblyInspectionEngine::GetNonCallSiteUnwindPlanFromAssembly(
1091
1099
1092
1100
else if (pop_misc_reg_p ()) {
1093
1101
current_sp_bytes_offset_from_fa -= m_wordsize;
1102
+ current_sp_offset_updated = true ;
1094
1103
if (fa_value_ptr->GetRegisterNumber () == m_lldb_sp_regnum) {
1095
1104
fa_value_ptr->SetIsRegisterPlusOffset (
1096
1105
m_lldb_sp_regnum, current_sp_bytes_offset_from_fa);
@@ -1126,6 +1135,7 @@ bool x86AssemblyInspectionEngine::GetNonCallSiteUnwindPlanFromAssembly(
1126
1135
}
1127
1136
1128
1137
current_sp_bytes_offset_from_fa -= m_wordsize;
1138
+ current_sp_offset_updated = true ;
1129
1139
1130
1140
if (fa_value_ptr->GetRegisterNumber () == m_lldb_sp_regnum) {
1131
1141
fa_value_ptr->SetIsRegisterPlusOffset (
@@ -1161,6 +1171,7 @@ bool x86AssemblyInspectionEngine::GetNonCallSiteUnwindPlanFromAssembly(
1161
1171
1162
1172
else if (sub_rsp_pattern_p (stack_offset)) {
1163
1173
current_sp_bytes_offset_from_fa += stack_offset;
1174
+ current_sp_offset_updated = true ;
1164
1175
if (fa_value_ptr->GetRegisterNumber () == m_lldb_sp_regnum) {
1165
1176
fa_value_ptr->SetOffset (current_sp_bytes_offset_from_fa);
1166
1177
row_updated = true ;
@@ -1169,6 +1180,7 @@ bool x86AssemblyInspectionEngine::GetNonCallSiteUnwindPlanFromAssembly(
1169
1180
1170
1181
else if (add_rsp_pattern_p (stack_offset)) {
1171
1182
current_sp_bytes_offset_from_fa -= stack_offset;
1183
+ current_sp_offset_updated = true ;
1172
1184
if (fa_value_ptr->GetRegisterNumber () == m_lldb_sp_regnum) {
1173
1185
fa_value_ptr->SetOffset (current_sp_bytes_offset_from_fa);
1174
1186
row_updated = true ;
@@ -1179,6 +1191,7 @@ bool x86AssemblyInspectionEngine::GetNonCallSiteUnwindPlanFromAssembly(
1179
1191
else if (push_extended_pattern_p () || push_imm_pattern_p () ||
1180
1192
push_misc_reg_p ()) {
1181
1193
current_sp_bytes_offset_from_fa += m_wordsize;
1194
+ current_sp_offset_updated = true ;
1182
1195
if (fa_value_ptr->GetRegisterNumber () == m_lldb_sp_regnum) {
1183
1196
fa_value_ptr->SetOffset (current_sp_bytes_offset_from_fa);
1184
1197
row_updated = true ;
@@ -1187,6 +1200,7 @@ bool x86AssemblyInspectionEngine::GetNonCallSiteUnwindPlanFromAssembly(
1187
1200
1188
1201
else if (lea_rsp_pattern_p (stack_offset)) {
1189
1202
current_sp_bytes_offset_from_fa -= stack_offset;
1203
+ current_sp_offset_updated = true ;
1190
1204
if (fa_value_ptr->GetRegisterNumber () == m_lldb_sp_regnum) {
1191
1205
fa_value_ptr->SetOffset (current_sp_bytes_offset_from_fa);
1192
1206
row_updated = true ;
@@ -1206,6 +1220,7 @@ bool x86AssemblyInspectionEngine::GetNonCallSiteUnwindPlanFromAssembly(
1206
1220
if (fa_value_ptr->GetRegisterNumber () == m_lldb_fp_regnum) {
1207
1221
current_sp_bytes_offset_from_fa =
1208
1222
fa_value_ptr->GetOffset () - stack_offset;
1223
+ current_sp_offset_updated = true ;
1209
1224
}
1210
1225
}
1211
1226
@@ -1219,6 +1234,7 @@ bool x86AssemblyInspectionEngine::GetNonCallSiteUnwindPlanFromAssembly(
1219
1234
}
1220
1235
if (fa_value_ptr->GetRegisterNumber () == m_lldb_alt_fp_regnum) {
1221
1236
current_sp_bytes_offset_from_fa = fa_value_ptr->GetOffset () - stack_offset;
1237
+ current_sp_offset_updated = true ;
1222
1238
}
1223
1239
}
1224
1240
@@ -1251,6 +1267,7 @@ bool x86AssemblyInspectionEngine::GetNonCallSiteUnwindPlanFromAssembly(
1251
1267
row.reset (newrow);
1252
1268
current_sp_bytes_offset_from_fa =
1253
1269
prologue_completed_sp_bytes_offset_from_cfa;
1270
+ current_sp_offset_updated = true ;
1254
1271
is_aligned = prologue_completed_is_aligned;
1255
1272
1256
1273
saved_registers.clear ();
@@ -1272,6 +1289,7 @@ bool x86AssemblyInspectionEngine::GetNonCallSiteUnwindPlanFromAssembly(
1272
1289
// global data
1273
1290
else if (call_next_insn_pattern_p ()) {
1274
1291
current_sp_bytes_offset_from_fa += m_wordsize;
1292
+ current_sp_offset_updated = true ;
1275
1293
if (fa_value_ptr->GetRegisterNumber () == m_lldb_sp_regnum) {
1276
1294
fa_value_ptr->SetOffset (current_sp_bytes_offset_from_fa);
1277
1295
row_updated = true ;
@@ -1304,7 +1322,7 @@ bool x86AssemblyInspectionEngine::GetNonCallSiteUnwindPlanFromAssembly(
1304
1322
1305
1323
// We may change the sp value without adding a new Row necessarily -- keep
1306
1324
// track of it either way.
1307
- if (!in_epilogue) {
1325
+ if (!in_epilogue && current_sp_offset_updated ) {
1308
1326
prologue_completed_sp_bytes_offset_from_cfa =
1309
1327
current_sp_bytes_offset_from_fa;
1310
1328
prologue_completed_is_aligned = is_aligned;
0 commit comments