Exemplo n.º 1
0
/**
 * sirDumpBuf()
 *
 * FUNCTION:
 * This function is called to dump a buffer with a certain level
 *
 * LOGIC:
 *
 * ASSUMPTIONS:
 * None.
 *
 * NOTE:
 *
 * @param pBuf: buffer pointer
 * @return None.
 */
void
sirDumpBuf(tpAniSirGlobal pMac, tANI_U8 modId, tANI_U32 level, tANI_U8 *buf, tANI_U32 size)
{
    tANI_U32 i;

    if (level > pMac->utils.gLogDbgLevel[LOG_INDEX_FOR_MODULE(modId)])
        return;

    logDbg(pMac, modId, level, FL("Dumping %d bytes in host order\n"), size);

    for (i=0; (i+7)<size; i+=8)
    {
        logDbg(pMac, modId, level,
                 "%02x %02x %02x %02x %02x %02x %02x %02x \n",
                 buf[i],
                 buf[i+1],
                 buf[i+2],
                 buf[i+3],
                 buf[i+4],
                 buf[i+5],
                 buf[i+6],
                 buf[i+7]);
    }

    // Dump the bytes in the last line
    for (; i < size; i++)
    {
        logDbg(pMac, modId, level, "%02x ", buf[i]);

        if((i+1) == size)
            logDbg(pMac, modId, level, "\n");
    }

}/*** end sirDumpBuf() ***/
Exemplo n.º 2
0
int
virgo__lua_debug_stackwalk(lua_State *L)
{

  virgo_t* v = virgo__lua_context(L);
  const char *errstr = lua_tostring(L, 1);
  lua_Debug ldbg;
  int i = 0;
  
  logDbg(v, "Lua stack backtrace: %s", errstr);

  /* start at 1 to skip this function. */
  for (i = 1; lua_getstack(L, i, &ldbg); i++)
  {
    char *ptr = (char *) scratchbuf;
    size_t len = sizeof (scratchbuf);
    int bw = snprintfcat(&ptr, &len, "#%d", i-1);
    const int maxspacing = 4;
    int spacing = maxspacing - bw;
    while (spacing-- > 0)
      snprintfcat(&ptr, &len, " ");
    
    if (!lua_getinfo(L, "nSl", &ldbg))
    {
      snprintfcat(&ptr, &len, "???\n");
      logDbg(v, "%s", (const char *) scratchbuf);
      continue;
    }
    
    if (ldbg.namewhat[0])
      snprintfcat(&ptr, &len, "%s ", ldbg.namewhat);
    
    if ((ldbg.name) && (ldbg.name[0]))
      snprintfcat(&ptr, &len, "function %s ()", ldbg.name);
    else
    {
      if (strcmp(ldbg.what, "main") == 0)
        snprintfcat(&ptr, &len, "mainline of chunk");
      else if (strcmp(ldbg.what, "tail") == 0)
        snprintfcat(&ptr, &len, "tail call");
      else
        snprintfcat(&ptr, &len, "unidentifiable function");
    }
    
    ptr = (char *) scratchbuf;
    len = sizeof (scratchbuf);
    
    for (spacing = 0; spacing < maxspacing; spacing++)
      snprintfcat(&ptr, &len, " ");
    
    if (strcmp(ldbg.what, "C") == 0)
      snprintfcat(&ptr, &len, "in native code");
    else if (strcmp(ldbg.what, "tail") == 0)
      snprintfcat(&ptr, &len, "in Lua code");
    else if ( (strcmp(ldbg.source, "=?") == 0) && (ldbg.currentline == 0) )
      snprintfcat(&ptr, &len, "in Lua code (debug info stripped)");
    else
    {
      snprintfcat(&ptr, &len, "in Lua code at %s", ldbg.short_src);
      if (ldbg.currentline != -1)
        snprintfcat(&ptr, &len, ":%d", ldbg.currentline);
      snprintfcat(&ptr, &len, " %s()", ldbg.name);
    }
    logDbg(v, "%s", (const char *) scratchbuf);
  }
  
  return 0;
}