mirror of
https://github.com/yuzu-emu/breakpad.git
synced 2025-01-06 12:45:46 +00:00
Issue 208: Reviewer waylonis
git-svn-id: http://google-breakpad.googlecode.com/svn/trunk@209 4c0a9323-5329-0410-9bdc-e9ce6186880e
This commit is contained in:
parent
649967cfd2
commit
30dfc3d392
|
@ -41,29 +41,67 @@ namespace google_breakpad {
|
||||||
//==============================================================================
|
//==============================================================================
|
||||||
// Returns the size of the memory region containing |address| and the
|
// Returns the size of the memory region containing |address| and the
|
||||||
// number of bytes from |address| to the end of the region.
|
// number of bytes from |address| to the end of the region.
|
||||||
|
// We potentially, will extend the size of the original
|
||||||
|
// region by the size of the following region if it's contiguous with the
|
||||||
|
// first in order to handle cases when we're reading strings and they
|
||||||
|
// straddle two vm regions.
|
||||||
|
//
|
||||||
static vm_size_t GetMemoryRegionSize(task_port_t target_task,
|
static vm_size_t GetMemoryRegionSize(task_port_t target_task,
|
||||||
const void* address,
|
const void* address,
|
||||||
vm_size_t *size_to_end) {
|
vm_size_t *size_to_end) {
|
||||||
vm_address_t stack_region_base = (vm_address_t)address;
|
vm_address_t region_base = (vm_address_t)address;
|
||||||
vm_size_t stack_region_size;
|
vm_size_t region_size;
|
||||||
natural_t nesting_level = 0;
|
natural_t nesting_level = 0;
|
||||||
vm_region_submap_info submap_info;
|
vm_region_submap_info submap_info;
|
||||||
mach_msg_type_number_t info_count = VM_REGION_SUBMAP_INFO_COUNT;
|
mach_msg_type_number_t info_count = VM_REGION_SUBMAP_INFO_COUNT;
|
||||||
|
|
||||||
|
// Get information about the vm region containing |address|
|
||||||
kern_return_t result =
|
kern_return_t result =
|
||||||
vm_region_recurse(target_task, &stack_region_base, &stack_region_size,
|
vm_region_recurse(target_task,
|
||||||
|
®ion_base,
|
||||||
|
®ion_size,
|
||||||
&nesting_level,
|
&nesting_level,
|
||||||
reinterpret_cast<vm_region_recurse_info_t>(&submap_info),
|
reinterpret_cast<vm_region_recurse_info_t>(&submap_info),
|
||||||
&info_count);
|
&info_count);
|
||||||
|
|
||||||
if (result == KERN_SUCCESS) {
|
if (result == KERN_SUCCESS) {
|
||||||
*size_to_end = stack_region_base + stack_region_size - (vm_address_t)address;
|
// Get distance from |address| to the end of this region
|
||||||
|
*size_to_end = region_base + region_size -(vm_address_t)address;
|
||||||
|
|
||||||
|
// If we want to handle strings as long as 4096 characters we may need
|
||||||
|
// to check if there's a vm region immediately following the first one.
|
||||||
|
// If so, we need to extend |*size_to_end| to go all the way to the end
|
||||||
|
// of the second region.
|
||||||
|
if (*size_to_end < 4096) {
|
||||||
|
// Second region starts where the first one ends
|
||||||
|
vm_address_t region_base2 =
|
||||||
|
(vm_address_t)(region_base + region_size);
|
||||||
|
vm_size_t region_size2;
|
||||||
|
|
||||||
|
// Get information about the following vm region
|
||||||
|
result =
|
||||||
|
vm_region_recurse(
|
||||||
|
target_task,
|
||||||
|
®ion_base2,
|
||||||
|
®ion_size2,
|
||||||
|
&nesting_level,
|
||||||
|
reinterpret_cast<vm_region_recurse_info_t>(&submap_info),
|
||||||
|
&info_count);
|
||||||
|
|
||||||
|
// Extend region_size to go all the way to the end of the 2nd region
|
||||||
|
if (result == KERN_SUCCESS
|
||||||
|
&& region_base2 == region_base + region_size) {
|
||||||
|
region_size += region_size2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
*size_to_end = region_base + region_size -(vm_address_t)address;
|
||||||
} else {
|
} else {
|
||||||
stack_region_size = 0;
|
region_size = 0;
|
||||||
*size_to_end = 0;
|
*size_to_end = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
return stack_region_size;
|
return region_size;
|
||||||
}
|
}
|
||||||
|
|
||||||
#define kMaxStringLength 8192
|
#define kMaxStringLength 8192
|
||||||
|
|
Loading…
Reference in a new issue