13d8536b4Sopenharmony_ci/* 23d8536b4Sopenharmony_ci * Copyright (c) 2022-2022 Huawei Device Co., Ltd. All rights reserved. 33d8536b4Sopenharmony_ci * 43d8536b4Sopenharmony_ci * Redistribution and use in source and binary forms, with or without modification, 53d8536b4Sopenharmony_ci * are permitted provided that the following conditions are met: 63d8536b4Sopenharmony_ci * 73d8536b4Sopenharmony_ci * 1. Redistributions of source code must retain the above copyright notice, this list of 83d8536b4Sopenharmony_ci * conditions and the following disclaimer. 93d8536b4Sopenharmony_ci * 103d8536b4Sopenharmony_ci * 2. Redistributions in binary form must reproduce the above copyright notice, this list 113d8536b4Sopenharmony_ci * of conditions and the following disclaimer in the documentation and/or other materials 123d8536b4Sopenharmony_ci * provided with the distribution. 133d8536b4Sopenharmony_ci * 143d8536b4Sopenharmony_ci * 3. Neither the name of the copyright holder nor the names of its contributors may be used 153d8536b4Sopenharmony_ci * to endorse or promote products derived from this software without specific prior written 163d8536b4Sopenharmony_ci * permission. 173d8536b4Sopenharmony_ci * 183d8536b4Sopenharmony_ci * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 193d8536b4Sopenharmony_ci * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 203d8536b4Sopenharmony_ci * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 213d8536b4Sopenharmony_ci * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 223d8536b4Sopenharmony_ci * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 233d8536b4Sopenharmony_ci * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 243d8536b4Sopenharmony_ci * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 253d8536b4Sopenharmony_ci * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 263d8536b4Sopenharmony_ci * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 273d8536b4Sopenharmony_ci * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 283d8536b4Sopenharmony_ci * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 293d8536b4Sopenharmony_ci */ 303d8536b4Sopenharmony_ci 313d8536b4Sopenharmony_ci#ifndef _LOS_DEBUGTOOLS_H 323d8536b4Sopenharmony_ci#define _LOS_DEBUGTOOLS_H 333d8536b4Sopenharmony_ci 343d8536b4Sopenharmony_ci#include "los_config.h" 353d8536b4Sopenharmony_ci#include "los_task.h" 363d8536b4Sopenharmony_ci 373d8536b4Sopenharmony_ci#ifdef __cplusplus 383d8536b4Sopenharmony_ci#if __cplusplus 393d8536b4Sopenharmony_ciextern "C" { 403d8536b4Sopenharmony_ci#endif /* __cplusplus */ 413d8536b4Sopenharmony_ci#endif /* __cplusplus */ 423d8536b4Sopenharmony_ci 433d8536b4Sopenharmony_ci 443d8536b4Sopenharmony_ci/* StackDump print format */ 453d8536b4Sopenharmony_ci#define PRINT_PER_ROW 4 463d8536b4Sopenharmony_ci 473d8536b4Sopenharmony_ci/* SchedTrace records number */ 483d8536b4Sopenharmony_ci#define TRACE_NUM 200 493d8536b4Sopenharmony_ci 503d8536b4Sopenharmony_ci/* sched trace info, users can add their own */ 513d8536b4Sopenharmony_citypedef struct { 523d8536b4Sopenharmony_ci UINT32 newTaskID; 533d8536b4Sopenharmony_ci CHAR newTaskName[LOS_TASK_NAMELEN]; 543d8536b4Sopenharmony_ci UINT32 runTaskID; 553d8536b4Sopenharmony_ci CHAR runTaskName[LOS_TASK_NAMELEN]; 563d8536b4Sopenharmony_ci} SchedTraceInfo; 573d8536b4Sopenharmony_ci 583d8536b4Sopenharmony_ci/* SchedTrace record callback */ 593d8536b4Sopenharmony_citypedef void (*SchedTraceRecordCB)(LosTaskCB *newTask, LosTaskCB *runTask); 603d8536b4Sopenharmony_ci 613d8536b4Sopenharmony_ci/* SchedTrace show callback, buf is overwrite ringbuf, max amount of storage is TRACE_NUM */ 623d8536b4Sopenharmony_citypedef void (*SchedTraceShowCB)(SchedTraceInfo *ringBuf, UINT32 count); 633d8536b4Sopenharmony_ci 643d8536b4Sopenharmony_ci/* Shell callback */ 653d8536b4Sopenharmony_ciextern UINT32 OsShellCmdStackDump(INT32 argc, const CHAR **argv); 663d8536b4Sopenharmony_ciextern UINT32 OsShellCmdHwiDump(INT32 argc, const CHAR **argv); 673d8536b4Sopenharmony_ciextern UINT32 OsShellCmdSchedTrace(INT32 argc, const CHAR **argv); 683d8536b4Sopenharmony_ci 693d8536b4Sopenharmony_ci/* Other module callback */ 703d8536b4Sopenharmony_ciextern VOID OsSchedTraceRecord(LosTaskCB *newTask, LosTaskCB *runTask); 713d8536b4Sopenharmony_ci 723d8536b4Sopenharmony_ci/* External interface */ 733d8536b4Sopenharmony_ci/* dump stack by task id, can be called at any time */ 743d8536b4Sopenharmony_ciextern VOID LOS_TaskStackDump(UINT32 taskID); 753d8536b4Sopenharmony_ci 763d8536b4Sopenharmony_ci/* register sched trace handle, If not registered, the default fun will be used */ 773d8536b4Sopenharmony_ciextern VOID LOS_SchedTraceHandleRegister(SchedTraceRecordCB recordCB, SchedTraceShowCB showCB); 783d8536b4Sopenharmony_ci/* start sched trace, will alloc buf, and start write to buf when sched */ 793d8536b4Sopenharmony_ciextern VOID LOS_SchedTraceStart(VOID); 803d8536b4Sopenharmony_ci/* stop sched trace, will stop record and free buf */ 813d8536b4Sopenharmony_ciextern VOID LOS_SchedTraceStop(VOID); 823d8536b4Sopenharmony_ci 833d8536b4Sopenharmony_ci#ifdef __cplusplus 843d8536b4Sopenharmony_ci#if __cplusplus 853d8536b4Sopenharmony_ci} 863d8536b4Sopenharmony_ci#endif /* __cplusplus */ 873d8536b4Sopenharmony_ci#endif /* __cplusplus */ 883d8536b4Sopenharmony_ci 893d8536b4Sopenharmony_ci#endif 90