Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(120)

Side by Side Diff: src/processor/dump_context.cc

Issue 1210943005: Use general instruction/stack pointer convenience method instead of manually (Closed) Base URL: http://google-breakpad.googlecode.com/svn/trunk/
Patch Set: Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/google_breakpad/processor/dump_context.h ('k') | src/processor/exploitability_linux.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 Google Inc. 1 // Copyright (c) 2010 Google Inc.
2 // All rights reserved. 2 // All rights reserved.
3 // 3 //
4 // Redistribution and use in source and binary forms, with or without 4 // Redistribution and use in source and binary forms, with or without
5 // modification, are permitted provided that the following conditions are 5 // modification, are permitted provided that the following conditions are
6 // met: 6 // met:
7 // 7 //
8 // * Redistributions of source code must retain the above copyright 8 // * Redistributions of source code must retain the above copyright
9 // notice, this list of conditions and the following disclaimer. 9 // notice, this list of conditions and the following disclaimer.
10 // * Redistributions in binary form must reproduce the above 10 // * Redistributions in binary form must reproduce the above
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
178 *ip = GetContextMIPS()->epc; 178 *ip = GetContextMIPS()->epc;
179 break; 179 break;
180 default: 180 default:
181 // This should never happen. 181 // This should never happen.
182 BPLOG(ERROR) << "Unknown CPU architecture in GetInstructionPointer"; 182 BPLOG(ERROR) << "Unknown CPU architecture in GetInstructionPointer";
183 return false; 183 return false;
184 } 184 }
185 return true; 185 return true;
186 } 186 }
187 187
188 bool DumpContext::GetStackPointer(uint64_t* sp) const {
189 BPLOG_IF(ERROR, !sp) << "DumpContext::GetStackPointer requires |sp|";
190 assert(sp);
191 *sp = 0;
192
193 if (!valid_) {
194 BPLOG(ERROR) << "Invalid DumpContext for GetStackPointer";
195 return false;
196 }
197
198 switch (GetContextCPU()) {
199 case MD_CONTEXT_AMD64:
200 *sp = GetContextAMD64()->rsp;
201 break;
202 case MD_CONTEXT_ARM:
203 *sp = GetContextARM()->iregs[MD_CONTEXT_ARM_REG_SP];
204 break;
205 case MD_CONTEXT_ARM64:
206 *sp = GetContextARM64()->iregs[MD_CONTEXT_ARM64_REG_SP];
207 break;
208 case MD_CONTEXT_PPC:
209 *sp = GetContextPPC()->gpr[MD_CONTEXT_PPC_REG_SP];
210 break;
211 case MD_CONTEXT_PPC64:
212 *sp = GetContextPPC64()->gpr[MD_CONTEXT_PPC64_REG_SP];
213 break;
214 case MD_CONTEXT_SPARC:
215 *sp = GetContextSPARC()->g_r[MD_CONTEXT_SPARC_REG_SP];
216 break;
217 case MD_CONTEXT_X86:
218 *sp = GetContextX86()->esp;
219 break;
220 case MD_CONTEXT_MIPS:
221 *sp = GetContextMIPS()->iregs[MD_CONTEXT_MIPS_REG_SP];
222 break;
223 default:
224 // This should never happen.
225 BPLOG(ERROR) << "Unknown CPU architecture in GetStackPointer";
226 return false;
227 }
228 return true;
229 }
230
188 void DumpContext::SetContextFlags(uint32_t context_flags) { 231 void DumpContext::SetContextFlags(uint32_t context_flags) {
189 context_flags_ = context_flags; 232 context_flags_ = context_flags;
190 } 233 }
191 234
192 void DumpContext::SetContextX86(MDRawContextX86* x86) { 235 void DumpContext::SetContextX86(MDRawContextX86* x86) {
193 context_.x86 = x86; 236 context_.x86 = x86;
194 } 237 }
195 238
196 void DumpContext::SetContextPPC(MDRawContextPPC* ppc) { 239 void DumpContext::SetContextPPC(MDRawContextPPC* ppc) {
197 context_.ppc = ppc; 240 context_.ppc = ppc;
(...skipping 407 matching lines...) Expand 10 before | Expand all | Expand 10 after
605 break; 648 break;
606 } 649 }
607 650
608 default: { 651 default: {
609 break; 652 break;
610 } 653 }
611 } 654 }
612 } 655 }
613 656
614 } // namespace google_breakpad 657 } // namespace google_breakpad
OLDNEW
« no previous file with comments | « src/google_breakpad/processor/dump_context.h ('k') | src/processor/exploitability_linux.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698