Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(1)

Unified Diff: src/processor/stackwalker_x86.cc

Issue 535002: Use stdint types everywhere. (Closed)
Patch Set: Renamed uint128_t to uint128_struct Created 12 years ago
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: src/processor/stackwalker_x86.cc
===================================================================
--- a/src/processor/stackwalker_x86.cc
+++ b/src/processor/stackwalker_x86.cc
@@ -101,17 +101,17 @@ StackFrameX86::~StackFrameX86() {
if (windows_frame_info)
delete windows_frame_info;
windows_frame_info = NULL;
if (cfi_frame_info)
delete cfi_frame_info;
cfi_frame_info = NULL;
}
-u_int64_t StackFrameX86::ReturnAddress() const
+uint64_t StackFrameX86::ReturnAddress() const
{
assert(context_validity & StackFrameX86::CONTEXT_VALID_EIP);
return context.eip;
}
StackFrame* StackwalkerX86::GetContextFrame() {
if (!context_) {
BPLOG(ERROR) << "Can't get context frame without context";
@@ -174,17 +174,17 @@ StackFrameX86* StackwalkerX86::GetCaller
// If the last frame has no callee (because it's the context frame), just
// set the callee parameter size to 0: the stack pointer can't point to
// callee arguments because there's no callee. This is correct as long
// as the context wasn't captured while arguments were being pushed for
// a function call. Note that there may be functions whose parameter sizes
// are unknown, 0 is also used in that case. When that happens, it should
// be possible to walk to the next frame without reference to %esp.
- u_int32_t last_frame_callee_parameter_size = 0;
+ uint32_t last_frame_callee_parameter_size = 0;
int frames_already_walked = frames.size();
if (frames_already_walked >= 2) {
const StackFrameX86* last_frame_callee
= static_cast<StackFrameX86*>(frames[frames_already_walked - 2]);
WindowsFrameInfo* last_frame_callee_info
= last_frame_callee->windows_frame_info;
if (last_frame_callee_info &&
(last_frame_callee_info->valid
@@ -192,36 +192,36 @@ StackFrameX86* StackwalkerX86::GetCaller
last_frame_callee_parameter_size =
last_frame_callee_info->parameter_size;
}
}
// Set up the dictionary for the PostfixEvaluator. %ebp and %esp are used
// in each program string, and their previous values are known, so set them
// here.
- PostfixEvaluator<u_int32_t>::DictionaryType dictionary;
+ PostfixEvaluator<uint32_t>::DictionaryType dictionary;
// Provide the current register values.
dictionary["$ebp"] = last_frame->context.ebp;
dictionary["$esp"] = last_frame->context.esp;
// Provide constants from the debug info for last_frame and its callee.
// .cbCalleeParams is a Breakpad extension that allows us to use the
// PostfixEvaluator engine when certain types of debugging information
// are present without having to write the constants into the program
// string as literals.
dictionary[".cbCalleeParams"] = last_frame_callee_parameter_size;
dictionary[".cbSavedRegs"] = last_frame_info->saved_register_size;
dictionary[".cbLocals"] = last_frame_info->local_size;
- u_int32_t raSearchStart = last_frame->context.esp +
+ uint32_t raSearchStart = last_frame->context.esp +
last_frame_callee_parameter_size +
last_frame_info->local_size +
last_frame_info->saved_register_size;
- u_int32_t raSearchStartOld = raSearchStart;
- u_int32_t found = 0; // dummy value
+ uint32_t raSearchStartOld = raSearchStart;
+ uint32_t found = 0; // dummy value
// Scan up to three words above the calculated search value, in case
// the stack was aligned to a quadword boundary.
if (ScanForReturnAddress(raSearchStart, &raSearchStart, &found, 3) &&
last_frame->trust == StackFrame::FRAME_TRUST_CONTEXT &&
last_frame->windows_frame_info != NULL &&
last_frame_info->type_ == WindowsFrameInfo::STACK_INFO_FPO &&
raSearchStartOld == raSearchStart &&
found == last_frame->context.eip) {
@@ -321,30 +321,30 @@ StackFrameX86* StackwalkerX86::GetCaller
// %ebp_new = %ebp_old
program_string = "$eip .raSearchStart ^ = "
"$esp .raSearchStart 4 + =";
recover_ebp = false;
}
// Now crank it out, making sure that the program string set at least the
// two required variables.
- PostfixEvaluator<u_int32_t> evaluator =
- PostfixEvaluator<u_int32_t>(&dictionary, memory_);
- PostfixEvaluator<u_int32_t>::DictionaryValidityType dictionary_validity;
+ PostfixEvaluator<uint32_t> evaluator =
+ PostfixEvaluator<uint32_t>(&dictionary, memory_);
+ PostfixEvaluator<uint32_t>::DictionaryValidityType dictionary_validity;
if (!evaluator.Evaluate(program_string, &dictionary_validity) ||
dictionary_validity.find("$eip") == dictionary_validity.end() ||
dictionary_validity.find("$esp") == dictionary_validity.end()) {
// Program string evaluation failed. It may be that %eip is not somewhere
// with stack frame info, and %ebp is pointing to non-stack memory, so
// our evaluation couldn't succeed. We'll scan the stack for a return
// address. This can happen if the stack is in a module for which
// we don't have symbols, and that module is compiled without a
// frame pointer.
- u_int32_t location_start = last_frame->context.esp;
- u_int32_t location, eip;
+ uint32_t location_start = last_frame->context.esp;
+ uint32_t location, eip;
if (!ScanForReturnAddress(location_start, &location, &eip)) {
// if we can't find an instruction pointer even with stack scanning,
// give up.
return NULL;
}
// This seems like a reasonable return address. Since program string
// evaluation failed, use it and set %esp to the location above the
@@ -371,22 +371,22 @@ StackFrameX86* StackwalkerX86::GetCaller
// solution is to check the minidump's memory map to see if the candidate
// %eip value comes from a mapped executable page, although this would
// require dumps that contain MINIDUMP_MEMORY_INFO, which the Breakpad
// client doesn't currently write (it would need to call MiniDumpWriteDump
// with the MiniDumpWithFullMemoryInfo type bit set). Even given this
// ability, older OSes (pre-XP SP2) and CPUs (pre-P4) don't enforce
// an independent execute privilege on memory pages.
- u_int32_t eip = dictionary["$eip"];
+ uint32_t eip = dictionary["$eip"];
if (modules_ && !modules_->GetModuleForAddress(eip)) {
// The instruction pointer at .raSearchStart was invalid, so start
// looking one 32-bit word above that location.
- u_int32_t location_start = dictionary[".raSearchStart"] + 4;
- u_int32_t location;
+ uint32_t location_start = dictionary[".raSearchStart"] + 4;
+ uint32_t location;
if (ScanForReturnAddress(location_start, &location, &eip)) {
// This is a better return address that what program string
// evaluation found. Use it, and set %esp to the location above the
// one where the return address was found.
dictionary["$eip"] = eip;
dictionary["$esp"] = location + 4;
offset = location - location_start;
trust = StackFrame::FRAME_TRUST_CFI_SCAN;
@@ -396,32 +396,32 @@ StackFrameX86* StackwalkerX86::GetCaller
if (recover_ebp) {
// When trying to recover the previous value of the frame pointer (%ebp),
// start looking at the lowest possible address in the saved-register
// area, and look at the entire saved register area, increased by the
// size of |offset| to account for additional data that may be on the
// stack. The scan is performed from the highest possible address to
// the lowest, because the expectation is that the function's prolog
// would have saved %ebp early.
- u_int32_t ebp = dictionary["$ebp"];
+ uint32_t ebp = dictionary["$ebp"];
// When a scan for return address is used, it is possible to skip one or
// more frames (when return address is not in a known module). One
// indication for skipped frames is when the value of %ebp is lower than
// the location of the return address on the stack
bool has_skipped_frames =
(trust != StackFrame::FRAME_TRUST_CFI && ebp <= raSearchStart + offset);
- u_int32_t value; // throwaway variable to check pointer validity
+ uint32_t value; // throwaway variable to check pointer validity
if (has_skipped_frames || !memory_->GetMemoryAtAddress(ebp, &value)) {
int fp_search_bytes = last_frame_info->saved_register_size + offset;
- u_int32_t location_end = last_frame->context.esp +
+ uint32_t location_end = last_frame->context.esp +
last_frame_callee_parameter_size;
- for (u_int32_t location = location_end + fp_search_bytes;
+ for (uint32_t location = location_end + fp_search_bytes;
location >= location_end;
location -= 4) {
if (!memory_->GetMemoryAtAddress(location, &ebp))
break;
if (memory_->GetMemoryAtAddress(ebp, &value)) {
// The candidate value is a pointer to the same memory region
// (the stack). Prefer it as a recovered %ebp result.
@@ -488,18 +488,18 @@ StackFrameX86* StackwalkerX86::GetCaller
return frame.release();
}
StackFrameX86* StackwalkerX86::GetCallerByEBPAtBase(
const vector<StackFrame*> &frames) {
StackFrame::FrameTrust trust;
StackFrameX86* last_frame = static_cast<StackFrameX86*>(frames.back());
- u_int32_t last_esp = last_frame->context.esp;
- u_int32_t last_ebp = last_frame->context.ebp;
+ uint32_t last_esp = last_frame->context.esp;
+ uint32_t last_ebp = last_frame->context.ebp;
// Assume that the standard %ebp-using x86 calling convention is in
// use.
//
// The typical x86 calling convention, when frame pointers are present,
// is for the calling procedure to use CALL, which pushes the return
// address onto the stack and sets the instruction pointer (%eip) to
// the entry point of the called routine. The called routine then
@@ -514,17 +514,17 @@ StackFrameX86* StackwalkerX86::GetCaller
// procedure made the CALL: 4 bytes for the return address pushed by the
// CALL itself, and 4 bytes for the callee's PUSH of the caller's frame
// pointer.
//
// %eip_new = *(%ebp_old + 4)
// %esp_new = %ebp_old + 8
// %ebp_new = *(%ebp_old)
- u_int32_t caller_eip, caller_esp, caller_ebp;
+ uint32_t caller_eip, caller_esp, caller_ebp;
if (memory_->GetMemoryAtAddress(last_ebp + 4, &caller_eip) &&
memory_->GetMemoryAtAddress(last_ebp, &caller_ebp)) {
caller_esp = last_ebp + 8;
trust = StackFrame::FRAME_TRUST_FP;
} else {
// We couldn't read the memory %ebp refers to. It may be that %ebp
// is pointing to non-stack memory. We'll scan the stack for a

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld 1004:630ec63f810e-tainted