Commit | Line | Data |
---|---|---|
920dae64 AT |
1 | // ========== Copyright Header Begin ========================================== |
2 | // | |
3 | // OpenSPARC T2 Processor File: SS_BreakPoint.cc | |
4 | // Copyright (c) 2006 Sun Microsystems, Inc. All Rights Reserved. | |
5 | // DO NOT ALTER OR REMOVE COPYRIGHT NOTICES. | |
6 | // | |
7 | // The above named program is free software; you can redistribute it and/or | |
8 | // modify it under the terms of the GNU General Public | |
9 | // License version 2 as published by the Free Software Foundation. | |
10 | // | |
11 | // The above named program is distributed in the hope that it will be | |
12 | // useful, but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
14 | // General Public License for more details. | |
15 | // | |
16 | // You should have received a copy of the GNU General Public | |
17 | // License along with this work; if not, write to the Free Software | |
18 | // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. | |
19 | // | |
20 | // ========== Copyright Header End ============================================ | |
21 | ||
22 | #include "SS_BreakPoint.h" | |
23 | #include "SS_Signal.h" | |
24 | #include "SS_Strand.h" | |
25 | ||
26 | BL_Mutex SS_BreakPoint::id_mutex; | |
27 | SS_BreakPoint::Ident SS_BreakPoint::id_count = 0; | |
28 | ||
29 | SS_BreakPoint::SS_BreakPoint( Break _type, SS_BreakPoint* _next )/*{{{*/ | |
30 | : | |
31 | type(_type), | |
32 | enabled(true), | |
33 | triggered(false), | |
34 | next(_next), | |
35 | link(0) | |
36 | { | |
37 | id_mutex.lock(); | |
38 | id = id_count; | |
39 | id_count++; | |
40 | id_mutex.unlock(); | |
41 | } | |
42 | /*}}}*/ | |
43 | bool SS_BreakPoint::trigger( SS_Strand* s )/*{{{*/ | |
44 | { | |
45 | if (triggered) | |
46 | { | |
47 | triggered = false; | |
48 | } | |
49 | else | |
50 | { | |
51 | triggered = true; | |
52 | SS_Signal* sgn = s->msg.make_signal(SS_Signal::BREAKPOINT); | |
53 | sgn->breakpoint = this; | |
54 | s->post_signal(sgn); | |
55 | ||
56 | // In case of trc_step(1) we should get out of the loop | |
57 | // signaling a breakpoint. Breaks are reported to the | |
58 | // UI though a non zero return of step. See SS_Strand::trc_step() | |
59 | // for why we set break_hit prematurely. | |
60 | ||
61 | s->break_hit = this; | |
62 | } | |
63 | return triggered; | |
64 | } | |
65 | /*}}}*/ | |
66 | void SS_BreakPoint::unlink( SS_BreakPoint** root )/*{{{*/ | |
67 | { | |
68 | SS_BreakPoint* prev = 0; | |
69 | SS_BreakPoint* help = *root; | |
70 | ||
71 | while (help != this) | |
72 | { | |
73 | prev = help; | |
74 | help = help->link; | |
75 | } | |
76 | (prev ? prev->link : *root) = this->link; | |
77 | } | |
78 | /*}}}*/ | |
79 | ||
80 | extern "C" SS_Vaddr run_exe_breakpoint( SS_Vaddr pc, SS_Vaddr npc, SS_Strand* s, SS_Instr* i )/*{{{*/ | |
81 | { | |
82 | SS_BreakPoint* bp = i->bp; | |
83 | ||
84 | if (bp->enabled) | |
85 | { | |
86 | if (bp->triggered) | |
87 | { | |
88 | bp->triggered = false; | |
89 | } | |
90 | else | |
91 | { | |
92 | bp->triggered = true; | |
93 | SS_Signal* sgn = s->msg.make_signal(SS_Signal::BREAKPOINT); | |
94 | sgn->breakpoint = bp; | |
95 | s->post_signal(sgn); | |
96 | return pc; | |
97 | } | |
98 | } | |
99 | return (bp->inst.exe)(pc,npc,s,&bp->inst); | |
100 | } | |
101 | /*}}}*/ | |
102 | void SS_BreakPoint::remove()/*{{{*/ | |
103 | { | |
104 | orig->exe = inst.exe; | |
105 | orig->rs1 = inst.rs1; | |
106 | orig->rs2 = inst.rs2; | |
107 | orig->rs3 = inst.rs3; | |
108 | orig->rd = inst.rd; | |
109 | orig->bp = inst.bp; | |
110 | orig->opc = inst.opc; | |
111 | orig->flg = inst.flg; | |
112 | } | |
113 | /*}}}*/ |