Beispiel #1
0
bool CSynapseServer::DoResolve( CSynapseClient *pClient ) {
    list<CSynapseClientSlot>::iterator iSlot;
    for ( iSlot = mClients.begin(); iSlot != mClients.end(); iSlot++ )
    {
        if ( ( *iSlot ).mpClient == pClient ) {
            break;
        }
    }
    if ( iSlot == mClients.end() ) {
        Syn_Printf( "CSynapserServer::Resolve adding new client slot '%s'\n", pClient->GetInfo() );
        CSynapseClientSlot slot;
        slot.mpClient = pClient;
        slot.mFileName = "local client";
        // make it active so we can request the interfaces already
        pClient->ForceSetActive();
        mClients.push_front( slot );
    }
    else
    {
        // make it active so we can request the interfaces already
        ( *iSlot ).mpClient->ForceSetActive();
    }

    // push the interfaces that need to be resolved for this client
    // NOTE: this doesn't take care of the SYN_REQUIRE_ANY interfaces
    PushRequired( pClient );
    // start resolving now
    // working till the stack is emptied or till we reach a dead end situation
    // we do a depth first traversal, we will grow the interface stack to be resolved till we start finding solutions
    list<APIDescriptor_t*>::iterator iCurrent;
    mbStackChanged = true; // init to true so we try the first elem
    while ( !mStack.empty() )
    {
        //DumpStack();
        if ( !mbStackChanged ) {
            // the stack didn't change last loop
            iCurrent++;
            if ( iCurrent == mStack.end() ) {
                Syn_Printf( "ERROR: CSynapseServer::Resolve, failed to resolve\n" );
                DumpStack();
                return false;
            }
            if ( ResolveAPI( *iCurrent ) ) {
                iCurrent = mStack.erase( iCurrent );
                mbStackChanged = true;
            }
        }
        else
        {
            // the stack changed at last loop
            mbStackChanged = false;
            iCurrent = mStack.begin();
            if ( ResolveAPI( *iCurrent ) ) {
                iCurrent = mStack.erase( iCurrent );
                mbStackChanged = true;
            }
        }
    }
    return true;
}
/**
 * \brief The Hard Fault Handler
 *
 */
void Hard_Fault_Handler(uint32_t stack[])
{
	static char msg[80];
	printErrorMsg("Hard Fault!!!\n");
	sprintf(msg, "SCB->HFSR = 0x%08x\n", SCB->HFSR);
	printErrorMsg(msg);

	if ((SCB->HFSR & (1 << 30)) != 0) {
		printErrorMsg("Forced Hard Fault\n");
		sprintf(msg, "SCB->CFSR = 0x%08x\n", SCB->CFSR);
		printErrorMsg(msg);

		if ((SCB->CFSR & 0xFFFF0000) != 0) {
			printUsageErrorMsg(SCB->CFSR);
		}

		if ((SCB->CFSR & 0xFF00) != 0) {
			printBusFaultErrorMsg(SCB->CFSR);
		}

		if ((SCB->CFSR & 0xFF) != 0) {
			printMemoryManagementErrorMsg(SCB->CFSR);
		}
	}

	DumpStack(stack);
	HardFaultHandlerUser(stack);

#if defined(__ICCARM__)
	__asm volatile("BKPT #01");
#endif

	while (1) {};
}
Beispiel #3
0
static int
MemoryTrackerTrackDeallocate( 
	IN void *pMemory )
{
	MEM_ALLOC_HDR	*pHdr;
	LIST_ITEM		*pListItem;
	int				result = 0;

	if( pMemTracker )
	{
		SpinLockAcquire( &pMemTracker->Lock );

		// Removes an item from the allocation tracking list given a pointer
		// To the user's data and returns the pointer to header referencing the
		// allocated memory block.
		pListItem = 
			QListFindFromTail( &pMemTracker->AllocList, NULL, pMemory );

		if( pListItem )
		{
			// Get the pointer to the header.
			pHdr = PARENT_STRUCT( pListItem, MEM_ALLOC_HDR, ListItem );
#ifdef MEM_TRACK_FTR
			MemoryTrackerCheckOverrun(pHdr);
#endif	// MEM_TRACK_FTR

			if (pHdr->displaying) {
				pHdr->deallocate = TRUE;
			} else {
				// Remove the item from the list.
				MemoryTrackerUnlink(pHdr);
			}
		} else {
			int ii;
			for (ii=0; ii<unTindex; ii++) {
				if (unTAddr[ii] == pMemory) {
					unTAddr[ii] = 0; /* found it */
					break;
				}
			}
			if (ii == unTindex) {
				result = 1;
#if defined(VXWORKS)
				MsgOut( "UNMATCHED FREE %p ra=%p\n", pMemory, __builtin_return_address(0));
#else
				MsgOut( "BAD FREE %p\n", pMemory);
#endif
				DumpStack();
			}
		}
		SpinLockRelease( &pMemTracker->Lock );
	}
	return result;
}
bool LuaScriptUtilities::CheckArgumentCountOrDie(
    lua_State* const luaVM,
    const unsigned int argCount,
    const unsigned int optionalArgs)
{
    const unsigned int actualArgCount =
        static_cast<unsigned int>(lua_gettop(luaVM));

    if (actualArgCount < argCount || actualArgCount > (argCount + optionalArgs))
    {
        Ogre::LogManager* const logManager = Ogre::LogManager::getSingletonPtr();

        char buffer[2048];

        if (optionalArgs)
        {
            sprintf_s(
                buffer,
                sizeof(buffer),
                "LUA_ERROR: \"%s\" expected at least %d arguments but no more "
                "than %d arguments, encountered %d.",
                GetCallingFunctionName(luaVM).c_str(),
                argCount,
                argCount + optionalArgs,
                actualArgCount);
        }
        else
        {
            sprintf_s(
                buffer,
                sizeof(buffer),
                "LUA_ERROR: \"%s\" expected %d arguments, encountered %d.",
                GetCallingFunctionName(luaVM).c_str(),
                argCount,
                actualArgCount);
        }

        logManager->logMessage(
            buffer, Ogre::LML_CRITICAL);

        DumpStack(luaVM, Ogre::LML_CRITICAL);
        DumpStackTrace(luaVM, Ogre::LML_CRITICAL);

        PushErrorMessageAndDie(luaVM, buffer);

        return false;
    }

    return true;
}
/*************************************************************************
 * StackTrace
 */
void StackTrace(char *gdb_command_file)
{
#if defined(PLATFORM_UNIX)
  /*
   * In general dbx seems to do a better job than gdb.
   *
   * Different dbx implementations require different flags/commands.
   */

# if defined(PLATFORM_AIX)

  if (DumpStack("dbx -a %d 2>/dev/null <<EOF\n"
		"where\n"
		"detach\n"
		"EOF\n",
		(int)getpid()))
    return;

  if (DumpStack("gdb -q %s %d 2>/dev/null <<EOF\n"
		"set prompt\n"
		"where\n"
		"detach\n"
		"quit\n"
		"EOF\n",
		global_progname, (int)getpid()))
    return;

# elif defined(PLATFORM_FREEBSD)

  /*
   * FreeBSD insists on sending a SIGSTOP to the process we
   * attach to, so we let the debugger send a SIGCONT to that
   * process after we have detached.
   */
  if (DumpStack("gdb -q %s %d 2>/dev/null <<EOF\n"
		"set prompt\n"
		"where\n"
		"detach\n"
		"shell kill -CONT %d\n"
		"quit\n"
		"EOF\n",
		global_progname, (int)getpid(), (int)getpid()))
    return;

# elif defined(PLATFORM_HPUX)

  /*
   * HP decided to call their debugger xdb.
   *
   * This does not seem to work properly yet. The debugger says
   * "Note: Stack traces may not be possible until you are
   *  stopped in user code." on HP-UX 09.01
   *
   * -L = line-oriented interface.
   * "T [depth]" gives a stacktrace with local variables.
   * The final "y" is confirmation to the quit command.
   */

  if (DumpStack("xdb -P %d -L %s 2>&1 <<EOF\n"
		"T 50\n"
		"q\ny\n"
		"EOF\n",
		(int)getpid(), global_progname))
    return;

  if (DumpStack("gdb -q %s %d 2>/dev/null <<EOF\n"
		"set prompt\n"
		"where\n"
		"detach\n"
		"quit\n"
		"EOF\n",
		global_progname, (int)getpid()))
    return;

#  if defined(PLATFORM_HPUX) && defined(USE_BUILTIN)
  U_STACK_TRACE();
  return;
#  endif

# elif defined(PLATFORM_IRIX)

  /*
   * "set $page=0" drops hold mode
   * "dump ." displays the contents of the variables
   */
  if (DumpStack("dbx -p %d 2>/dev/null <<EOF\n"
		"set \\$page=0\n"
		"where\n"
#  if !defined(__GNUC__)
		/* gcc does not generate this information */
		"dump .\n"
#  endif
		"detach\n"
		"EOF\n",
		(int)getpid()))
    return;

#  if defined(USE_BUILTIN)
  if (trace_back_stack_and_print())
    return;
#  endif

  if (DumpStack("gdb -q %s %d 2>/dev/null <<EOF\n"
		"set prompt\n"
		"echo --- Stacktrace\\n\n"
		"where\n"
		"echo --- Symbols\\n\n"
		"frame 5\n"      /* Skip signal handler frames */
		"set \\$x = 50\n"
		"while (\\$x)\n" /* Print local variables for each frame */
		"info locals\n"
		"up\n"
		"set \\$x--\n"
		"end\n"
		"echo ---\\n\n"
		"detach\n"
		"quit\n"
		"EOF\n",
		global_progname, (int)getpid()))
    return;

# elif defined(PLATFORM_OSF)

  if (DumpStack("dbx -pid %d %s 2>/dev/null <<EOF\n"
		"where\n"
		"detach\n"
		"quit\n"
		"EOF\n",
		(int)getpid(), global_progname))
    return;

  if (DumpStack("gdb -q %s %d 2>/dev/null <<EOF\n"
		"set prompt\n"
		"where\n"
		"detach\n"
		"quit\n"
		"EOF\n",
		global_progname, (int)getpid()))
    return;

# elif defined(PLATFORM_SCO)

  /*
   * SCO OpenServer dbx is like a catch-22. The 'detach' command
   * depends on whether ptrace(S) support detaching or not. If it
   * is supported then 'detach' must be used, otherwise the process
   * will be killed upon dbx exit. If it isn't supported then 'detach'
   * will cause the process to be killed. We do not want it to be
   * killed.
   *
   * Out of two evils, the omission of 'detach' was chosen because
   * it worked on our system.
   */
  if (DumpStack("dbx %s %d 2>/dev/null <<EOF\n"
		"where\n"
		"quit\nEOF\n",
		global_progname, (int)getpid()))
    return;

  if (DumpStack("gdb -q %s %d 2>/dev/null <<EOF\n"
		"set prompt\n"
		"where\n"
		"detach\n"
		"quit\n"
		"EOF\n",
		global_progname, (int)getpid()))
    return;

# elif defined(PLATFORM_SOLARIS)

  if (DumpStack("dbx %s %d 2>/dev/null <<EOF\n"
		"where\n"
		"detach\n"
		"EOF\n",
		global_progname, (int)getpid()))
    return;

  if (DumpStack("gdb -q %s %d 2>/dev/null <<EOF\n"
		"set prompt\n"
		"echo --- Stacktrace\\n\n"
		"where\n"
		"echo --- Symbols\\n\n"
		"frame 5\n"      /* Skip signal handler frames */
		"set \\$x = 50\n"
		"while (\\$x)\n" /* Print local variables for each frame */
		"info locals\n"
		"up\n"
		"set \\$x--\n"
		"end\n"
		"echo ---\\n\n"
		"detach\n"
		"quit\n"
		"EOF\n",
		global_progname, (int)getpid()))
    return;

  if (DumpStack("/usr/proc/bin/pstack %d",
		(int)getpid()))
    return;

  /*
   * Other Unices (AIX, HPUX, SCO) also have adb, but
   * they seem unable to attach to a running process.
   */
  if (DumpStack("adb %s 2>&1 <<EOF\n"
		"0t%d:A\n" /* Attach to pid */
		"\\$c\n"   /* print stacktrace */
		":R\n"     /* Detach */
		"\\$q\n"   /* Quit */
		"EOF\n",
		global_progname, (int)getpid()))
    return;

# else /* All other Unix platforms */

  /*
   * TODO: SCO/UnixWare 7 must be something like (not tested)
   *  debug -i c <pid> <<EOF\nstack -f 4\nquit\nEOF\n
   */

#  if !defined(__GNUC__)
  if (DumpStack("dbx %s %d 2>/dev/null <<EOF\n"
		"where\n"
		"detach\n"
		"EOF\n",
		global_progname, (int)getpid()))
    return;
#  endif

  // This version works (piping from a file)
  if (DumpStack("gdb -q %s %d 2>/dev/null <%s >fweelin-stackdump",
		global_progname, (int)getpid(), gdb_command_file))
    return;

#if 0
  // This version does not work (piping from stdin)
  if (DumpStack("gdb -q %s %d 2>/dev/null <<EOF\n"
		"set prompt\n"
		"echo --- Stacktrace\\n\n"
		"where\n"
		"echo --- Symbols\\n\n"
		"frame 4\n"
		"set \\$x = 50\n"
		"while (\\$x)\n" /* Print local variables for each frame */
		"info locals\n"
		"up\n"
		"set \\$x--\n"
		"end\n"
		"echo ---\\n\n"
		"detach\n"
		"quit\n"
		"EOF\n",
		global_progname, (int)getpid()))
    return;
#endif

# endif

# if defined(__GNUC__) && defined(USE_BUILTIN)

  GCC_DumpStack();

# endif

  write(global_output,
	"No debugger found\n", strlen("No debugger found\n"));

#elif defined(PLATFORM_WIN32)
  /* Use StackWalk() */
#endif
}
Beispiel #6
0
VOID LoginExceptionHandler::XFSZHandler(INT)
{
	DumpStack("XFSZ exception:\r\n");
	exit(0);
}
Beispiel #7
0
VOID LoginExceptionHandler::SEGHandler(INT)
{
	DumpStack("SEG exception:\r\n");
	exit(0);
}
Beispiel #8
0
VOID LoginExceptionHandler::FPEHandler(INT)
{
	DumpStack("FPE exception:\r\n");
	exit(0);
}
Beispiel #9
0
VOID LoginExceptionHandler::ILLHandler(INT)
{
	DumpStack("ILL exception:\r\n");
	exit(0);
}
Beispiel #10
0
VOID LoginExceptionHandler::ABORTHandler(INT)
{
	DumpStack("ABORT exception:\r\n");
	exit(0);
}
Beispiel #11
0
VOID LoginExceptionHandler::TERMHandler(INT)
{
	DumpStack("TERM exception:\r\n");
	exit(0);

}
Beispiel #12
0
static
int FindLongestPath(int Group)
{
    int     HighWater;
    TNode*  Stack;
    TNode*  Node;

    Stack       = (TNode*)malloc(sizeof(TNode)*MaxGroups*2);
    assert(Stack != NULL);

    Node        = Stack;
//???    Node->Group = Groups[Group*2];
    Node->Group = Group;
    Node->Edge  = Groups[Group*2+1];
    HighWater   = 0;
    printf("group=%d, MaxGroups=%d, Node->Group=%d\n", Group, MaxGroups, Node->Group);
    while(Node >= Stack)
    {
        DumpStack(Stack, Node);
        /* if we hit end of linked list for this stacked node */
        if(Node->Edge == -1)
        {
            /* pop stack until we find a node not at end of its list */
            while(Node->Edge == -1 && Node >= Stack)
                --Node;
        }
        /* else, push the node pointed to by current edge */
        else
        {
            Group           = Edges[Node->Edge*2];
            if(GroupInStack(Stack, (Node-Stack)+1, Group))
            {
                int     iStack;
                TNode*  Rover = Stack;

                if(Globals.Dump)
                {
                    DumpInternal();
                    for(iStack=0; Rover <= Node; ++iStack)
                    {
                        fprintf(stdout, "stack[%d] group = %d, edge = %d\n", iStack, Rover->Group, Rover->Edge);
                        ++Rover;
                    }
                }
                ErrorExit(ERROR_FAILED_OP_PREC_TABLE,
                          "Internal error(FindLongestPath() cycle via %d\n"
                          "Can't create operator precedence table.\n",
                          Group
                         );
            }
            /* ??? is this off by one?*/
            assert(Node-Stack < MaxGroups*2);
            Node[1].Group   = Group;
            Node[1].Edge    = Groups[Group*2+1];
            printf("push group=%d, Edge=%d\n", Group, Groups[Group*2+1]);
            /* but first advance in linked list of current topmost node */
            Node->Edge      = Edges[Node->Edge*2+1];
            printf("    previous edge moves to %d\n", Node->Edge);
            ++Node;
        }

        if(Node-Stack > HighWater)
            HighWater   = Node-Stack;
    }

    printf("HighWater was %d\n", HighWater);
    free(Stack);

    return HighWater;
}