void AvmDebugMsg(const char* p, bool debugBreak)
	{
#ifdef _DEBUG
		char buf[256];
		VMPI_strcpy(buf, p);
		::CopyCStringToPascal(buf, (StringPtr)buf);
		if(debugBreak)
		{
			DebugStr((StringPtr) buf);
			exit(1);	// ensure we die
		}
#else
		(void)p;
		(void)debugBreak;
#endif
	}
Example #2
0
	void DebugCLI::enterDebugger()
	{	
		setCurrentSource( (core->callStack) ? (core->callStack->filename()) : 0 );

		for (;;) {
			printIP();
			
			core->console << "(asdb) ";
			Platform::GetInstance()->getUserInput(commandLine, kMaxCommandLine);

			commandLine[VMPI_strlen(commandLine)-1] = 0;
			
			if (!commandLine[0]) {
				VMPI_strcpy(commandLine, lastCommand);
			} else {
				VMPI_strcpy(lastCommand, commandLine);
			}
				
			currentToken = commandLine;
		
			char *command = nextToken();
			int cmd = commandFor(command);

			switch (cmd) {
			case -1:
				// ambiguous, we already printed error message
				break;
			case CMD_INFO:
				info();
				break;
			case CMD_BREAK:
				breakpoint(nextToken());
				break;
			case CMD_DELETE:
				deleteBreakpoint(nextToken());
				break;
			case CMD_LIST:
				list(nextToken());
				break;
			case CMD_UNKNOWN:
				core->console << "Unknown command.\n";
				break;
			case CMD_QUIT:
				Platform::GetInstance()->exit(0);
				break;
			case CMD_CONTINUE:
				return;
			case CMD_PRINT:
				print(nextToken());
				break;
			case CMD_NEXT:
				stepOver();
				return;
			case INFO_STACK_CMD:
				bt();
				break;
			case CMD_FINISH:
				stepOut();
				return;
			case CMD_STEP:
				stepInto();
				return;
			case CMD_SET:
				set();
				break;
			default:
				core->console << "Command not implemented.\n";
				break;
			}
		}
	}
/* note:
   1. getpwuid( geteuid() ) shall return the name associated with the effective user ID of the process
   2. getlogin() shall return the name associated with the current login activity
   3. getpwuid( getuid() ) shall return the name associated with the real user ID of the process
*/
void VMPI_getUserName(char *username)
{
    struct passwd *pws;
    pws = getpwuid( geteuid() );
    VMPI_strcpy( username, pws->pw_name );
}