Skip to content

Commit

Permalink
Consider the first chunk that we encounter as valid
Browse files Browse the repository at this point in the history
  • Loading branch information
patacca committed Mar 7, 2024
1 parent 7a10f95 commit 690389e
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
4 changes: 3 additions & 1 deletion include/quokka/Layout.h
Original file line number Diff line number Diff line change
Expand Up @@ -271,8 +271,10 @@ class HeadIterator {
/**
* Retrieve the next chunk address if any are found
* @param address Address to start from
* @param skip_current Do not consider the chunk starting at the current
* address
*/
void SetNextChunk(ea_t address);
void SetNextChunk(ea_t address, bool skip_current = true);

/**
* Compute the next address and state
Expand Down
19 changes: 16 additions & 3 deletions src/Layout.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,24 @@ void HeadIterator::InitAddresses(ea_t address) {
this->next_unk_addr = next_unknown(address, this->max_ea);
this->next_head_addr = next_head(address, this->max_ea);

this->SetNextChunk(address);
this->SetNextChunk(address, false);
}

void HeadIterator::SetNextChunk(ea_t address) {
func_t* func = get_next_fchunk(address);
void HeadIterator::SetNextChunk(ea_t address, bool skip_current /* = true*/) {
func_t* func;

// Check if there is a chunk starting at provided address
if (!skip_current) {
func = get_fchunk(address);
if (func != nullptr && func->start_ea == address) {
this->next_chunk_addr = address;
this->next_func_chunk = func;
return;
}
}

// Find the next chunk, not considering the one at the current address
func = get_next_fchunk(address);
if (func != nullptr) {
this->next_chunk_addr = func->start_ea;
this->next_func_chunk = func;
Expand Down

0 comments on commit 690389e

Please sign in to comment.