OSDN Git Service

* dll_init.cc (dll_global_dtors): Add an additional test to avoid walking the
[pf3gnuchains/pf3gnuchains3x.git] / gdb / gdbtk / plugins / intel-pentium / msrselection.itb
1 # Implements MSR selection dialog class for Insight.
2 # Copyright (C) 1999, 2000, 2001 Red Hat, Inc.
3 #
4 # Written by Fernando Nasser  <fnasser@redhat.com>
5 #
6 # This program is free software; you can redistribute it and/or modify it
7 # under the terms of the GNU General Public License (GPL) as published by
8 # the Free Software Foundation; either version 2 of the License, or (at
9 # your option) any later version.
10 #
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 # GNU General Public License for more details.
15
16 # ------------------------------------------------------------------
17 #  NAME:         MsrSelDlg::constructor
18 #  DESCRIPTION:  Create a new MSR Selection dialog window.
19 #
20 #  ARGUMENTS:    None
21 #  RETURNS:      Nothing
22 # ------------------------------------------------------------------
23 body MsrSelDlg::constructor {args} {
24
25   window_name "MSR Selection"
26   build_win
27   eval itk_initialize $args
28
29 }
30
31 # ------------------------------------------------------------------
32 #  NAME:         protected method MsrSelDlg::build_win
33 #  DESCRIPTION:  Builds the MSR dialog window from widgets.
34 #
35 #  ARGUMENTS:    None
36 #  RETURNS:      Nothing
37 #
38 #  NOTES:        This method should only be called once for
39 #                each MsrSelDlg.
40 # ------------------------------------------------------------------
41 body MsrSelDlg::build_win {} {
42   
43   # CHOOSE_MSR: the list box with list of MSRs.  Also an entry
44   # for typing in the MSR by hand.
45
46   itk_component add choose_msr {
47     iwidgets::scrolledlistbox $itk_interior.cmsr -visibleitems 30x15 \
48       -labeltext "Choose MSR" -labelpos nw \
49       -labelrelief groove -labelborderwidth 2 \
50       -ipadx 8 -ipady 6 -childsitepos s -hscrollmode none \
51       -textbackground white -exportselection 0 \
52       -selectioncommand [code $this select_msr] \
53       -dblclickcommand [code $this doit]
54   }
55
56   # MSR_ENTRY: this is the MSR entry box.  You can enter the MSR register name
57   # by hand here, or click on the listbox to have it entered for you.
58
59   itk_component add msr_entry {
60     iwidgets::entryfield [$itk_component(choose_msr) childsite].lab \
61       -labeltext MSR: -textbackground white \
62       -focuscommand [code $this clear_msr_selection] \
63       -command [code $this doit]
64   }
65   pack $itk_component(msr_entry) -fill x -side bottom -pady 4
66   
67   itk_component add button_box {
68     frame $itk_interior.b
69   }
70   
71   itk_component add ok {
72     button $itk_component(button_box).ok -text OK -command [code $this doit]
73   }
74   $itk_component(ok) configure -state disabled
75
76   itk_component add cancel {
77     button $itk_component(button_box).cancel -text Cancel \
78       -command [code $this cancel]
79   }
80
81   ::standard_button_box $itk_component(button_box)
82
83   pack $itk_component(button_box) -side bottom -fill x \
84     -pady 4 -padx 4
85   pack $itk_component(choose_msr) -fill both -expand 1 -pady 4 -padx 4
86
87   after idle [list update idletasks;  $this list_msrs]
88
89 }
90
91 # ------------------------------------------------------------------
92 #  NAME:         protected method MsrSelDlg::doit
93 #  DESCRIPTION:  Selects the MSR to view and unposts window.
94 #
95 #  ARGUMENTS:    None
96 #  RETURNS:      Nothing
97 #
98 #  NOTES:        
99 # ------------------------------------------------------------------
100 body MsrSelDlg::doit {} {
101   set MsrSelDlg::last_button 1
102   set msr [$itk_component(msr_entry) get]
103   set MsrSelDlg::last_msr $msr
104
105   if {[catch {gdb_cmd "set msr-pointer $msr"} result]} {
106     ManagedWin::open WarningDlg -transient \
107                     -message [list "Could not select this $msr:\n$result"]
108   }
109
110   debug "About to unpost"
111   unpost
112 }
113
114 # ------------------------------------------------------------------
115 #  NAME:         protected method MsrSelDlg::cancel
116 #  DESCRIPTION:  Unposts the window without selecting
117 #                the MSR to view.
118 #
119 #  ARGUMENTS:    None
120 #  RETURNS:      Nothing
121 #
122 #  NOTES:        
123 # ------------------------------------------------------------------
124 body MsrSelDlg::cancel {} {
125   set MsrSelDlg::last_button 0
126   set MsrSelDlg::last_msr {}
127   unpost
128 }
129
130 # ------------------------------------------------------------------
131 #  NAME:         protected method MsrSelDlg::list_msrs
132 #  DESCRIPTION:  List the known MSR names.
133 #
134 #  ARGUMENTS:    None
135 #  RETURNS:      Nothing
136 #
137 #  NOTES:        
138 # ------------------------------------------------------------------
139 body MsrSelDlg::list_msrs {{expr {}}} {
140   set err [catch {gdb_cmd "set msr-pointer" 1} msg ]
141   set msg [string trimright $msg "."]
142   set msrnames [split $msg ,]
143   set msrnames [lrange $msrnames 1 end]
144
145   $itk_component(choose_msr) clear
146   set msr_list {}
147
148   foreach name $msrnames {
149     lappend msr_list [list $name {set msr $name}]
150     $itk_component(choose_msr) insert end $name
151   }
152
153   $itk_component(choose_msr) selection set 0
154   select_msr
155 }
156
157 # ------------------------------------------------------------------
158 #  NAME:         protected method MsrSelDlg::select_msrs
159 #  DESCRIPTION:  Grab the selected element from the MSR listbox
160 #                and insert the associated MSR into the entry form.
161 #
162 #  ARGUMENTS:    None
163 #  RETURNS:      Nothing
164 #
165 #  NOTES:        
166 # ------------------------------------------------------------------
167 body MsrSelDlg::select_msr {} {
168   set hit [$itk_component(choose_msr) curselection]
169   if {$hit != ""} {
170     $itk_component(msr_entry) clear
171     $itk_component(msr_entry) insert 0 [lindex [lindex $msr_list $hit] 0]
172     $itk_component(ok) configure -state normal
173   }
174 }
175
176 # ------------------------------------------------------------------
177 #  METHOD:  clear_msr_selection - Clear the current MSR selection.
178 # ------------------------------------------------------------------
179 # ------------------------------------------------------------------
180 #  NAME:         protected method MsrSelDlg::clear_msrs_selection
181 #  DESCRIPTION:  Clear the current MSR selection.
182 #
183 #  ARGUMENTS:    None
184 #  RETURNS:      Nothing
185 #
186 #  NOTES:        
187 # ------------------------------------------------------------------
188 body MsrSelDlg::clear_msr_selection {} {
189   $itk_component(choose_msr) selection clear 0 end
190   $itk_component(msr_entry) selection range 0 end
191 }
192