Skip to content

Commit

Permalink
[Media Common] add linux media driver call stack capture support
Browse files Browse the repository at this point in the history
media driver call stack capture support in linux
stage 2: media driver call stack dump with keyword enabled.
  • Loading branch information
lindongw authored and intel-mediadev committed May 13, 2022
1 parent 531abde commit b66bb0c
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
2 changes: 2 additions & 0 deletions media_common/agnostic/common/os/mos_os_trace_event.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ typedef enum _MEDIA_EVENT_FILTER_KEYID
TR_KEY_DECODE_DSTYUV,
TR_KEY_DECODE_REFYUV,
TR_KEY_MOSMSG_ALL = 12,
TR_KEY_CALL_STACK,
TR_KEY_DATA_DUMP = 16,
TR_KEY_MOSMSG_CP,
TR_KEY_MOSMSG_VP,
Expand Down Expand Up @@ -271,6 +272,7 @@ typedef enum _MEDIA_EVENT
EVENT_DECODE_FEATURE_DECODEMODE_REPORT, //! event for Decode Feature Decode Mode Report
EVENT_DECODE_DST_DUMPINFO, //! event for Decode Dst Surface Info
EVENT_DECODE_REF_DUMPINFO, //! event for Decode Ref Surface Info
EVENT_CALL_STACK, //! event for call stack dump
} MEDIA_EVENT;

typedef enum _MEDIA_EVENT_TYPE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
#include <signal.h>
#include <unistd.h> // fork
#include <algorithm>
#include <execinfo.h> // backtrace

const char *MosUtilitiesSpecificNext::m_szUserFeatureFile = USER_FEATURE_FILE;
MOS_PUF_KEYLIST MosUtilitiesSpecificNext::m_ufKeyList = nullptr;
Expand Down Expand Up @@ -2488,6 +2489,25 @@ void MosUtilities::MosTraceEvent(
MOS_FreeMemory(pTraceBuf);
}
}
if (m_mosTraceFilter & (1ULL << TR_KEY_CALL_STACK))
{
// reserve space for header and stack size field.
// max 32-2=30 layers call stack in 64bit driver.
uint32_t nLen = 4*sizeof(uint32_t);
void **stack = (void **)(traceBuf + nLen);
int num = backtrace(stack, ((sizeof(traceBuf)-nLen)/sizeof(void *)));
if (num > 0)
{
uint32_t *header = (uint32_t *)traceBuf;

header[0] = 0x494D5445; // IMTE (IntelMediaTraceEvent) as ftrace raw marker tag
header[1] = (EVENT_CALL_STACK << 16) | (num*sizeof(void *)+sizeof(uint32_t));
header[2] = 0;
header[3] = (uint32_t)num;
nLen += num*sizeof(void *);
size_t ret = write(MosUtilitiesSpecificNext::m_mosTraceFd, traceBuf, nLen);
}
}
}
return;
}
Expand Down

0 comments on commit b66bb0c

Please sign in to comment.