Use range-based for loops in linux/minidump_writer/minidump_writer.cc.
Also fix lint errors. R=mark@chromium.org Review URL: https://codereview.chromium.org/1562273002 .
This commit is contained in:
parent
b1d3cdba8b
commit
bcf4cc2f9a
@ -509,7 +509,7 @@ class MinidumpWriter {
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
MDRawModule mod;
|
MDRawModule mod;
|
||||||
if (!FillRawModule(mapping, true, i, mod, NULL))
|
if (!FillRawModule(mapping, true, i, &mod, NULL))
|
||||||
return false;
|
return false;
|
||||||
list.CopyIndexAfterObject(j++, &mod, MD_MODULE_SIZE);
|
list.CopyIndexAfterObject(j++, &mod, MD_MODULE_SIZE);
|
||||||
}
|
}
|
||||||
@ -518,7 +518,7 @@ class MinidumpWriter {
|
|||||||
iter != mapping_list_.end();
|
iter != mapping_list_.end();
|
||||||
++iter) {
|
++iter) {
|
||||||
MDRawModule mod;
|
MDRawModule mod;
|
||||||
if (!FillRawModule(iter->first, false, 0, mod, iter->second))
|
if (!FillRawModule(iter->first, false, 0, &mod, iter->second))
|
||||||
return false;
|
return false;
|
||||||
list.CopyIndexAfterObject(j++, &mod, MD_MODULE_SIZE);
|
list.CopyIndexAfterObject(j++, &mod, MD_MODULE_SIZE);
|
||||||
}
|
}
|
||||||
@ -532,12 +532,12 @@ class MinidumpWriter {
|
|||||||
bool FillRawModule(const MappingInfo& mapping,
|
bool FillRawModule(const MappingInfo& mapping,
|
||||||
bool member,
|
bool member,
|
||||||
unsigned int mapping_id,
|
unsigned int mapping_id,
|
||||||
MDRawModule& mod,
|
MDRawModule* mod,
|
||||||
const uint8_t* identifier) {
|
const uint8_t* identifier) {
|
||||||
my_memset(&mod, 0, MD_MODULE_SIZE);
|
my_memset(mod, 0, MD_MODULE_SIZE);
|
||||||
|
|
||||||
mod.base_of_image = mapping.start_addr;
|
mod->base_of_image = mapping.start_addr;
|
||||||
mod.size_of_image = mapping.size;
|
mod->size_of_image = mapping.size;
|
||||||
|
|
||||||
uint8_t cv_buf[MDCVInfoPDB70_minsize + NAME_MAX];
|
uint8_t cv_buf[MDCVInfoPDB70_minsize + NAME_MAX];
|
||||||
uint8_t* cv_ptr = cv_buf;
|
uint8_t* cv_ptr = cv_buf;
|
||||||
@ -572,12 +572,12 @@ class MinidumpWriter {
|
|||||||
my_memcpy(cv_ptr, file_name, file_name_len + 1);
|
my_memcpy(cv_ptr, file_name, file_name_len + 1);
|
||||||
cv.Copy(cv_buf, MDCVInfoPDB70_minsize + file_name_len + 1);
|
cv.Copy(cv_buf, MDCVInfoPDB70_minsize + file_name_len + 1);
|
||||||
|
|
||||||
mod.cv_record = cv.location();
|
mod->cv_record = cv.location();
|
||||||
|
|
||||||
MDLocationDescriptor ld;
|
MDLocationDescriptor ld;
|
||||||
if (!minidump_writer_.WriteString(file_path, my_strlen(file_path), &ld))
|
if (!minidump_writer_.WriteString(file_path, my_strlen(file_path), &ld))
|
||||||
return false;
|
return false;
|
||||||
mod.module_name_rva = ld.rva;
|
mod->module_name_rva = ld.rva;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -684,17 +684,14 @@ class MinidumpWriter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifdef __mips__
|
#ifdef __mips__
|
||||||
if (dyn.d_tag == DT_MIPS_RLD_MAP) {
|
const int32_t debug_tag = DT_MIPS_RLD_MAP;
|
||||||
r_debug = reinterpret_cast<struct r_debug*>(dyn.d_un.d_ptr);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
#else
|
#else
|
||||||
if (dyn.d_tag == DT_DEBUG) {
|
const int32_t debug_tag = DT_DEBUG;
|
||||||
|
#endif
|
||||||
|
if (dyn.d_tag == debug_tag) {
|
||||||
r_debug = reinterpret_cast<struct r_debug*>(dyn.d_un.d_ptr);
|
r_debug = reinterpret_cast<struct r_debug*>(dyn.d_un.d_ptr);
|
||||||
continue;
|
continue;
|
||||||
}
|
} else if (dyn.d_tag == DT_NULL) {
|
||||||
#endif
|
|
||||||
else if (dyn.d_tag == DT_NULL) {
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -836,15 +833,14 @@ class MinidumpWriter {
|
|||||||
ProcCpuInfoReader* const reader = new(allocator) ProcCpuInfoReader(fd);
|
ProcCpuInfoReader* const reader = new(allocator) ProcCpuInfoReader(fd);
|
||||||
const char* field;
|
const char* field;
|
||||||
while (reader->GetNextField(&field)) {
|
while (reader->GetNextField(&field)) {
|
||||||
for (size_t i = 0;
|
bool is_first_entry = true;
|
||||||
i < sizeof(cpu_info_table) / sizeof(cpu_info_table[0]);
|
for (CpuInfoEntry& entry : cpu_info_table) {
|
||||||
i++) {
|
if (!is_first_entry && entry.found) {
|
||||||
CpuInfoEntry* entry = &cpu_info_table[i];
|
|
||||||
if (i > 0 && entry->found) {
|
|
||||||
// except for the 'processor' field, ignore repeated values.
|
// except for the 'processor' field, ignore repeated values.
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (!my_strcmp(field, entry->info_name)) {
|
is_first_entry = false;
|
||||||
|
if (!my_strcmp(field, entry.info_name)) {
|
||||||
size_t value_len;
|
size_t value_len;
|
||||||
const char* value = reader->GetValueAndLen(&value_len);
|
const char* value = reader->GetValueAndLen(&value_len);
|
||||||
if (value_len == 0)
|
if (value_len == 0)
|
||||||
@ -854,8 +850,8 @@ class MinidumpWriter {
|
|||||||
if (my_read_decimal_ptr(&val, value) == value)
|
if (my_read_decimal_ptr(&val, value) == value)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
entry->value = static_cast<int>(val);
|
entry.value = static_cast<int>(val);
|
||||||
entry->found = true;
|
entry.found = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -871,10 +867,8 @@ class MinidumpWriter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// make sure we got everything we wanted
|
// make sure we got everything we wanted
|
||||||
for (size_t i = 0;
|
for (const CpuInfoEntry& entry : cpu_info_table) {
|
||||||
i < sizeof(cpu_info_table) / sizeof(cpu_info_table[0]);
|
if (!entry.found) {
|
||||||
i++) {
|
|
||||||
if (!cpu_info_table[i].found) {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1010,18 +1004,15 @@ class MinidumpWriter {
|
|||||||
new(allocator) ProcCpuInfoReader(fd);
|
new(allocator) ProcCpuInfoReader(fd);
|
||||||
const char* field;
|
const char* field;
|
||||||
while (reader->GetNextField(&field)) {
|
while (reader->GetNextField(&field)) {
|
||||||
for (size_t i = 0;
|
for (const CpuInfoEntry& entry : cpu_info_table) {
|
||||||
i < sizeof(cpu_id_entries)/sizeof(cpu_id_entries[0]);
|
if (my_strcmp(entry.field, field) != 0)
|
||||||
++i) {
|
|
||||||
const CpuIdEntry* entry = &cpu_id_entries[i];
|
|
||||||
if (my_strcmp(entry->field, field) != 0)
|
|
||||||
continue;
|
continue;
|
||||||
uintptr_t result = 0;
|
uintptr_t result = 0;
|
||||||
const char* value = reader->GetValue();
|
const char* value = reader->GetValue();
|
||||||
const char* p = value;
|
const char* p = value;
|
||||||
if (value[0] == '0' && value[1] == 'x') {
|
if (value[0] == '0' && value[1] == 'x') {
|
||||||
p = my_read_hex_ptr(&result, value+2);
|
p = my_read_hex_ptr(&result, value+2);
|
||||||
} else if (entry->format == 'x') {
|
} else if (entry.format == 'x') {
|
||||||
p = my_read_hex_ptr(&result, value);
|
p = my_read_hex_ptr(&result, value);
|
||||||
} else {
|
} else {
|
||||||
p = my_read_decimal_ptr(&result, value);
|
p = my_read_decimal_ptr(&result, value);
|
||||||
@ -1029,8 +1020,8 @@ class MinidumpWriter {
|
|||||||
if (p == value)
|
if (p == value)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
result &= (1U << entry->bit_length)-1;
|
result &= (1U << entry.bit_length)-1;
|
||||||
result <<= entry->bit_lshift;
|
result <<= entry.bit_lshift;
|
||||||
sys_info->cpu.arm_cpu_info.cpuid |=
|
sys_info->cpu.arm_cpu_info.cpuid |=
|
||||||
static_cast<uint32_t>(result);
|
static_cast<uint32_t>(result);
|
||||||
}
|
}
|
||||||
@ -1084,7 +1075,7 @@ class MinidumpWriter {
|
|||||||
const char* tag = value;
|
const char* tag = value;
|
||||||
size_t tag_len = value_len;
|
size_t tag_len = value_len;
|
||||||
const char* p = my_strchr(tag, ' ');
|
const char* p = my_strchr(tag, ' ');
|
||||||
if (p != NULL) {
|
if (p) {
|
||||||
tag_len = static_cast<size_t>(p - tag);
|
tag_len = static_cast<size_t>(p - tag);
|
||||||
value += tag_len + 1;
|
value += tag_len + 1;
|
||||||
value_len -= tag_len + 1;
|
value_len -= tag_len + 1;
|
||||||
@ -1092,14 +1083,10 @@ class MinidumpWriter {
|
|||||||
tag_len = strlen(tag);
|
tag_len = strlen(tag);
|
||||||
value_len = 0;
|
value_len = 0;
|
||||||
}
|
}
|
||||||
for (size_t i = 0;
|
for (const CpuInfoEntry& entry : cpu_features_entries) {
|
||||||
i != sizeof(cpu_features_entries) /
|
if (tag_len == strlen(entry.tag) &&
|
||||||
sizeof(cpu_features_entries[0]);
|
!memcmp(tag, entry.tag, tag_len)) {
|
||||||
++i) {
|
sys_info->cpu.arm_cpu_info.elf_hwcaps |= entry.hwcaps;
|
||||||
const CpuFeaturesEntry* entry = &cpu_features_entries[i];
|
|
||||||
if (tag_len == strlen(entry->tag) &&
|
|
||||||
!memcmp(tag, entry->tag, tag_len)) {
|
|
||||||
sys_info->cpu.arm_cpu_info.elf_hwcaps |= entry->hwcaps;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user