1 | # -*- coding: utf-8 -*-
|
---|
2 | #
|
---|
3 | # TECS Generator
|
---|
4 | # Generator for TOPPERS Embedded Component System
|
---|
5 | #
|
---|
6 | # Copyright (C) 2008-2014 by TOPPERS Project
|
---|
7 | #--
|
---|
8 | # ä¸è¨èä½æ¨©è
|
---|
9 | ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
|
---|
10 | # ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ã使ç¨ã»è¤è£½ã»æ¹
|
---|
11 | # å¤ã»åé
|
---|
12 | å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
|
---|
13 | # (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
|
---|
14 | # 権表示ï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
|
---|
15 | # ã¹ã³ã¼ãä¸ã«å«ã¾ãã¦ãããã¨ï¼
|
---|
16 | # (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
|
---|
17 | # ç¨ã§ããå½¢ã§åé
|
---|
18 | å¸ããå ´åã«ã¯ï¼åé
|
---|
19 | å¸ã«ä¼´ãããã¥ã¡ã³ãï¼å©ç¨
|
---|
20 | # è
|
---|
21 | ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
|
---|
22 | # ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
|
---|
23 | # (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
|
---|
24 | # ç¨ã§ããªãå½¢ã§åé
|
---|
25 | å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
|
---|
26 | # ã¨ï¼
|
---|
27 | # (a) åé
|
---|
28 | å¸ã«ä¼´ãããã¥ã¡ã³ãï¼å©ç¨è
|
---|
29 | ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
|
---|
30 | # ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
|
---|
31 | # (b) åé
|
---|
32 | å¸ã®å½¢æ
|
---|
33 | ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSããã¸ã§ã¯ãã«
|
---|
34 | # å ±åãããã¨ï¼
|
---|
35 | # (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
|
---|
36 | # 害ãããï¼ä¸è¨èä½æ¨©è
|
---|
37 | ããã³TOPPERSããã¸ã§ã¯ããå
|
---|
38 | 責ãããã¨ï¼
|
---|
39 | # ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
|
---|
40 | # ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
|
---|
41 | ããã³TOPPERSããã¸ã§ã¯ãã
|
---|
42 | # å
|
---|
43 | 責ãããã¨ï¼
|
---|
44 | #
|
---|
45 | # æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
|
---|
46 | ã
|
---|
47 | # ãã³TOPPERSããã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
|
---|
48 | # ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
|
---|
49 | # ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ害ã«é¢ãã¦ãï¼ã
|
---|
50 | # ã®è²¬ä»»ãè² ããªãï¼
|
---|
51 | #
|
---|
52 | # $Id$
|
---|
53 | #++
|
---|
54 |
|
---|
55 | class TracePlugin < ThroughPlugin
|
---|
56 | #@cellEntry_list::[ "Cell.eEntry", "Cell2.eEntry2", ... ]
|
---|
57 | #@b_generate::bool : true : TracePlugin ãçæããå¿
|
---|
58 | è¦ããã
|
---|
59 |
|
---|
60 | #=== TracePlugin ã® initialize
|
---|
61 | # 説æ㯠ThroughPlugin (plugin.rb) ãåç
|
---|
62 | §
|
---|
63 | def initialize( cell_name, plugin_arg, next_cell, next_cell_port_name, next_cell_port_subscript, signature, celltype, caller_cell )
|
---|
64 |
|
---|
65 | @maxArrayDisplay = 16
|
---|
66 | @cellEntry_list = []
|
---|
67 | @probeName = ""
|
---|
68 | @b_generate = false
|
---|
69 | @b_displayTime = false
|
---|
70 | @kernelCelltype = :"tKernel"
|
---|
71 | @syslogCelltype = :"tSysLog"
|
---|
72 |
|
---|
73 | super
|
---|
74 | @plugin_arg_check_proc_tab = TracePluginArgProc
|
---|
75 | parse_plugin_arg
|
---|
76 |
|
---|
77 | if @cellEntry_list.length > 0 then
|
---|
78 | @cellEntry_list.each{ |ce|
|
---|
79 | if "#{next_cell.get_name}.#{next_cell_port_name}".to_sym == ce.to_sym
|
---|
80 | @b_generate = true
|
---|
81 | end
|
---|
82 | }
|
---|
83 | else
|
---|
84 | @b_generate = true
|
---|
85 | end
|
---|
86 |
|
---|
87 | if @b_generate == false then
|
---|
88 | # å
|
---|
89 | ã
|
---|
90 | å¼ã³åºãã»ã«ã«çµåãããã®ã¨ãã
|
---|
91 | @entry_port_name = next_cell_port_name
|
---|
92 | @cell_name = next_cell.get_name
|
---|
93 | end
|
---|
94 | end
|
---|
95 |
|
---|
96 | #=== 宣è¨ã³ã¼ãã®çæ
|
---|
97 | # typedef, signature, celltype ãªã©ï¼cell 以å¤ï¼ã®ã³ã¼ããçæ
|
---|
98 | # éè¤ãã¦çæãã¦ã¯ãªããªãï¼ãã§ã«çæããã¦ããå ´åã¯åºåããªããã¨ï¼
|
---|
99 | #file:: FILE çæãããã¡ã¤ã«
|
---|
100 | def gen_plugin_decl_code( file )
|
---|
101 |
|
---|
102 | # ãã®ã»ã«ã¿ã¤ãï¼åãã·ã°ããã£ï¼ã¯æ¢ã«çæããã¦ãããï¼
|
---|
103 | if @@generated_celltype[ @ct_name ] == nil then
|
---|
104 | @@generated_celltype[ @ct_name ] = [ self ]
|
---|
105 | else
|
---|
106 | @@generated_celltype[ @ct_name ] << self
|
---|
107 | return
|
---|
108 | end
|
---|
109 |
|
---|
110 | file2 = CFile.open( "#{$gen}/#{@ct_name}.cdl", "w" )
|
---|
111 |
|
---|
112 | send_receive = []
|
---|
113 | if @signature != nil then
|
---|
114 | @signature.each_param{ |fd,param|
|
---|
115 | dir =param.get_direction
|
---|
116 | case dir
|
---|
117 | when :SEND, :RECEIVE
|
---|
118 | send_receive << [ dir, fd, param ]
|
---|
119 | end
|
---|
120 | }
|
---|
121 | end
|
---|
122 |
|
---|
123 | file2.print <<EOT
|
---|
124 | celltype #{@ct_name} {
|
---|
125 | EOT
|
---|
126 |
|
---|
127 | if send_receive.length > 0 then
|
---|
128 | file2.print " [ allocator(\n"
|
---|
129 | delim = ""
|
---|
130 | send_receive.each { |a|
|
---|
131 | file2.print "#{delim}\t#{a[1].get_name}.#{a[2].get_name}<=#{@call_port_name}.#{a[1].get_name}.#{a[2].get_name}"
|
---|
132 | delim = ",\n"
|
---|
133 | }
|
---|
134 | file2.print "\n )]\n"
|
---|
135 | end
|
---|
136 |
|
---|
137 | file2.print <<EOT
|
---|
138 | entry #{@signature.get_namespace_path} #{@entry_port_name};
|
---|
139 | call #{@signature.get_namespace_path} #{@call_port_name};
|
---|
140 | attr{
|
---|
141 | char_t *probeName_str = "";
|
---|
142 | char_t *from_str = "";
|
---|
143 | };
|
---|
144 | require #{@syslogCelltype}.eSysLog;
|
---|
145 | require #{@kernelCelltype}.eKernel;
|
---|
146 | };
|
---|
147 | EOT
|
---|
148 | # char_t *cell_port_name_str = "";
|
---|
149 |
|
---|
150 | file2.close
|
---|
151 |
|
---|
152 | file.print "import( \"#{$gen}/#{@ct_name}.cdl\" );\n"
|
---|
153 | end
|
---|
154 |
|
---|
155 | def gen_through_cell_code( file )
|
---|
156 |
|
---|
157 | gen_plugin_decl_code( file )
|
---|
158 |
|
---|
159 | if @b_generate != false then
|
---|
160 | nest = @region.gen_region_str_pre file
|
---|
161 | indent_str = " " * nest
|
---|
162 | if @next_cell_port_subscript then
|
---|
163 | subscript = '[' + @next_cell_port_subscript.to_s + ']'
|
---|
164 | else
|
---|
165 | subscript = ""
|
---|
166 | end
|
---|
167 |
|
---|
168 | if @probeName then
|
---|
169 | probeName_str = "#{indent_str} probeName_str = \"" + @probeName + ": \";\n"
|
---|
170 | else
|
---|
171 | probeName_str = ""
|
---|
172 | end
|
---|
173 | if @caller_cell then
|
---|
174 | caller_cell_str = "#{indent_str} from_str = \"#{@caller_cell.get_name}\";\n"
|
---|
175 | else
|
---|
176 | caller_cell_str = ""
|
---|
177 | end
|
---|
178 |
|
---|
179 | file.print <<EOT
|
---|
180 | #{indent_str}cell #{@ct_name} #{@cell_name} {
|
---|
181 | #{indent_str} #{@call_port_name} = #{@next_cell.get_namespace_path.get_path_str}.#{@next_cell_port_name}#{subscript};
|
---|
182 | #{probeName_str}#{caller_cell_str}#{indent_str}};
|
---|
183 | EOT
|
---|
184 | # cell_port_name_str = \"#{@next_cell.get_name}.#{@next_cell_port_name}\";
|
---|
185 | @region.gen_region_str_post file
|
---|
186 | end
|
---|
187 |
|
---|
188 | end
|
---|
189 |
|
---|
190 | def gen_ep_func_body( file, b_singleton, ct_name, global_ct_name, sig_name, ep_name, func_name, func_global_name, func_type, params )
|
---|
191 |
|
---|
192 | if ! func_type.get_type.is_void? then
|
---|
193 | file.print( "\t#{func_type.get_type_str}\tretval;\n" )
|
---|
194 | end
|
---|
195 |
|
---|
196 | file.print( "\tSYSUTM\tutime;\n" )
|
---|
197 |
|
---|
198 | if ! b_singleton then
|
---|
199 |
|
---|
200 | file.print <<EOT
|
---|
201 | \t#{ct_name}_CB *p_cellcb;
|
---|
202 | \tif( VALID_IDX( idx ) ){
|
---|
203 | \t\tp_cellcb = #{global_ct_name}_GET_CELLCB(idx);
|
---|
204 | \t}else{
|
---|
205 | \t\t/* put code here for error */
|
---|
206 | \t}
|
---|
207 |
|
---|
208 | EOT
|
---|
209 | end
|
---|
210 |
|
---|
211 | # p "celltype_name, sig_name, func_name, func_global_name"
|
---|
212 | # p "#{ct_name}, #{sig_name}, #{func_name}, #{func_global_name}"
|
---|
213 |
|
---|
214 |
|
---|
215 | file.print <<EOT
|
---|
216 | \tgetMicroTime( &utime );
|
---|
217 | \tsyslog( LOG_INFO, \"Enter: %sTime=%d: #{@next_cell.get_name}.#{@next_cell_port_name}.#{func_name} calledFrom: %s\", ATTR_probeName_str, utime, ATTR_from_str );
|
---|
218 | EOT
|
---|
219 |
|
---|
220 | print_params( params, file, 0, :IN )
|
---|
221 |
|
---|
222 | delim = ""
|
---|
223 | if ! func_type.get_type.is_void? then
|
---|
224 | file.print( "\tretval = " )
|
---|
225 | else
|
---|
226 | file.print( "\t" )
|
---|
227 | end
|
---|
228 |
|
---|
229 | file.print( "#{@call_port_name}_#{func_name}(" )
|
---|
230 |
|
---|
231 | params.each{ |param|
|
---|
232 | file.printf( "#{delim} #{param.get_name}" )
|
---|
233 | delim = ","
|
---|
234 | }
|
---|
235 | file.print( " );\n" )
|
---|
236 | if @next_cell_port_subscript then
|
---|
237 | subscript = '[' + @next_cell_port_subscript.to_s + ']'
|
---|
238 | else
|
---|
239 | subscript = ""
|
---|
240 | end
|
---|
241 |
|
---|
242 | file.print <<EOT
|
---|
243 | \tgetMicroTime( &utime );
|
---|
244 | \tsyslog( LOG_INFO, \"Leave: %sTime=%d: #{@next_cell.get_name}.#{@next_cell_port_name}#{subscript}.#{func_name}\", ATTR_probeName_str, utime );
|
---|
245 | EOT
|
---|
246 |
|
---|
247 | print_params( params, file, 0, :OUT )
|
---|
248 |
|
---|
249 | if( ! func_type.get_type.is_void? ) then
|
---|
250 | print_param( "retval", func_type.get_type, file, 0, :RETURN, func_type.get_type.get_type_str, nil, nil)
|
---|
251 | file.print( "\treturn retval;\n" )
|
---|
252 | end
|
---|
253 |
|
---|
254 | end
|
---|
255 |
|
---|
256 | def print_params( params, file, nest, direction )
|
---|
257 | params.each{ |param|
|
---|
258 | dir = param.get_direction
|
---|
259 | if( direction == :IN )then
|
---|
260 | case dir
|
---|
261 | when :IN, :INOUT, :SEND
|
---|
262 | print_param( param.get_name, param.get_type, file, nest, dir, param.get_type.get_type_str, nil, nil )
|
---|
263 | end
|
---|
264 | else
|
---|
265 | case dir
|
---|
266 | when :OUT, :INOUT
|
---|
267 | print_param( param.get_name, param.get_type, file, nest, dir, param.get_type.get_type_str, nil, nil )
|
---|
268 | when :RECEIVE
|
---|
269 | outer = "*"
|
---|
270 | outer2 = nil
|
---|
271 | print_param( param.get_name, param.get_type.get_referto, file, nest, dir,
|
---|
272 | param.get_type.get_referto.get_type_str, outer, outer2 )
|
---|
273 | end
|
---|
274 | end
|
---|
275 | }
|
---|
276 | end
|
---|
277 |
|
---|
278 | def print_param( name, type, file, nest, direction, type_str, outer, outer2, name_list = nil )
|
---|
279 | indent = " " * ( nest + 1 )
|
---|
280 |
|
---|
281 | case type
|
---|
282 | when DefinedType
|
---|
283 | print_param( name, type.get_type, file, nest, direction, type_str, outer, outer2, name_list )
|
---|
284 | when VoidType
|
---|
285 | when BoolType
|
---|
286 | file.print( "#{indent}syslog( LOG_INFO, \"#{indent}[#{direction}]#{type_str} #{outer}#{name}#{outer2} = %d;\", #{outer}#{name}#{outer2} );\n" )
|
---|
287 | when IntType
|
---|
288 | file.print <<EOT
|
---|
289 | #{indent}if( sizeof(#{outer}#{name}#{outer2}) > sizeof(int_t) )
|
---|
290 | #{indent}\tsyslog( LOG_INFO, \"#{indent}[#{direction}]#{type_str} #{outer}#{name}#{outer2} = %ld;\", (long)#{outer}#{name}#{outer2} );
|
---|
291 | #{indent}else
|
---|
292 | #{indent}\tsyslog( LOG_INFO, \"#{indent}[#{direction}]#{type_str} #{outer}#{name}#{outer2} = %d;\", #{outer}#{name}#{outer2} );
|
---|
293 | EOT
|
---|
294 | # file.print( "#{indent}syslog( LOG_INFO, \"#{indent}[#{direction}]#{type_str} #{outer}#{name}#{outer2} = %ld;\", (long)#{outer}#{name}#{outer2} );\n" )
|
---|
295 | when FloatType
|
---|
296 | file.print( "#{indent}syslog( LOG_INFO, \"#{indent}[#{direction}]#{type_str} #{outer}#{name}#{outer2} = %g;\", (double)#{outer}#{name}#{outer2} );\n" )
|
---|
297 | when EnumType # mikan EnumType
|
---|
298 |
|
---|
299 | when StructType
|
---|
300 | members_decl =type.get_members_decl
|
---|
301 | if outer || outer2
|
---|
302 | outer = "(#{outer}#{name}#{outer2})."
|
---|
303 | else
|
---|
304 | outer = "#{name}."
|
---|
305 | end
|
---|
306 | members_decl.get_items.each { |m|
|
---|
307 | print_param( m.get_name, m.get_type, file, nest, direction, m.get_type.get_type_str, outer, nil, members_decl )
|
---|
308 | }
|
---|
309 | when FuncType # mikan FuncType
|
---|
310 | when ArrayType # mikan ArrayType
|
---|
311 | when PtrType
|
---|
312 |
|
---|
313 | se = type.get_size
|
---|
314 | ce = type.get_count
|
---|
315 | max_loop = @maxArrayDisplay
|
---|
316 | loop_count = nil
|
---|
317 |
|
---|
318 | if se then
|
---|
319 | loop_count = "(((#{se.to_str( name_list, outer, outer2 )})>#{max_loop}) ? #{max_loop} : (#{se.to_str( name_list, outer, outer2 )}))"
|
---|
320 | file.print( "#{indent}syslog( LOG_INFO, \"#{indent}size_is(#{se.to_str( name_list, outer, outer2 )})=%d\", #{se.to_str( name_list, outer, outer2 )} );\n" )
|
---|
321 | size = "#{se.to_str( name_list, outer, outer2 )}"
|
---|
322 | elsif ce then
|
---|
323 | loop_count = "(((#{ce.to_str( name_list, outer, outer2 )})>#{max_loop}) ? #{max_loop} : (#{ce.to_str( name_list, outer, outer2 )})) "
|
---|
324 | file.print( "#{indent}syslog( LOG_INFO, \"#{indent}count_is(#{ce.to_str( name_list, outer, outer2 )})=%d\", #{ce.to_str( name_list, outer, outer2 )} );\n" )
|
---|
325 | size = "#{ce.to_str( name_list, outer, outer2 )}"
|
---|
326 | end
|
---|
327 |
|
---|
328 | # mikan PtrType: string
|
---|
329 |
|
---|
330 | referto = type.get_referto
|
---|
331 | type0 = type
|
---|
332 | type = referto
|
---|
333 | type_str = type.get_type_str
|
---|
334 | if type.kind_of?( DefinedType ) then
|
---|
335 | type = type.get_original_type
|
---|
336 | end
|
---|
337 |
|
---|
338 | if type0.is_nullable? then
|
---|
339 | nest += 1
|
---|
340 | indent0 = indent
|
---|
341 | outer0 = outer
|
---|
342 | outer20 = outer2
|
---|
343 | indent += " "
|
---|
344 | file.print"#{indent0}if( #{outer}#{name}#{outer2} ){\n"
|
---|
345 | end
|
---|
346 |
|
---|
347 | if loop_count == nil then
|
---|
348 | case type
|
---|
349 | when StructType
|
---|
350 | members = type.get_members_decl
|
---|
351 | if outer || outer2
|
---|
352 | outer = "(#{outer}#{name}#{outer2})->"
|
---|
353 | else
|
---|
354 | outer = "#{name}->"
|
---|
355 | end
|
---|
356 | outer2 = nil
|
---|
357 | members.get_items.each { |m|
|
---|
358 | print_param( m.get_name, m.get_type, file, nest, direction, m.get_type.get_type_str, outer, outer2, members )
|
---|
359 | }
|
---|
360 | when FuncType # mikan FuncType
|
---|
361 | when ArrayType # mikan ArrayType
|
---|
362 | when BoolType, IntType, FloatType, EnumType, PtrType
|
---|
363 | outer = "*#{outer}"
|
---|
364 | outer2 = "#{outer2}"
|
---|
365 | print_param( name, type, file, nest, direction, type_str, outer, outer2 )
|
---|
366 | end
|
---|
367 | else # loop_count != nil
|
---|
368 | if type.kind_of?( PtrType ) || type.kind_of?( StructType ) then
|
---|
369 | num_per_loop = 1
|
---|
370 | else
|
---|
371 | num_per_loop = 4
|
---|
372 | end
|
---|
373 |
|
---|
374 | file.print <<EOT
|
---|
375 | #{indent}{
|
---|
376 | #{indent}\tint i__#{nest}, loop_count__ = #{loop_count};
|
---|
377 | #{indent}\tfor( i__#{nest} = 0; i__#{nest} < loop_count__; i__#{nest}+=#{num_per_loop} ){
|
---|
378 | EOT
|
---|
379 |
|
---|
380 | case type
|
---|
381 | when StructType
|
---|
382 | members = type.get_members_decl
|
---|
383 | if outer || outer2
|
---|
384 | outer = "(#{outer}#{name}#{outer2})[i__#{nest}]."
|
---|
385 | else
|
---|
386 | outer = "#{name}[i__#{nest}]."
|
---|
387 | end
|
---|
388 | members.get_items.each { |m|
|
---|
389 | print_param( m.get_name, m.get_type, file, nest + 1, direction, m.get_type.get_type_str, outer, nil, members )
|
---|
390 | }
|
---|
391 | when FuncType # mikan FuncType
|
---|
392 | when ArrayType # mikan ArrayType
|
---|
393 |
|
---|
394 | when BoolType, FloatType
|
---|
395 | if outer || outer2
|
---|
396 | outer = "(#{outer}"
|
---|
397 | outer2 = "#{outer2})"
|
---|
398 | end
|
---|
399 |
|
---|
400 | file.print <<EOT
|
---|
401 | #{indent}\t\tsyslog( LOG_INFO, \"#{indent}[#{direction}]#{type_str} #{name}[%d]: %d %d %d %d\",
|
---|
402 | #{indent}\t\t\t\ti__#{nest}, #{outer}#{name}#{outer2}[i__#{nest}], #{outer}#{name}#{outer2}[i__#{nest}+1], #{outer}#{name}#{outer2}[i__#{nest}+2], #{outer}#{name}#{outer2}[i__#{nest}+3] );
|
---|
403 | EOT
|
---|
404 | when IntType
|
---|
405 | if outer || outer2
|
---|
406 | outer = "(#{outer}"
|
---|
407 | outer2 = "#{outer2})"
|
---|
408 | end
|
---|
409 |
|
---|
410 | file.print <<EOT
|
---|
411 | #{indent}\t\tif( sizeof(#{outer}#{name}#{outer2}) > sizeof(int_t) )
|
---|
412 | #{indent}\t\t\tsyslog( LOG_INFO, \"#{indent}[#{direction}]#{type_str} #{name}[%d]: %02x %02x %02x %02x\",
|
---|
413 | #{indent}\t\t\t\t\ti__#{nest}, #{outer}#{name}#{outer2}[i__#{nest}], #{outer}#{name}#{outer2}[i__#{nest}+1], #{outer}#{name}#{outer2}[i__#{nest}+2], #{outer}#{name}#{outer2}[i__#{nest}+3] );
|
---|
414 | #{indent}\t\telse
|
---|
415 | #{indent}\t\t\tsyslog( LOG_INFO, \"#{indent}[#{direction}]#{type_str} #{name}[%d]: %02lx %02lx %02lx %02lx\",
|
---|
416 | #{indent}\t\t\t\t\ti__#{nest}, #{outer}#{name}#{outer2}[i__#{nest}], #{outer}#{name}#{outer2}[i__#{nest}+1], #{outer}#{name}#{outer2}[i__#{nest}+2], #{outer}#{name}#{outer2}[i__#{nest}+3] );
|
---|
417 | EOT
|
---|
418 |
|
---|
419 | when PtrType
|
---|
420 | # type = type.get_referto
|
---|
421 | if outer || outer2
|
---|
422 | outer = "(#{outer}"
|
---|
423 | outer2 = "#{outer2})[i__#{nest}]"
|
---|
424 | else
|
---|
425 | outer = ""
|
---|
426 | outer2 = "[i__#{nest}]"
|
---|
427 | end
|
---|
428 | print_param( name, type, file, nest + 1, direction, type_str, outer, outer2 )
|
---|
429 | end
|
---|
430 |
|
---|
431 | file.print <<EOT
|
---|
432 | #{indent}\t} /* for ( i__#{nest} ) */
|
---|
433 | #{indent}\tif( i__#{nest} < #{size} )
|
---|
434 | #{indent}\t\tsyslog( LOG_INFO, \"#{indent}(%d elements are omitted)\", #{size} - i__#{nest} );
|
---|
435 | #{indent}\telse if( i__#{nest} > #{size} )
|
---|
436 | #{indent}\t\tsyslog( LOG_INFO, \"#{indent}(last %d elements are void)\", i__#{nest} - #{size} );
|
---|
437 | #{indent}}
|
---|
438 | EOT
|
---|
439 | end # loop_count == nil
|
---|
440 |
|
---|
441 | if type0.is_nullable? then
|
---|
442 | file.print <<EOT
|
---|
443 | #{indent0}} else {
|
---|
444 | #{indent0} syslog( LOG_INFO, \"#{indent0}[#{direction}]#{outer0}#{name}#{outer20} = NULL\" );
|
---|
445 | #{indent0}}
|
---|
446 | EOT
|
---|
447 | end
|
---|
448 | end
|
---|
449 | end
|
---|
450 |
|
---|
451 | # ãã©ã°ã¤ã³å¼æ°å㨠Proc
|
---|
452 | TracePluginArgProc = {
|
---|
453 | "maxArrayDisplay" => Proc.new { |obj,rhs| obj.set_maxArrayDisplay rhs },
|
---|
454 | "cellEntry" => Proc.new { |obj,rhs| obj.set_cellEntry rhs },
|
---|
455 | "probeName" => Proc.new { |obj,rhs| obj.set_probeName rhs },
|
---|
456 | "displayTime" => Proc.new { |obj,rhs| obj.set_displayTime rhs },
|
---|
457 | "kernelCelltype" => Proc.new { |obj,rhs| obj.set_kernelCelltype rhs },
|
---|
458 | "syslogCelltype" => Proc.new { |obj,rhs| obj.set_syslogCelltype rhs },
|
---|
459 | }
|
---|
460 |
|
---|
461 | def set_maxArrayDisplay rhs
|
---|
462 | @maxArrayDisplay = rhs
|
---|
463 | end
|
---|
464 |
|
---|
465 | def set_cellEntry rhs
|
---|
466 | ces = rhs.to_s.split /\s*,\s*/
|
---|
467 | ces.each{ |ce|
|
---|
468 | if ce =~ /^[A-Za-z_]\w*\.[A-Za-z_]\w*$/ then
|
---|
469 | # OK
|
---|
470 | else
|
---|
471 | cdl_error( "#{ce}: TracePlugin arg not in \"symbol.symbol\" form" )
|
---|
472 | end
|
---|
473 | }
|
---|
474 | @cellEntry_list.concat ces
|
---|
475 | end
|
---|
476 |
|
---|
477 | def set_probeName rhs
|
---|
478 | @probeName = rhs.to_s
|
---|
479 | end
|
---|
480 |
|
---|
481 | def set_displayTime rhs
|
---|
482 | if rhs.to_s == "true"
|
---|
483 | @b_diplayTime = true
|
---|
484 | elsif rhs.to_s == "false"
|
---|
485 | @b_diplayTime = false
|
---|
486 | else
|
---|
487 | cdl_error( "displayTime : #{rhs} unsuitable: specify true or false" )
|
---|
488 | end
|
---|
489 | end
|
---|
490 |
|
---|
491 | #=== ãã©ã°ã¤ã³å¼æ° tKernel ã®ãã§ãã¯
|
---|
492 | def set_kernelCelltype( rhs )
|
---|
493 | @kernelCelltype = rhs.to_sym
|
---|
494 | nsp = NamespacePath.analyze( @kernelCelltype.to_s )
|
---|
495 | obj = Namespace.find( nsp )
|
---|
496 | if ! obj.instance_of?( Celltype ) && ! obj.instance_of?( CompositeCelltype ) then
|
---|
497 | cdl_error( "TracePlugin: kernelCelltype '#{rhs}' not celltype or not defined" )
|
---|
498 | end
|
---|
499 | end
|
---|
500 |
|
---|
501 | #=== ãã©ã°ã¤ã³å¼æ° tSyslog ã®ãã§ãã¯
|
---|
502 | def set_syslogCelltype( rhs )
|
---|
503 | @syslogCelltype = rhs.to_sym
|
---|
504 | nsp = NamespacePath.analyze( @syslogCelltype.to_s )
|
---|
505 | obj = Namespace.find( nsp )
|
---|
506 | if ! obj.instance_of?( Celltype ) && ! obj.instance_of?( CompositeCelltype ) then
|
---|
507 | cdl_error( "TracePlugin: syslogCelltype '#{rhs}' not celltype or not defined" )
|
---|
508 | end
|
---|
509 | end
|
---|
510 |
|
---|
511 | end
|
---|
512 |
|
---|
513 |
|
---|