| Index: src/debug.h
 | 
| diff --git a/src/debug.h b/src/debug.h
 | 
| index 3e2db60b8ea70e324884b085ef8068c374a38962..7209b53ad0027bdaa21a882f558bf24ffd6e2ef2 100644
 | 
| --- a/src/debug.h
 | 
| +++ b/src/debug.h
 | 
| @@ -66,83 +66,161 @@ enum BreakPositionAlignment {
 | 
|  };
 | 
|  
 | 
|  
 | 
| -// Class for iterating through the break points in a function and changing
 | 
| -// them.
 | 
| -class BreakLocationIterator {
 | 
| +class BreakLocation {
 | 
|   public:
 | 
| -  explicit BreakLocationIterator(Handle<DebugInfo> debug_info,
 | 
| -                                 BreakLocatorType type);
 | 
| -  virtual ~BreakLocationIterator();
 | 
| -
 | 
| -  void Next();
 | 
| -  void Next(int count);
 | 
| -  void FindBreakLocationFromAddress(Address pc);
 | 
| -  void FindBreakLocationFromPosition(int position,
 | 
| -      BreakPositionAlignment alignment);
 | 
| -  void Reset();
 | 
| -  bool Done() const;
 | 
| +  // Find the break point at the supplied address, or the closest one before
 | 
| +  // the address.
 | 
| +  static BreakLocation FromAddress(Handle<DebugInfo> debug_info,
 | 
| +                                   BreakLocatorType type, Address pc);
 | 
| +
 | 
| +  static void FromAddressSameStatement(Handle<DebugInfo> debug_info,
 | 
| +                                       BreakLocatorType type, Address pc,
 | 
| +                                       List<BreakLocation>* result_out);
 | 
| +
 | 
| +  static BreakLocation FromPosition(Handle<DebugInfo> debug_info,
 | 
| +                                    BreakLocatorType type, int position,
 | 
| +                                    BreakPositionAlignment alignment);
 | 
| +
 | 
| +  bool IsDebugBreak() const;
 | 
| +  inline bool IsExit() const { return RelocInfo::IsJSReturn(rmode_); }
 | 
| +  inline bool IsConstructCall() const {
 | 
| +    return RelocInfo::IsConstructCall(rmode_);
 | 
| +  }
 | 
| +  inline bool IsCodeTarget() const { return RelocInfo::IsCodeTarget(rmode_); }
 | 
| +
 | 
| +  Handle<Code> CodeTarget() const;
 | 
| +  Handle<Code> OriginalCodeTarget() const;
 | 
| +
 | 
| +  bool IsStepInLocation() const;
 | 
| +  inline bool HasBreakPoint() const {
 | 
| +    return debug_info_->HasBreakPoint(pc_offset_);
 | 
| +  }
 | 
| +
 | 
| +  Handle<Object> BreakPointObjects() const;
 | 
| +
 | 
|    void SetBreakPoint(Handle<Object> break_point_object);
 | 
|    void ClearBreakPoint(Handle<Object> break_point_object);
 | 
| +
 | 
|    void SetOneShot();
 | 
|    void ClearOneShot();
 | 
| -  bool IsStepInLocation(Isolate* isolate);
 | 
| -  bool IsExit() const;
 | 
| -  bool HasBreakPoint();
 | 
| -  bool IsDebugBreak();
 | 
| -  Object* BreakPointObjects();
 | 
| -  void ClearAllDebugBreak();
 | 
| -
 | 
|  
 | 
| -  inline int code_position() {
 | 
| -    return static_cast<int>(pc() - debug_info_->code()->entry());
 | 
| -  }
 | 
| -  inline int break_point() { return break_point_; }
 | 
| -  inline int position() { return position_; }
 | 
| -  inline int statement_position() { return statement_position_; }
 | 
| -  inline Address pc() { return reloc_iterator_->rinfo()->pc(); }
 | 
| -  inline Code* code() { return debug_info_->code(); }
 | 
| -  inline RelocInfo* rinfo() { return reloc_iterator_->rinfo(); }
 | 
| -  inline RelocInfo::Mode rmode() const {
 | 
| -    return reloc_iterator_->rinfo()->rmode();
 | 
| +  inline RelocInfo rinfo() const {
 | 
| +    return RelocInfo(pc(), rmode(), data_, code());
 | 
|    }
 | 
| -  inline RelocInfo* original_rinfo() {
 | 
| -    return reloc_iterator_original_->rinfo();
 | 
| -  }
 | 
| -  inline RelocInfo::Mode original_rmode() const {
 | 
| -    return reloc_iterator_original_->rinfo()->rmode();
 | 
| +
 | 
| +  inline RelocInfo original_rinfo() const {
 | 
| +    return RelocInfo(original_pc(), original_rmode(), original_data_,
 | 
| +                     original_code());
 | 
|    }
 | 
|  
 | 
| -  bool IsDebuggerStatement();
 | 
| +  inline int position() const { return position_; }
 | 
| +  inline int statement_position() const { return statement_position_; }
 | 
|  
 | 
| - protected:
 | 
| -  bool RinfoDone() const;
 | 
| -  void RinfoNext();
 | 
| +  inline Address pc() const { return code()->entry() + pc_offset_; }
 | 
| +  inline Address original_pc() const {
 | 
| +    return original_code()->entry() + original_pc_offset_;
 | 
| +  }
 | 
|  
 | 
| -  BreakLocatorType type_;
 | 
| -  int break_point_;
 | 
| -  int position_;
 | 
| -  int statement_position_;
 | 
| -  Handle<DebugInfo> debug_info_;
 | 
| -  RelocIterator* reloc_iterator_;
 | 
| -  RelocIterator* reloc_iterator_original_;
 | 
| +  inline RelocInfo::Mode rmode() const { return rmode_; }
 | 
| +  inline RelocInfo::Mode original_rmode() const { return original_rmode_; }
 | 
| +
 | 
| +  inline Code* code() const { return debug_info_->code(); }
 | 
| +  inline Code* original_code() const { return debug_info_->original_code(); }
 | 
|  
 | 
|   private:
 | 
| -  void SetDebugBreak();
 | 
| -  void ClearDebugBreak();
 | 
| +  BreakLocation(Handle<DebugInfo> debug_info, RelocInfo* rinfo,
 | 
| +                RelocInfo* original_rinfo, int position, int statement_position)
 | 
| +      : debug_info_(debug_info),
 | 
| +        pc_offset_(static_cast<int>(rinfo->pc() - debug_info->code()->entry())),
 | 
| +        original_pc_offset_(static_cast<int>(
 | 
| +            original_rinfo->pc() - debug_info->original_code()->entry())),
 | 
| +        rmode_(rinfo->rmode()),
 | 
| +        original_rmode_(original_rinfo->rmode()),
 | 
| +        data_(rinfo->data()),
 | 
| +        original_data_(original_rinfo->data()),
 | 
| +        position_(position),
 | 
| +        statement_position_(statement_position) {}
 | 
| +
 | 
| +  class Iterator {
 | 
| +   public:
 | 
| +    Iterator(Handle<DebugInfo> debug_info, BreakLocatorType type);
 | 
|  
 | 
| -  void SetDebugBreakAtIC();
 | 
| -  void ClearDebugBreakAtIC();
 | 
| +    BreakLocation GetBreakLocation() {
 | 
| +      return BreakLocation(debug_info_, rinfo(), original_rinfo(), position(),
 | 
| +                           statement_position());
 | 
| +    }
 | 
|  
 | 
| -  bool IsDebugBreakAtReturn();
 | 
| -  void SetDebugBreakAtReturn();
 | 
| -  void ClearDebugBreakAtReturn();
 | 
| +    inline bool Done() const { return RinfoDone(); }
 | 
| +    void Next();
 | 
| +
 | 
| +    void SkipTo(int count) {
 | 
| +      while (count-- > 0) Next();
 | 
| +    }
 | 
| +
 | 
| +    inline RelocInfo::Mode rmode() { return reloc_iterator_.rinfo()->rmode(); }
 | 
| +    inline RelocInfo::Mode original_rmode() {
 | 
| +      return reloc_iterator_.rinfo()->rmode();
 | 
| +    }
 | 
|  
 | 
| -  bool IsDebugBreakSlot();
 | 
| -  bool IsDebugBreakAtSlot();
 | 
| +    inline RelocInfo* rinfo() { return reloc_iterator_.rinfo(); }
 | 
| +    inline RelocInfo* original_rinfo() {
 | 
| +      return reloc_iterator_original_.rinfo();
 | 
| +    }
 | 
| +
 | 
| +    inline Address pc() { return rinfo()->pc(); }
 | 
| +    inline Address original_pc() { return original_rinfo()->pc(); }
 | 
| +
 | 
| +    int break_index() const { return break_index_; }
 | 
| +
 | 
| +    inline int position() const { return position_; }
 | 
| +    inline int statement_position() const { return statement_position_; }
 | 
| +
 | 
| +   private:
 | 
| +    bool RinfoDone() const;
 | 
| +    void RinfoNext();
 | 
| +
 | 
| +    Handle<DebugInfo> debug_info_;
 | 
| +    BreakLocatorType type_;
 | 
| +    RelocIterator reloc_iterator_;
 | 
| +    RelocIterator reloc_iterator_original_;
 | 
| +    int break_index_;
 | 
| +    int position_;
 | 
| +    int statement_position_;
 | 
| +
 | 
| +    DisallowHeapAllocation no_gc_;
 | 
| +
 | 
| +    DISALLOW_COPY_AND_ASSIGN(Iterator);
 | 
| +  };
 | 
| +
 | 
| +  friend class Debug;
 | 
| +
 | 
| +  static int BreakIndexFromAddress(Handle<DebugInfo> debug_info,
 | 
| +                                   BreakLocatorType type, Address pc);
 | 
| +
 | 
| +  void ClearDebugBreak();
 | 
| +  void RestoreFromOriginal(int length_in_bytes);
 | 
| +
 | 
| +  void SetDebugBreak();
 | 
| +  void SetDebugBreakAtReturn();
 | 
|    void SetDebugBreakAtSlot();
 | 
| -  void ClearDebugBreakAtSlot();
 | 
| +  void SetDebugBreakAtIC();
 | 
|  
 | 
| -  DISALLOW_COPY_AND_ASSIGN(BreakLocationIterator);
 | 
| +  inline bool IsDebuggerStatement() const {
 | 
| +    return RelocInfo::IsDebuggerStatement(rmode_);
 | 
| +  }
 | 
| +  inline bool IsDebugBreakSlot() const {
 | 
| +    return RelocInfo::IsDebugBreakSlot(rmode_);
 | 
| +  }
 | 
| +
 | 
| +  Handle<DebugInfo> debug_info_;
 | 
| +  int pc_offset_;
 | 
| +  int original_pc_offset_;
 | 
| +  RelocInfo::Mode rmode_;
 | 
| +  RelocInfo::Mode original_rmode_;
 | 
| +  intptr_t data_;
 | 
| +  intptr_t original_data_;
 | 
| +  int position_;
 | 
| +  int statement_position_;
 | 
|  };
 | 
|  
 | 
|  
 | 
| @@ -403,8 +481,7 @@ class Debug {
 | 
|    void ClearStepping();
 | 
|    void ClearStepOut();
 | 
|    bool IsStepping() { return thread_local_.step_count_ > 0; }
 | 
| -  bool StepNextContinue(BreakLocationIterator* break_location_iterator,
 | 
| -                        JavaScriptFrame* frame);
 | 
| +  bool StepNextContinue(BreakLocation* location, JavaScriptFrame* frame);
 | 
|    bool StepInActive() { return thread_local_.step_into_fp_ != 0; }
 | 
|    void HandleStepIn(Handle<Object> function_obj, Handle<Object> holder,
 | 
|                      Address fp, bool is_constructor);
 | 
| @@ -422,13 +499,11 @@ class Debug {
 | 
|    static bool HasDebugInfo(Handle<SharedFunctionInfo> shared);
 | 
|  
 | 
|    // This function is used in FunctionNameUsing* tests.
 | 
| -  Object* FindSharedFunctionInfoInScript(Handle<Script> script, int position);
 | 
| +  Handle<Object> FindSharedFunctionInfoInScript(Handle<Script> script,
 | 
| +                                                int position);
 | 
|  
 | 
|    // Returns true if the current stub call is patched to call the debugger.
 | 
|    static bool IsDebugBreak(Address addr);
 | 
| -  // Returns true if the current return statement has been patched to be
 | 
| -  // a debugger breakpoint.
 | 
| -  static bool IsDebugBreakAtReturn(RelocInfo* rinfo);
 | 
|  
 | 
|    static Handle<Object> GetSourceBreakLocations(
 | 
|        Handle<SharedFunctionInfo> shared,
 | 
| 
 |