Deleted Added
full compact
dbxface.c (91116) dbxface.c (99679)
1/*******************************************************************************
2 *
3 * Module Name: dbxface - AML Debugger external interfaces
1/*******************************************************************************
2 *
3 * Module Name: dbxface - AML Debugger external interfaces
4 * $Revision: 55 $
4 * $Revision: 59 $
5 *
6 ******************************************************************************/
7
8/******************************************************************************
9 *
10 * 1. Copyright Notice
11 *
12 * Some or all of this work - Copyright (c) 1999 - 2002, Intel Corp.

--- 98 unchanged lines hidden (view full) ---

111 * United States government or any agency thereof requires an export license,
112 * other governmental approval, or letter of assurance, without first obtaining
113 * such license, approval or letter.
114 *
115 *****************************************************************************/
116
117
118#include "acpi.h"
5 *
6 ******************************************************************************/
7
8/******************************************************************************
9 *
10 * 1. Copyright Notice
11 *
12 * Some or all of this work - Copyright (c) 1999 - 2002, Intel Corp.

--- 98 unchanged lines hidden (view full) ---

111 * United States government or any agency thereof requires an export license,
112 * other governmental approval, or letter of assurance, without first obtaining
113 * such license, approval or letter.
114 *
115 *****************************************************************************/
116
117
118#include "acpi.h"
119#include "acparser.h"
120#include "amlcode.h"
119#include "amlcode.h"
121#include "acnamesp.h"
122#include "acparser.h"
123#include "acevents.h"
124#include "acinterp.h"
125#include "acdebug.h"
126
127
128#ifdef ENABLE_DEBUGGER
129
130#define _COMPONENT ACPI_DEBUGGER
131 ACPI_MODULE_NAME ("dbxface")
132

--- 24 unchanged lines hidden (view full) ---

157 ACPI_PARSE_OBJECT *DisplayOp;
158 ACPI_PARSE_OBJECT *ParentOp;
159
160
161 ACPI_FUNCTION_ENTRY ();
162
163 /* Check for single-step breakpoint */
164
120#include "acdebug.h"
121
122
123#ifdef ENABLE_DEBUGGER
124
125#define _COMPONENT ACPI_DEBUGGER
126 ACPI_MODULE_NAME ("dbxface")
127

--- 24 unchanged lines hidden (view full) ---

152 ACPI_PARSE_OBJECT *DisplayOp;
153 ACPI_PARSE_OBJECT *ParentOp;
154
155
156 ACPI_FUNCTION_ENTRY ();
157
158 /* Check for single-step breakpoint */
159
165 if (WalkState->MethodBreakpoint && (WalkState->MethodBreakpoint <= Op->AmlOffset))
160 if (WalkState->MethodBreakpoint &&
161 (WalkState->MethodBreakpoint <= Op->Common.AmlOffset))
166 {
167 /* Check if the breakpoint has been reached or passed */
168 /* Hit the breakpoint, resume single step, reset breakpoint */
169
162 {
163 /* Check if the breakpoint has been reached or passed */
164 /* Hit the breakpoint, resume single step, reset breakpoint */
165
170 AcpiOsPrintf ("***Break*** at AML offset %X\n", Op->AmlOffset);
166 AcpiOsPrintf ("***Break*** at AML offset %X\n", Op->Common.AmlOffset);
171 AcpiGbl_CmSingleStep = TRUE;
172 AcpiGbl_StepToNextCall = FALSE;
173 WalkState->MethodBreakpoint = 0;
174 }
175
176 /* Check for user breakpoint (Must be on exact Aml offset) */
177
167 AcpiGbl_CmSingleStep = TRUE;
168 AcpiGbl_StepToNextCall = FALSE;
169 WalkState->MethodBreakpoint = 0;
170 }
171
172 /* Check for user breakpoint (Must be on exact Aml offset) */
173
178 else if (WalkState->UserBreakpoint && (WalkState->UserBreakpoint == Op->AmlOffset))
174 else if (WalkState->UserBreakpoint &&
175 (WalkState->UserBreakpoint == Op->Common.AmlOffset))
179 {
176 {
180 AcpiOsPrintf ("***UserBreakpoint*** at AML offset %X\n", Op->AmlOffset);
177 AcpiOsPrintf ("***UserBreakpoint*** at AML offset %X\n", Op->Common.AmlOffset);
181 AcpiGbl_CmSingleStep = TRUE;
182 AcpiGbl_StepToNextCall = FALSE;
183 WalkState->MethodBreakpoint = 0;
184 }
185
186
187 /*
188 * Check if this is an opcode that we are interested in --
189 * namely, opcodes that have arguments
190 */
178 AcpiGbl_CmSingleStep = TRUE;
179 AcpiGbl_StepToNextCall = FALSE;
180 WalkState->MethodBreakpoint = 0;
181 }
182
183
184 /*
185 * Check if this is an opcode that we are interested in --
186 * namely, opcodes that have arguments
187 */
191 if (Op->Opcode == AML_INT_NAMEDFIELD_OP)
188 if (Op->Common.AmlOpcode == AML_INT_NAMEDFIELD_OP)
192 {
193 return (AE_OK);
194 }
195
196 switch (OpcodeClass)
197 {
198 case AML_CLASS_UNKNOWN:
199 case AML_CLASS_ARGUMENT: /* constants, literals, etc. do nothing */
200 return (AE_OK);
189 {
190 return (AE_OK);
191 }
192
193 switch (OpcodeClass)
194 {
195 case AML_CLASS_UNKNOWN:
196 case AML_CLASS_ARGUMENT: /* constants, literals, etc. do nothing */
197 return (AE_OK);
198
199 default:
200 /* All other opcodes -- continue */
201 break;
201 }
202
203 /*
204 * Under certain debug conditions, display this opcode and its operands
205 */
206 if ((AcpiGbl_DbOutputToFile) ||
207 (AcpiGbl_CmSingleStep) ||
208 (AcpiDbgLevel & ACPI_LV_PARSE))

--- 6 unchanged lines hidden (view full) ---

215
216 /*
217 * Display this op (and only this op - zero out the NEXT field temporarily,
218 * and disable parser trace output for the duration of the display because
219 * we don't want the extraneous debug output)
220 */
221 OriginalDebugLevel = AcpiDbgLevel;
222 AcpiDbgLevel &= ~(ACPI_LV_PARSE | ACPI_LV_FUNCTIONS);
202 }
203
204 /*
205 * Under certain debug conditions, display this opcode and its operands
206 */
207 if ((AcpiGbl_DbOutputToFile) ||
208 (AcpiGbl_CmSingleStep) ||
209 (AcpiDbgLevel & ACPI_LV_PARSE))

--- 6 unchanged lines hidden (view full) ---

216
217 /*
218 * Display this op (and only this op - zero out the NEXT field temporarily,
219 * and disable parser trace output for the duration of the display because
220 * we don't want the extraneous debug output)
221 */
222 OriginalDebugLevel = AcpiDbgLevel;
223 AcpiDbgLevel &= ~(ACPI_LV_PARSE | ACPI_LV_FUNCTIONS);
223 Next = Op->Next;
224 Op->Next = NULL;
224 Next = Op->Common.Next;
225 Op->Common.Next = NULL;
225
226
227 DisplayOp = Op;
226
227
228 DisplayOp = Op;
228 ParentOp = Op->Parent;
229 ParentOp = Op->Common.Parent;
229 if (ParentOp)
230 {
231 if ((WalkState->ControlState) &&
232 (WalkState->ControlState->Common.State == ACPI_CONTROL_PREDICATE_EXECUTING))
233 {
234 /*
235 * We are executing the predicate of an IF or WHILE statement
236 * Search upwards for the containing IF or WHILE so that the
237 * entire predicate can be displayed.
238 */
239 while (ParentOp)
240 {
230 if (ParentOp)
231 {
232 if ((WalkState->ControlState) &&
233 (WalkState->ControlState->Common.State == ACPI_CONTROL_PREDICATE_EXECUTING))
234 {
235 /*
236 * We are executing the predicate of an IF or WHILE statement
237 * Search upwards for the containing IF or WHILE so that the
238 * entire predicate can be displayed.
239 */
240 while (ParentOp)
241 {
241 if ((ParentOp->Opcode == AML_IF_OP) ||
242 (ParentOp->Opcode == AML_WHILE_OP))
242 if ((ParentOp->Common.AmlOpcode == AML_IF_OP) ||
243 (ParentOp->Common.AmlOpcode == AML_WHILE_OP))
243 {
244 DisplayOp = ParentOp;
245 break;
246 }
244 {
245 DisplayOp = ParentOp;
246 break;
247 }
247 ParentOp = ParentOp->Parent;
248 ParentOp = ParentOp->Common.Parent;
248 }
249 }
250 else
251 {
252 while (ParentOp)
253 {
249 }
250 }
251 else
252 {
253 while (ParentOp)
254 {
254 if ((ParentOp->Opcode == AML_IF_OP) ||
255 (ParentOp->Opcode == AML_ELSE_OP) ||
256 (ParentOp->Opcode == AML_SCOPE_OP) ||
257 (ParentOp->Opcode == AML_METHOD_OP) ||
258 (ParentOp->Opcode == AML_WHILE_OP))
255 if ((ParentOp->Common.AmlOpcode == AML_IF_OP) ||
256 (ParentOp->Common.AmlOpcode == AML_ELSE_OP) ||
257 (ParentOp->Common.AmlOpcode == AML_SCOPE_OP) ||
258 (ParentOp->Common.AmlOpcode == AML_METHOD_OP) ||
259 (ParentOp->Common.AmlOpcode == AML_WHILE_OP))
259 {
260 break;
261 }
262 DisplayOp = ParentOp;
260 {
261 break;
262 }
263 DisplayOp = ParentOp;
263 ParentOp = ParentOp->Parent;
264 ParentOp = ParentOp->Common.Parent;
264 }
265 }
266 }
267
268 /* Now we can display it */
269
270 AcpiDbDisplayOp (WalkState, DisplayOp, ACPI_UINT32_MAX);
271
265 }
266 }
267 }
268
269 /* Now we can display it */
270
271 AcpiDbDisplayOp (WalkState, DisplayOp, ACPI_UINT32_MAX);
272
272 if ((Op->Opcode == AML_IF_OP) ||
273 (Op->Opcode == AML_WHILE_OP))
273 if ((Op->Common.AmlOpcode == AML_IF_OP) ||
274 (Op->Common.AmlOpcode == AML_WHILE_OP))
274 {
275 if (WalkState->ControlState->Common.Value)
276 {
277 AcpiOsPrintf ("Predicate = [True], IF block was executed\n");
278 }
279 else
280 {
281 AcpiOsPrintf ("Predicate = [False], Skipping IF block\n");
282 }
283 }
284
275 {
276 if (WalkState->ControlState->Common.Value)
277 {
278 AcpiOsPrintf ("Predicate = [True], IF block was executed\n");
279 }
280 else
281 {
282 AcpiOsPrintf ("Predicate = [False], Skipping IF block\n");
283 }
284 }
285
285 else if (Op->Opcode == AML_ELSE_OP)
286 else if (Op->Common.AmlOpcode == AML_ELSE_OP)
286 {
287 AcpiOsPrintf ("Predicate = [False], ELSE block was executed\n");
288 }
289
290 /* Restore everything */
291
287 {
288 AcpiOsPrintf ("Predicate = [False], ELSE block was executed\n");
289 }
290
291 /* Restore everything */
292
292 Op->Next = Next;
293 Op->Common.Next = Next;
293 AcpiOsPrintf ("\n");
294 AcpiDbgLevel = OriginalDebugLevel;
295 }
296
297 /* If we are not single stepping, just continue executing the method */
298
299 if (!AcpiGbl_CmSingleStep)
300 {
301 return (AE_OK);
302 }
303
304 /*
305 * If we are executing a step-to-call command,
306 * Check if this is a method call.
307 */
308 if (AcpiGbl_StepToNextCall)
309 {
294 AcpiOsPrintf ("\n");
295 AcpiDbgLevel = OriginalDebugLevel;
296 }
297
298 /* If we are not single stepping, just continue executing the method */
299
300 if (!AcpiGbl_CmSingleStep)
301 {
302 return (AE_OK);
303 }
304
305 /*
306 * If we are executing a step-to-call command,
307 * Check if this is a method call.
308 */
309 if (AcpiGbl_StepToNextCall)
310 {
310 if (Op->Opcode != AML_INT_METHODCALL_OP)
311 if (Op->Common.AmlOpcode != AML_INT_METHODCALL_OP)
311 {
312 /* Not a method call, just keep executing */
313
314 return (AE_OK);
315 }
316
317 /* Found a method call, stop executing */
318
319 AcpiGbl_StepToNextCall = FALSE;
320 }
321
322 /*
323 * If the next opcode is a method call, we will "step over" it
324 * by default.
325 */
312 {
313 /* Not a method call, just keep executing */
314
315 return (AE_OK);
316 }
317
318 /* Found a method call, stop executing */
319
320 AcpiGbl_StepToNextCall = FALSE;
321 }
322
323 /*
324 * If the next opcode is a method call, we will "step over" it
325 * by default.
326 */
326 if (Op->Opcode == AML_INT_METHODCALL_OP)
327 if (Op->Common.AmlOpcode == AML_INT_METHODCALL_OP)
327 {
328 AcpiGbl_CmSingleStep = FALSE; /* No more single step while executing called method */
329
330 /* Set the breakpoint on/before the call, it will stop execution as soon as we return */
331
332 WalkState->MethodBreakpoint = 1; /* Must be non-zero! */
333 }
334

--- 40 unchanged lines hidden (view full) ---

375 }
376 else
377 {
378 AcpiOsPrintf ("%1c ", ACPI_DEBUGGER_EXECUTE_PROMPT);
379 }
380
381 /* Get the user input line */
382
328 {
329 AcpiGbl_CmSingleStep = FALSE; /* No more single step while executing called method */
330
331 /* Set the breakpoint on/before the call, it will stop execution as soon as we return */
332
333 WalkState->MethodBreakpoint = 1; /* Must be non-zero! */
334 }
335

--- 40 unchanged lines hidden (view full) ---

376 }
377 else
378 {
379 AcpiOsPrintf ("%1c ", ACPI_DEBUGGER_EXECUTE_PROMPT);
380 }
381
382 /* Get the user input line */
383
383 AcpiOsGetLine (AcpiGbl_DbLineBuf);
384 (void) AcpiOsGetLine (AcpiGbl_DbLineBuf);
384 }
385
386 Status = AcpiDbCommandDispatch (AcpiGbl_DbLineBuf, WalkState, Op);
387 }
388
389 /* AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE); */
390
391 /* User commands complete, continue execution of the interrupted method */

--- 9 unchanged lines hidden (view full) ---

401 * PARAMETERS: None
402 *
403 * RETURN: Status
404 *
405 * DESCRIPTION: Init and start debugger
406 *
407 ******************************************************************************/
408
385 }
386
387 Status = AcpiDbCommandDispatch (AcpiGbl_DbLineBuf, WalkState, Op);
388 }
389
390 /* AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE); */
391
392 /* User commands complete, continue execution of the interrupted method */

--- 9 unchanged lines hidden (view full) ---

402 * PARAMETERS: None
403 *
404 * RETURN: Status
405 *
406 * DESCRIPTION: Init and start debugger
407 *
408 ******************************************************************************/
409
409int
410ACPI_STATUS
410AcpiDbInitialize (void)
411{
411AcpiDbInitialize (void)
412{
413 ACPI_STATUS Status;
412
414
415
413 /* Init globals */
414
415 AcpiGbl_DbBuffer = NULL;
416 AcpiGbl_DbFilename = NULL;
417 AcpiGbl_DbOutputToFile = FALSE;
418
419 AcpiGbl_DbDebugLevel = ACPI_LV_VERBOSITY2;
420 AcpiGbl_DbConsoleDebugLevel = NORMAL_DEFAULT | ACPI_LV_TABLES;
421 AcpiGbl_DbOutputFlags = ACPI_DB_CONSOLE_OUTPUT;
422
423 AcpiGbl_DbOpt_tables = FALSE;
424 AcpiGbl_DbOpt_disasm = FALSE;
425 AcpiGbl_DbOpt_stats = FALSE;
426 AcpiGbl_DbOpt_verbose = TRUE;
427 AcpiGbl_DbOpt_ini_methods = TRUE;
428
429 AcpiGbl_DbBuffer = AcpiOsAllocate (ACPI_DEBUG_BUFFER_SIZE);
430 if (!AcpiGbl_DbBuffer)
431 {
416 /* Init globals */
417
418 AcpiGbl_DbBuffer = NULL;
419 AcpiGbl_DbFilename = NULL;
420 AcpiGbl_DbOutputToFile = FALSE;
421
422 AcpiGbl_DbDebugLevel = ACPI_LV_VERBOSITY2;
423 AcpiGbl_DbConsoleDebugLevel = NORMAL_DEFAULT | ACPI_LV_TABLES;
424 AcpiGbl_DbOutputFlags = ACPI_DB_CONSOLE_OUTPUT;
425
426 AcpiGbl_DbOpt_tables = FALSE;
427 AcpiGbl_DbOpt_disasm = FALSE;
428 AcpiGbl_DbOpt_stats = FALSE;
429 AcpiGbl_DbOpt_verbose = TRUE;
430 AcpiGbl_DbOpt_ini_methods = TRUE;
431
432 AcpiGbl_DbBuffer = AcpiOsAllocate (ACPI_DEBUG_BUFFER_SIZE);
433 if (!AcpiGbl_DbBuffer)
434 {
432 return 0;
435 return (AE_NO_MEMORY);
433 }
434 ACPI_MEMSET (AcpiGbl_DbBuffer, 0, ACPI_DEBUG_BUFFER_SIZE);
435
436 /* Initial scope is the root */
437
438 AcpiGbl_DbScopeBuf [0] = '\\';
439 AcpiGbl_DbScopeBuf [1] = 0;
440 AcpiGbl_DbScopeNode = AcpiGbl_RootNode;
441
442 /*
443 * If configured for multi-thread support, the debug executor runs in
444 * a separate thread so that the front end can be in another address
445 * space, environment, or even another machine.
446 */
447 if (AcpiGbl_DebuggerConfiguration & DEBUGGER_MULTI_THREADED)
448 {
449 /* These were created with one unit, grab it */
450
436 }
437 ACPI_MEMSET (AcpiGbl_DbBuffer, 0, ACPI_DEBUG_BUFFER_SIZE);
438
439 /* Initial scope is the root */
440
441 AcpiGbl_DbScopeBuf [0] = '\\';
442 AcpiGbl_DbScopeBuf [1] = 0;
443 AcpiGbl_DbScopeNode = AcpiGbl_RootNode;
444
445 /*
446 * If configured for multi-thread support, the debug executor runs in
447 * a separate thread so that the front end can be in another address
448 * space, environment, or even another machine.
449 */
450 if (AcpiGbl_DebuggerConfiguration & DEBUGGER_MULTI_THREADED)
451 {
452 /* These were created with one unit, grab it */
453
451 AcpiUtAcquireMutex (ACPI_MTX_DEBUG_CMD_COMPLETE);
452 AcpiUtAcquireMutex (ACPI_MTX_DEBUG_CMD_READY);
454 Status = AcpiUtAcquireMutex (ACPI_MTX_DEBUG_CMD_COMPLETE);
455 if (ACPI_FAILURE (Status))
456 {
457 AcpiOsPrintf ("Could not get debugger mutex\n");
458 return (Status);
459 }
460 Status = AcpiUtAcquireMutex (ACPI_MTX_DEBUG_CMD_READY);
461 if (ACPI_FAILURE (Status))
462 {
463 AcpiOsPrintf ("Could not get debugger mutex\n");
464 return (Status);
465 }
453
454 /* Create the debug execution thread to execute commands */
455
466
467 /* Create the debug execution thread to execute commands */
468
456 AcpiOsQueueForExecution (0, AcpiDbExecuteThread, NULL);
469 Status = AcpiOsQueueForExecution (0, AcpiDbExecuteThread, NULL);
470 if (ACPI_FAILURE (Status))
471 {
472 AcpiOsPrintf ("Could not start debugger thread\n");
473 return (Status);
474 }
457 }
458
459 if (!AcpiGbl_DbOpt_verbose)
460 {
461 AcpiGbl_DbDisasmIndent = " ";
462 AcpiGbl_DbOpt_disasm = TRUE;
463 AcpiGbl_DbOpt_stats = FALSE;
464 }
465
475 }
476
477 if (!AcpiGbl_DbOpt_verbose)
478 {
479 AcpiGbl_DbDisasmIndent = " ";
480 AcpiGbl_DbOpt_disasm = TRUE;
481 AcpiGbl_DbOpt_stats = FALSE;
482 }
483
466 return (0);
484 return (AE_OK);
467}
468
469
470/*******************************************************************************
471 *
472 * FUNCTION: AcpiDbTerminate
473 *
474 * PARAMETERS: None

--- 23 unchanged lines hidden ---
485}
486
487
488/*******************************************************************************
489 *
490 * FUNCTION: AcpiDbTerminate
491 *
492 * PARAMETERS: None

--- 23 unchanged lines hidden ---