Print this page
update to acpica-unix2-20140114
update to acpica-unix2-20130927
acpica-unix2-20130823
PANKOVs restructure
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/uts/intel/io/acpica/debugger/dbxface.c
+++ new/usr/src/common/acpica/components/debugger/dbxface.c
1 1 /*******************************************************************************
2 2 *
3 3 * Module Name: dbxface - AML Debugger external interfaces
4 4 *
5 5 ******************************************************************************/
6 6
7 7 /*
8 - * Copyright (C) 2000 - 2011, Intel Corp.
8 + * Copyright (C) 2000 - 2014, Intel Corp.
9 9 * All rights reserved.
10 10 *
11 11 * Redistribution and use in source and binary forms, with or without
12 12 * modification, are permitted provided that the following conditions
13 13 * are met:
14 14 * 1. Redistributions of source code must retain the above copyright
15 15 * notice, this list of conditions, and the following disclaimer,
16 16 * without modification.
17 17 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
18 18 * substantially similar to the "NO WARRANTY" disclaimer below
19 19 * ("Disclaimer") and any redistribution must be conditioned upon
20 20 * including a substantially similar Disclaimer requirement for further
21 21 * binary redistribution.
22 22 * 3. Neither the names of the above-listed copyright holders nor the names
23 23 * of any contributors may be used to endorse or promote products derived
24 24 * from this software without specific prior written permission.
25 25 *
26 26 * Alternatively, this software may be distributed under the terms of the
27 27 * GNU General Public License ("GPL") version 2 as published by the Free
28 28 * Software Foundation.
29 29 *
30 30 * NO WARRANTY
31 31 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32 32 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33 33 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
34 34 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35 35 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36 36 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37 37 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38 38 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39 39 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
40 40 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41 41 * POSSIBILITY OF SUCH DAMAGES.
42 42 */
43 43
44 44
45 45 #include "acpi.h"
46 46 #include "accommon.h"
47 47 #include "amlcode.h"
48 48 #include "acdebug.h"
49 49 #include "acdisasm.h"
50 50
51 51
52 52 #ifdef ACPI_DEBUGGER
53 53
54 54 #define _COMPONENT ACPI_CA_DEBUGGER
55 55 ACPI_MODULE_NAME ("dbxface")
56 56
57 57
58 58 /* Local prototypes */
59 59
60 60 static ACPI_STATUS
61 61 AcpiDbStartCommand (
62 62 ACPI_WALK_STATE *WalkState,
63 63 ACPI_PARSE_OBJECT *Op);
64 64
65 65 #ifdef ACPI_OBSOLETE_FUNCTIONS
66 66 void
67 67 AcpiDbMethodEnd (
68 68 ACPI_WALK_STATE *WalkState);
69 69 #endif
70 70
71 71
72 72 /*******************************************************************************
73 73 *
74 74 * FUNCTION: AcpiDbStartCommand
75 75 *
76 76 * PARAMETERS: WalkState - Current walk
77 77 * Op - Current executing Op, from AML interpreter
78 78 *
79 79 * RETURN: Status
80 80 *
81 81 * DESCRIPTION: Enter debugger command loop
82 82 *
83 83 ******************************************************************************/
84 84
85 85 static ACPI_STATUS
86 86 AcpiDbStartCommand (
87 87 ACPI_WALK_STATE *WalkState,
88 88 ACPI_PARSE_OBJECT *Op)
89 89 {
90 90 ACPI_STATUS Status;
91 91
92 92
93 93 /* TBD: [Investigate] are there namespace locking issues here? */
94 94
95 95 /* AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); */
96 96
97 97 /* Go into the command loop and await next user command */
98 98
99 99
100 100 AcpiGbl_MethodExecuting = TRUE;
101 101 Status = AE_CTRL_TRUE;
102 102 while (Status == AE_CTRL_TRUE)
103 103 {
104 104 if (AcpiGbl_DebuggerConfiguration == DEBUGGER_MULTI_THREADED)
105 105 {
106 106 /* Handshake with the front-end that gets user command lines */
107 107
108 108 Status = AcpiUtReleaseMutex (ACPI_MTX_DEBUG_CMD_COMPLETE);
109 109 if (ACPI_FAILURE (Status))
110 110 {
111 111 return (Status);
112 112 }
113 113 Status = AcpiUtAcquireMutex (ACPI_MTX_DEBUG_CMD_READY);
114 114 if (ACPI_FAILURE (Status))
115 115 {
116 116 return (Status);
117 117 }
118 118 }
119 119 else
120 120 {
121 121 /* Single threaded, we must get a command line ourselves */
122 122
123 123 /* Force output to console until a command is entered */
124 124
125 125 AcpiDbSetOutputDestination (ACPI_DB_CONSOLE_OUTPUT);
126 126
127 127 /* Different prompt if method is executing */
128 128
129 129 if (!AcpiGbl_MethodExecuting)
130 130 {
131 131 AcpiOsPrintf ("%1c ", ACPI_DEBUGGER_COMMAND_PROMPT);
132 132 }
133 133 else
134 134 {
135 135 AcpiOsPrintf ("%1c ", ACPI_DEBUGGER_EXECUTE_PROMPT);
136 136 }
137 137
138 138 /* Get the user input line */
139 139
140 140 Status = AcpiOsGetLine (AcpiGbl_DbLineBuf,
141 141 ACPI_DB_LINE_BUFFER_SIZE, NULL);
142 142 if (ACPI_FAILURE (Status))
143 143 {
144 144 ACPI_EXCEPTION ((AE_INFO, Status, "While parsing command line"));
145 145 return (Status);
146 146 }
147 147 }
148 148
149 149 Status = AcpiDbCommandDispatch (AcpiGbl_DbLineBuf, WalkState, Op);
150 150 }
151 151
152 152 /* AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE); */
153 153
154 154 return (Status);
155 155 }
156 156
157 157
158 158 /*******************************************************************************
159 159 *
160 160 * FUNCTION: AcpiDbSingleStep
161 161 *
162 162 * PARAMETERS: WalkState - Current walk
163 163 * Op - Current executing op (from aml interpreter)
164 164 * OpcodeClass - Class of the current AML Opcode
165 165 *
166 166 * RETURN: Status
167 167 *
168 168 * DESCRIPTION: Called just before execution of an AML opcode.
169 169 *
170 170 ******************************************************************************/
171 171
172 172 ACPI_STATUS
173 173 AcpiDbSingleStep (
174 174 ACPI_WALK_STATE *WalkState,
175 175 ACPI_PARSE_OBJECT *Op,
176 176 UINT32 OpcodeClass)
177 177 {
178 178 ACPI_PARSE_OBJECT *Next;
179 179 ACPI_STATUS Status = AE_OK;
180 180 UINT32 OriginalDebugLevel;
181 181 ACPI_PARSE_OBJECT *DisplayOp;
182 182 ACPI_PARSE_OBJECT *ParentOp;
183 183
184 184
185 185 ACPI_FUNCTION_ENTRY ();
186 186
187 187
188 188 /* Check the abort flag */
189 189
190 190 if (AcpiGbl_AbortMethod)
191 191 {
192 192 AcpiGbl_AbortMethod = FALSE;
193 193 return (AE_ABORT_METHOD);
194 194 }
195 195
196 196 /* Check for single-step breakpoint */
197 197
198 198 if (WalkState->MethodBreakpoint &&
199 199 (WalkState->MethodBreakpoint <= Op->Common.AmlOffset))
200 200 {
201 201 /* Check if the breakpoint has been reached or passed */
202 202 /* Hit the breakpoint, resume single step, reset breakpoint */
203 203
204 204 AcpiOsPrintf ("***Break*** at AML offset %X\n", Op->Common.AmlOffset);
205 205 AcpiGbl_CmSingleStep = TRUE;
206 206 AcpiGbl_StepToNextCall = FALSE;
207 207 WalkState->MethodBreakpoint = 0;
208 208 }
209 209
210 210 /* Check for user breakpoint (Must be on exact Aml offset) */
211 211
212 212 else if (WalkState->UserBreakpoint &&
213 213 (WalkState->UserBreakpoint == Op->Common.AmlOffset))
214 214 {
215 215 AcpiOsPrintf ("***UserBreakpoint*** at AML offset %X\n",
216 216 Op->Common.AmlOffset);
217 217 AcpiGbl_CmSingleStep = TRUE;
218 218 AcpiGbl_StepToNextCall = FALSE;
219 219 WalkState->MethodBreakpoint = 0;
220 220 }
221 221
222 222 /*
223 223 * Check if this is an opcode that we are interested in --
↓ open down ↓ |
205 lines elided |
↑ open up ↑ |
224 224 * namely, opcodes that have arguments
225 225 */
226 226 if (Op->Common.AmlOpcode == AML_INT_NAMEDFIELD_OP)
227 227 {
228 228 return (AE_OK);
229 229 }
230 230
231 231 switch (OpcodeClass)
232 232 {
233 233 case AML_CLASS_UNKNOWN:
234 - case AML_CLASS_ARGUMENT: /* constants, literals, etc. do nothing */
234 + case AML_CLASS_ARGUMENT: /* constants, literals, etc. do nothing */
235 +
235 236 return (AE_OK);
236 237
237 238 default:
239 +
238 240 /* All other opcodes -- continue */
239 241 break;
240 242 }
241 243
242 244 /*
243 245 * Under certain debug conditions, display this opcode and its operands
244 246 */
245 247 if ((AcpiGbl_DbOutputToFile) ||
246 248 (AcpiGbl_CmSingleStep) ||
247 249 (AcpiDbgLevel & ACPI_LV_PARSE))
248 250 {
249 251 if ((AcpiGbl_DbOutputToFile) ||
250 252 (AcpiDbgLevel & ACPI_LV_PARSE))
251 253 {
252 254 AcpiOsPrintf ("\n[AmlDebug] Next AML Opcode to execute:\n");
253 255 }
254 256
255 257 /*
256 258 * Display this op (and only this op - zero out the NEXT field
257 259 * temporarily, and disable parser trace output for the duration of
258 260 * the display because we don't want the extraneous debug output)
259 261 */
260 262 OriginalDebugLevel = AcpiDbgLevel;
261 263 AcpiDbgLevel &= ~(ACPI_LV_PARSE | ACPI_LV_FUNCTIONS);
262 264 Next = Op->Common.Next;
263 265 Op->Common.Next = NULL;
264 266
265 267
266 268 DisplayOp = Op;
267 269 ParentOp = Op->Common.Parent;
268 270 if (ParentOp)
269 271 {
270 272 if ((WalkState->ControlState) &&
271 273 (WalkState->ControlState->Common.State ==
272 274 ACPI_CONTROL_PREDICATE_EXECUTING))
273 275 {
274 276 /*
275 277 * We are executing the predicate of an IF or WHILE statement
276 278 * Search upwards for the containing IF or WHILE so that the
277 279 * entire predicate can be displayed.
278 280 */
279 281 while (ParentOp)
280 282 {
281 283 if ((ParentOp->Common.AmlOpcode == AML_IF_OP) ||
282 284 (ParentOp->Common.AmlOpcode == AML_WHILE_OP))
283 285 {
284 286 DisplayOp = ParentOp;
285 287 break;
286 288 }
287 289 ParentOp = ParentOp->Common.Parent;
288 290 }
289 291 }
290 292 else
291 293 {
292 294 while (ParentOp)
293 295 {
294 296 if ((ParentOp->Common.AmlOpcode == AML_IF_OP) ||
295 297 (ParentOp->Common.AmlOpcode == AML_ELSE_OP) ||
296 298 (ParentOp->Common.AmlOpcode == AML_SCOPE_OP) ||
297 299 (ParentOp->Common.AmlOpcode == AML_METHOD_OP) ||
298 300 (ParentOp->Common.AmlOpcode == AML_WHILE_OP))
299 301 {
300 302 break;
301 303 }
302 304 DisplayOp = ParentOp;
303 305 ParentOp = ParentOp->Common.Parent;
304 306 }
305 307 }
306 308 }
307 309
308 310 /* Now we can display it */
309 311
310 312 AcpiDmDisassemble (WalkState, DisplayOp, ACPI_UINT32_MAX);
311 313
312 314 if ((Op->Common.AmlOpcode == AML_IF_OP) ||
313 315 (Op->Common.AmlOpcode == AML_WHILE_OP))
314 316 {
315 317 if (WalkState->ControlState->Common.Value)
316 318 {
317 319 AcpiOsPrintf ("Predicate = [True], IF block was executed\n");
318 320 }
319 321 else
320 322 {
321 323 AcpiOsPrintf ("Predicate = [False], Skipping IF block\n");
322 324 }
323 325 }
324 326 else if (Op->Common.AmlOpcode == AML_ELSE_OP)
325 327 {
326 328 AcpiOsPrintf ("Predicate = [False], ELSE block was executed\n");
327 329 }
328 330
329 331 /* Restore everything */
330 332
331 333 Op->Common.Next = Next;
332 334 AcpiOsPrintf ("\n");
333 335 if ((AcpiGbl_DbOutputToFile) ||
334 336 (AcpiDbgLevel & ACPI_LV_PARSE))
335 337 {
336 338 AcpiOsPrintf ("\n");
337 339 }
338 340 AcpiDbgLevel = OriginalDebugLevel;
339 341 }
340 342
341 343 /* If we are not single stepping, just continue executing the method */
342 344
343 345 if (!AcpiGbl_CmSingleStep)
344 346 {
345 347 return (AE_OK);
346 348 }
347 349
348 350 /*
349 351 * If we are executing a step-to-call command,
350 352 * Check if this is a method call.
351 353 */
352 354 if (AcpiGbl_StepToNextCall)
353 355 {
354 356 if (Op->Common.AmlOpcode != AML_INT_METHODCALL_OP)
355 357 {
356 358 /* Not a method call, just keep executing */
357 359
358 360 return (AE_OK);
359 361 }
360 362
361 363 /* Found a method call, stop executing */
362 364
363 365 AcpiGbl_StepToNextCall = FALSE;
364 366 }
365 367
366 368 /*
367 369 * If the next opcode is a method call, we will "step over" it
368 370 * by default.
369 371 */
370 372 if (Op->Common.AmlOpcode == AML_INT_METHODCALL_OP)
371 373 {
372 374 /* Force no more single stepping while executing called method */
373 375
374 376 AcpiGbl_CmSingleStep = FALSE;
375 377
376 378 /*
377 379 * Set the breakpoint on/before the call, it will stop execution
378 380 * as soon as we return
379 381 */
380 382 WalkState->MethodBreakpoint = 1; /* Must be non-zero! */
381 383 }
382 384
383 385
384 386 Status = AcpiDbStartCommand (WalkState, Op);
385 387
386 388 /* User commands complete, continue execution of the interrupted method */
387 389
388 390 return (Status);
389 391 }
390 392
391 393
392 394 /*******************************************************************************
393 395 *
394 396 * FUNCTION: AcpiDbInitialize
395 397 *
396 398 * PARAMETERS: None
397 399 *
398 400 * RETURN: Status
399 401 *
400 402 * DESCRIPTION: Init and start debugger
↓ open down ↓ |
153 lines elided |
↑ open up ↑ |
401 403 *
402 404 ******************************************************************************/
403 405
404 406 ACPI_STATUS
405 407 AcpiDbInitialize (
406 408 void)
407 409 {
408 410 ACPI_STATUS Status;
409 411
410 412
413 + ACPI_FUNCTION_TRACE (DbInitialize);
414 +
415 +
411 416 /* Init globals */
412 417
413 418 AcpiGbl_DbBuffer = NULL;
414 419 AcpiGbl_DbFilename = NULL;
415 420 AcpiGbl_DbOutputToFile = FALSE;
416 421
417 422 AcpiGbl_DbDebugLevel = ACPI_LV_VERBOSITY2;
418 423 AcpiGbl_DbConsoleDebugLevel = ACPI_NORMAL_DEFAULT | ACPI_LV_TABLES;
419 424 AcpiGbl_DbOutputFlags = ACPI_DB_CONSOLE_OUTPUT;
420 425
421 426 AcpiGbl_DbOpt_tables = FALSE;
422 427 AcpiGbl_DbOpt_disasm = FALSE;
423 428 AcpiGbl_DbOpt_stats = FALSE;
424 429 AcpiGbl_DbOpt_verbose = TRUE;
425 430 AcpiGbl_DbOpt_ini_methods = TRUE;
426 431
427 432 AcpiGbl_DbBuffer = AcpiOsAllocate (ACPI_DEBUG_BUFFER_SIZE);
428 433 if (!AcpiGbl_DbBuffer)
429 434 {
430 - return (AE_NO_MEMORY);
435 + return_ACPI_STATUS (AE_NO_MEMORY);
431 436 }
432 437 ACPI_MEMSET (AcpiGbl_DbBuffer, 0, ACPI_DEBUG_BUFFER_SIZE);
433 438
434 439 /* Initial scope is the root */
435 440
436 - AcpiGbl_DbScopeBuf [0] = '\\';
441 + AcpiGbl_DbScopeBuf [0] = AML_ROOT_PREFIX;
437 442 AcpiGbl_DbScopeBuf [1] = 0;
438 443 AcpiGbl_DbScopeNode = AcpiGbl_RootNode;
439 444
440 445 /*
441 446 * If configured for multi-thread support, the debug executor runs in
442 447 * a separate thread so that the front end can be in another address
443 448 * space, environment, or even another machine.
444 449 */
445 450 if (AcpiGbl_DebuggerConfiguration & DEBUGGER_MULTI_THREADED)
446 451 {
447 452 /* These were created with one unit, grab it */
448 453
449 454 Status = AcpiUtAcquireMutex (ACPI_MTX_DEBUG_CMD_COMPLETE);
450 455 if (ACPI_FAILURE (Status))
451 456 {
452 457 AcpiOsPrintf ("Could not get debugger mutex\n");
453 - return (Status);
458 + return_ACPI_STATUS (Status);
454 459 }
455 460
456 461 Status = AcpiUtAcquireMutex (ACPI_MTX_DEBUG_CMD_READY);
457 462 if (ACPI_FAILURE (Status))
458 463 {
459 464 AcpiOsPrintf ("Could not get debugger mutex\n");
460 - return (Status);
465 + return_ACPI_STATUS (Status);
461 466 }
462 467
463 468 /* Create the debug execution thread to execute commands */
464 469
465 470 Status = AcpiOsExecute (OSL_DEBUGGER_THREAD, AcpiDbExecuteThread, NULL);
466 471 if (ACPI_FAILURE (Status))
467 472 {
468 - AcpiOsPrintf ("Could not start debugger thread\n");
469 - return (Status);
473 + ACPI_EXCEPTION ((AE_INFO, Status, "Could not start debugger thread"));
474 + return_ACPI_STATUS (Status);
470 475 }
471 476 }
472 477
473 478 if (!AcpiGbl_DbOpt_verbose)
474 479 {
475 480 AcpiGbl_DbOpt_disasm = TRUE;
476 481 AcpiGbl_DbOpt_stats = FALSE;
477 482 }
478 483
479 - return (AE_OK);
484 + return_ACPI_STATUS (AE_OK);
480 485 }
481 486
482 487
483 488 /*******************************************************************************
484 489 *
485 490 * FUNCTION: AcpiDbTerminate
486 491 *
487 492 * PARAMETERS: None
488 493 *
489 494 * RETURN: None
490 495 *
491 496 * DESCRIPTION: Stop debugger
492 497 *
↓ open down ↓ |
3 lines elided |
↑ open up ↑ |
493 498 ******************************************************************************/
494 499
495 500 void
496 501 AcpiDbTerminate (
497 502 void)
498 503 {
499 504
500 505 if (AcpiGbl_DbBuffer)
501 506 {
502 507 AcpiOsFree (AcpiGbl_DbBuffer);
508 + AcpiGbl_DbBuffer = NULL;
503 509 }
510 +
511 + /* Ensure that debug output is now disabled */
512 +
513 + AcpiGbl_DbOutputFlags = ACPI_DB_DISABLE_OUTPUT;
504 514 }
505 515
506 516
507 517 #ifdef ACPI_OBSOLETE_FUNCTIONS
508 518 /*******************************************************************************
509 519 *
510 520 * FUNCTION: AcpiDbMethodEnd
511 521 *
512 522 * PARAMETERS: WalkState - Current walk
513 523 *
514 524 * RETURN: Status
515 525 *
516 526 * DESCRIPTION: Called at method termination
517 527 *
518 528 ******************************************************************************/
519 529
520 530 void
521 531 AcpiDbMethodEnd (
522 532 ACPI_WALK_STATE *WalkState)
523 533 {
524 534
525 535 if (!AcpiGbl_CmSingleStep)
526 536 {
527 537 return;
528 538 }
529 539
530 540 AcpiOsPrintf ("<Method Terminating>\n");
531 541
532 542 AcpiDbStartCommand (WalkState, NULL);
533 543 }
534 544 #endif
535 545
536 546 #endif /* ACPI_DEBUGGER */
↓ open down ↓ |
23 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX