我遇到了分段错误(核心转储)错误并尝试使用 gdb 进行调试。我发现错误发生在哪里:
Program received signal SIGSEGV, Segmentation fault.
0x08048edb in state_update2 () at xxx.cpp:333
333 if (rob.head->is_complete == 1 && rob.head->ready_to_retire == 1 )
几行代码是:
if(rob.head->is_complete == 1 && rob.head->ready_to_retire == 1) {
reorder_buffer_node *temp = new reorder_buffer_node[sizeof(struct reorder_buffer_node)];
temp = rob.head;
for(uint64_t i=0; i<f_; i++) {
if(temp->is_complete == 1 && temp->ready_to_retire == 1) {
rob.pop();
retired_inst++;
temp = temp->next;
}
else break;
}
}
ROB 是一个循环队列,head 是一个指向以下结构的指针:
struct reorder_buffer_node {
int is_complete;
uint64_t instr_num;
uint64_t dest_reg;
uint64_t index;
reorder_buffer_node *next;
int ready_to_retire;
};
我没有以正确的方式访问结构的成员吗?请告诉我!