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

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

Issue 459002: Refactor the logic of resolving source line info into helper class (Closed) Base URL: http://google-breakpad.googlecode.com/svn/trunk/src/
Patch Set: Update header guard in new header file. Created 12 years, 5 months ago
Left:
Right:
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 unified diff | Download patch
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 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 { "$esi", NULL, true, 74 { "$esi", NULL, true,
75 StackFrameX86::CONTEXT_VALID_ESI, &MDRawContextX86::esi }, 75 StackFrameX86::CONTEXT_VALID_ESI, &MDRawContextX86::esi },
76 { "$edi", NULL, true, 76 { "$edi", NULL, true,
77 StackFrameX86::CONTEXT_VALID_EDI, &MDRawContextX86::edi }, 77 StackFrameX86::CONTEXT_VALID_EDI, &MDRawContextX86::edi },
78 }; 78 };
79 79
80 StackwalkerX86::StackwalkerX86(const SystemInfo *system_info, 80 StackwalkerX86::StackwalkerX86(const SystemInfo *system_info,
81 const MDRawContextX86 *context, 81 const MDRawContextX86 *context,
82 MemoryRegion *memory, 82 MemoryRegion *memory,
83 const CodeModules *modules, 83 const CodeModules *modules,
84 SymbolSupplier *supplier, 84 StackFrameSymbolizer *resolver_helper)
Ted Mielczarek 2012/10/09 12:30:54 * next to type name.
SiyangXie 2012/10/10 20:28:43 Done.
85 SourceLineResolverInterface *resolver) 85 : Stackwalker(system_info, memory, modules, resolver_helper),
86 : Stackwalker(system_info, memory, modules, supplier, resolver),
87 context_(context), 86 context_(context),
88 cfi_walker_(cfi_register_map_, 87 cfi_walker_(cfi_register_map_,
89 (sizeof(cfi_register_map_) / sizeof(cfi_register_map_[0]))) { 88 (sizeof(cfi_register_map_) / sizeof(cfi_register_map_[0]))) {
90 if (memory_->GetBase() + memory_->GetSize() - 1 > 0xffffffff) { 89 if (memory_->GetBase() + memory_->GetSize() - 1 > 0xffffffff) {
91 // The x86 is a 32-bit CPU, the limits of the supplied stack are invalid. 90 // The x86 is a 32-bit CPU, the limits of the supplied stack are invalid.
92 // Mark memory_ = NULL, which will cause stackwalking to fail. 91 // Mark memory_ = NULL, which will cause stackwalking to fail.
93 BPLOG(ERROR) << "Memory out of range for stackwalking: " << 92 BPLOG(ERROR) << "Memory out of range for stackwalking: " <<
94 HexString(memory_->GetBase()) << "+" << 93 HexString(memory_->GetBase()) << "+" <<
95 HexString(memory_->GetSize()); 94 HexString(memory_->GetSize());
96 memory_ = NULL; 95 memory_ = NULL;
(...skipping 454 matching lines...) Expand 10 before | Expand all | Expand 10 after
551 BPLOG(ERROR) << "Can't get caller frame without memory or stack"; 550 BPLOG(ERROR) << "Can't get caller frame without memory or stack";
552 return NULL; 551 return NULL;
553 } 552 }
554 553
555 const vector<StackFrame *> &frames = *stack->frames(); 554 const vector<StackFrame *> &frames = *stack->frames();
556 StackFrameX86 *last_frame = static_cast<StackFrameX86 *>(frames.back()); 555 StackFrameX86 *last_frame = static_cast<StackFrameX86 *>(frames.back());
557 scoped_ptr<StackFrameX86> new_frame; 556 scoped_ptr<StackFrameX86> new_frame;
558 557
559 // If the resolver has Windows stack walking information, use that. 558 // If the resolver has Windows stack walking information, use that.
560 WindowsFrameInfo *windows_frame_info 559 WindowsFrameInfo *windows_frame_info
561 = resolver_ ? resolver_->FindWindowsFrameInfo(last_frame) : NULL; 560 = frame_symbolizer_->FindWindowsFrameInfo(last_frame);
562 if (windows_frame_info) 561 if (windows_frame_info)
563 new_frame.reset(GetCallerByWindowsFrameInfo(frames, windows_frame_info)); 562 new_frame.reset(GetCallerByWindowsFrameInfo(frames, windows_frame_info));
564 563
565 // If the resolver has DWARF CFI information, use that. 564 // If the resolver has DWARF CFI information, use that.
566 if (!new_frame.get()) { 565 if (!new_frame.get()) {
567 CFIFrameInfo *cfi_frame_info = 566 CFIFrameInfo *cfi_frame_info =
568 resolver_ ? resolver_->FindCFIFrameInfo(last_frame) : NULL; 567 frame_symbolizer_->FindCFIFrameInfo(last_frame);
569 if (cfi_frame_info) 568 if (cfi_frame_info)
570 new_frame.reset(GetCallerByCFIFrameInfo(frames, cfi_frame_info)); 569 new_frame.reset(GetCallerByCFIFrameInfo(frames, cfi_frame_info));
571 } 570 }
572 571
573 // Otherwise, hope that the program was using a traditional frame structure. 572 // Otherwise, hope that the program was using a traditional frame structure.
574 if (!new_frame.get()) 573 if (!new_frame.get())
575 new_frame.reset(GetCallerByEBPAtBase(frames)); 574 new_frame.reset(GetCallerByEBPAtBase(frames));
576 575
577 // If nothing worked, tell the caller. 576 // If nothing worked, tell the caller.
578 if (!new_frame.get()) 577 if (!new_frame.get())
(...skipping 16 matching lines...) Expand all
595 // the CALL, which is sufficient to get the source line information to 594 // the CALL, which is sufficient to get the source line information to
596 // match up with the line that contains a function call. Callers that 595 // match up with the line that contains a function call. Callers that
597 // require the exact return address value may access the context.eip 596 // require the exact return address value may access the context.eip
598 // field of StackFrameX86. 597 // field of StackFrameX86.
599 new_frame->instruction = new_frame->context.eip - 1; 598 new_frame->instruction = new_frame->context.eip - 1;
600 599
601 return new_frame.release(); 600 return new_frame.release();
602 } 601 }
603 602
604 } // namespace google_breakpad 603 } // namespace google_breakpad
OLDNEW

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