コード例 #1
0
ファイル: listing.c プロジェクト: cc65/cc65
void InitListingLine (void)
/* Initialize the current listing line */
{
    if (SB_GetLen (&ListingName) > 0) {
        /* Make the last loaded line the current line */
        /* ###### This code is a hack! We really need to do it right --
        ** as soon as we know how. :-(
        */
        if (LineCur && LineCur->Next && LineCur->Next != LineLast) {
            ListLine* L = LineCur;
            do {
                L = L->Next;
                /* Set the values for this line */
                CHECK (L != 0);
                L->PC            = GetPC ();
                L->Reloc         = GetRelocMode ();
                L->Output        = (ListingEnabled > 0);
                L->ListBytes = (unsigned char) ListBytes;
            } while (L->Next != LineLast);
        }
        LineCur = LineLast;

        /* Set the values for this line */
        CHECK (LineCur != 0);
        LineCur->PC         = GetPC ();
        LineCur->Reloc      = GetRelocMode ();
        LineCur->Output     = (ListingEnabled > 0);
        LineCur->ListBytes  = (unsigned char) ListBytes;
    }
}
コード例 #2
0
UFlareSimulatedSector* AFlareGame::DeactivateSector()
{
	if (!ActiveSector)
	{
		return NULL;
	}

	UFlareSimulatedSector* Sector = ActiveSector->GetSimulatedSector();
	FLOGV("AFlareGame::DeactivateSector : %s", *Sector->GetSectorName().ToString());
	World->Save();

	// Set last flown ship
	UFlareSimulatedSpacecraft* PlayerShip = NULL;
	if (GetPC()->GetPlayerShip())
	{
		PlayerShip = GetPC()->GetPlayerShip();
	}

	// Destroy the active sector
	DebrisFieldSystem->Reset();
	UnloadStreamingLevel(ActiveSector->GetSimulatedSector()->GetDescription()->LevelName);
	ActiveSector->DestroySector();
	ActiveSector = NULL;

	// Update the PC
	GetPC()->OnSectorDeactivated();
	SaveGame(GetPC());

	return Sector;
}
コード例 #3
0
void AFlareGame::Scrap(FName ShipImmatriculation, FName TargetStationImmatriculation)
{
	DeactivateSector();

	UFlareSimulatedSpacecraft* ShipToScrap = World->FindSpacecraft(ShipImmatriculation);
	UFlareSimulatedSpacecraft* ScrapingStation = World->FindSpacecraft(TargetStationImmatriculation);

	if(!ShipToScrap || !ScrapingStation)
	{
		FLOG("Scrap failed: ship to scrap or station not found");
		return;
	}

	if(ShipToScrap->GetCurrentSector() != ScrapingStation->GetCurrentSector())
	{
		FLOG("Scrap failed: ship and station not in the same sector");
		return;
	}
	UFlareSimulatedSector* CurrentSector = ShipToScrap->GetCurrentSector();

	int64 ScrapRevenue = 0;

	for (int ResourceIndex = 0; ResourceIndex < ShipToScrap->GetDescription()->CycleCost.InputResources.Num() ; ResourceIndex++)
	{
		FFlareFactoryResource* Resource = &ShipToScrap->GetDescription()->CycleCost.InputResources[ResourceIndex];


		ScrapRevenue += Resource->Quantity * CurrentSector->GetResourcePrice(&Resource->Resource->Data, EFlareResourcePriceContext::Default);
		int ResourceToGive = Resource->Quantity;

		ResourceToGive -= ScrapingStation->GetCargoBay()->GiveResources(&Resource->Resource->Data, Resource->Quantity);
		CurrentSector->GiveResources(ScrapingStation->GetCompany(), &Resource->Resource->Data, ResourceToGive, true);
	}


	ScrapRevenue = FMath::Min(ScrapRevenue, ScrapingStation->GetCompany()->GetMoney());

	FLOGV("Scrap success for %d", ScrapRevenue);

	if (ScrapingStation->GetCompany() != ShipToScrap->GetCompany())
	{
		ScrapingStation->GetCompany()->TakeMoney(ScrapRevenue);
		ShipToScrap->GetCompany()->GiveMoney(ScrapRevenue);
		GetPC()->Notify(LOCTEXT("ShipSellScrap", "Ship scrap complete"),
			FText::Format(LOCTEXT("ShipSellScrapFormat", "Your ship {0} has been scrapped for {1} credits!"), FText::FromString(ShipToScrap->GetImmatriculation().ToString()), FText::AsNumber(UFlareGameTools::DisplayMoney(ScrapRevenue))),
			FName("ship-own-scraped"),
			EFlareNotification::NT_Economy);
	}
	else
	{
		GetPC()->Notify(LOCTEXT("ShipOwnScrap", "Ship scrap complete"),
			FText::Format(LOCTEXT("ShipOwnScrapFormat", "Your ship {0} has been scrapped !"), FText::FromString(ShipToScrap->GetImmatriculation().ToString())),
			FName("ship-own-scraped"),
			EFlareNotification::NT_Economy);
	}

	ShipToScrap->GetCompany()->DestroySpacecraft(ShipToScrap);
}
コード例 #4
0
ファイル: MachThread.cpp プロジェクト: eightcien/lldb
void
MachThread::Dump(uint32_t index)
{
    const char * thread_run_state = NULL;

    switch (m_basicInfo.run_state)
    {
    case TH_STATE_RUNNING:          thread_run_state = "running"; break;    // 1 thread is running normally
    case TH_STATE_STOPPED:          thread_run_state = "stopped"; break;    // 2 thread is stopped
    case TH_STATE_WAITING:          thread_run_state = "waiting"; break;    // 3 thread is waiting normally
    case TH_STATE_UNINTERRUPTIBLE:  thread_run_state = "uninter"; break;    // 4 thread is in an uninterruptible wait
    case TH_STATE_HALTED:           thread_run_state = "halted "; break;     // 5 thread is halted at a
    default:                        thread_run_state = "???"; break;
    }

    DNBLogThreaded("[%3u] #%3u tid: 0x%4.4x, pc: 0x%16.16llx, sp: 0x%16.16llx, breakID: %3d, user: %d.%06.6d, system: %d.%06.6d, cpu: %2d, policy: %2d, run_state: %2d (%s), flags: %2d, suspend_count: %2d (current %2d), sleep_time: %d",
        index,
        m_seq_id,
        m_tid,
        GetPC(INVALID_NUB_ADDRESS),
        GetSP(INVALID_NUB_ADDRESS),
        m_breakID,
        m_basicInfo.user_time.seconds,      m_basicInfo.user_time.microseconds,
        m_basicInfo.system_time.seconds,    m_basicInfo.system_time.microseconds,
        m_basicInfo.cpu_usage,
        m_basicInfo.policy,
        m_basicInfo.run_state,
        thread_run_state,
        m_basicInfo.flags,
        m_basicInfo.suspend_count, m_suspendCount,
        m_basicInfo.sleep_time);
    //DumpRegisterState(0);
}
コード例 #5
0
ファイル: vmprof.c プロジェクト: pypyjs/pypy
static void sigprof_handler(int sig_nr, siginfo_t* info, void *ucontext) {
    void* stack[MAX_STACK_DEPTH];
    int saved_errno = errno;
    stack[0] = GetPC((ucontext_t*)ucontext);
    int depth = frame_forcer(get_stack_trace(stack+1, MAX_STACK_DEPTH-1, ucontext));
    depth++;  // To account for pc value in stack[0];
    prof_write_stacktrace(stack, depth, 1);
    errno = saved_errno;
}
bool
RegisterContextPOSIXProcessMonitor_arm64::UpdateAfterBreakpoint()
{
    // PC points one byte past the int3 responsible for the breakpoint.
    lldb::addr_t pc;

    if ((pc = GetPC()) == LLDB_INVALID_ADDRESS)
        return false;

    SetPC(pc - 1);
    return true;
}
コード例 #7
0
ファイル: Game.cpp プロジェクト: BlackLotus/gemrb
int Game::JoinParty(Actor* actor, int join)
{
	core->SetEventFlag(EF_PORTRAIT);
	actor->CreateStats(); //create stats if they didn't exist yet
	actor->InitButtons(actor->GetStat(IE_CLASS), false); //init actor's buttons
	actor->SetBase(IE_EXPLORE, 1);
	if (join&JP_INITPOS) {
		InitActorPos(actor);
	}
	int slot = InParty( actor );
	if (slot != -1) {
		return slot;
	}
	size_t size = PCs.size();
	//set the lastjoined trigger

	if (join&JP_JOIN) {
		//update kit abilities of actor
		actor->ApplyKit(false);
		//update the quickslots
		actor->ReinitQuickSlots();
		//set the joining date
		actor->PCStats->JoinDate = GameTime;
		if (size) {
			ieDword id = actor->GetGlobalID();
			for (size_t i=0;i<size; i++) {
				Actor *a = GetPC(i, false);
				a->PCStats->LastJoined = id;
			}
		} else {
			Reputation = actor->GetStat(IE_REPUTATION);
		}
	}
	slot = InStore( actor );
	if (slot >= 0) {
		std::vector< Actor*>::iterator m = NPCs.begin() + slot;
		NPCs.erase( m );
	}


	PCs.push_back( actor );
	if (!actor->InParty) {
		actor->InParty = (ieByte) (size+1);
	}

	if (join&(JP_INITPOS|JP_SELECT)) {
		actor->Selected = 0; // don't confuse SelectActor!
		SelectActor(actor,true, SELECT_NORMAL);
	}

	return ( int ) size;
}
コード例 #8
0
ファイル: DNBArchImplI386.cpp プロジェクト: ice799/lldb
bool
DNBArchImplI386::NotifyException(MachException::Data& exc)
{
    switch (exc.exc_type)
    {
    case EXC_BAD_ACCESS:
        break;
    case EXC_BAD_INSTRUCTION:
        break;
    case EXC_ARITHMETIC:
        break;
    case EXC_EMULATION:
        break;
    case EXC_SOFTWARE:
        break;
    case EXC_BREAKPOINT:
        if (exc.exc_data.size() >= 2 && exc.exc_data[0] == 2)
        {
            nub_addr_t pc = GetPC(INVALID_NUB_ADDRESS);
            if (pc != INVALID_NUB_ADDRESS && pc > 0)
            {
                pc -= 1;
                // Check for a breakpoint at one byte prior to the current PC value
                // since the PC will be just past the trap.

                nub_break_t breakID = m_thread->Process()->Breakpoints().FindIDByAddress(pc);
                if (NUB_BREAK_ID_IS_VALID(breakID))
                {
                    // Backup the PC for i386 since the trap was taken and the PC
                    // is at the address following the single byte trap instruction.
                    if (m_state.context.gpr.__eip > 0)
                    {
                        m_state.context.gpr.__eip = pc;
                        // Write the new PC back out
                        SetGPRState ();
                    }

                    m_thread->SetCurrentBreakpoint(breakID);
                }
                return true;
            }
        }
        break;
    case EXC_SYSCALL:
        break;
    case EXC_MACH_SYSCALL:
        break;
    case EXC_RPC_ALERT:
        break;
    }
    return false;
}
コード例 #9
0
ファイル: CProgram.cpp プロジェクト: MaddTheSane/tntbasic
// ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ
//		¥ Step														/*e*/
// ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ
// Executes one statement, returns true if the program is still running, false otherwise.
bool CProgram::Step()
{
	AssertThrow_(mProgramState==kRunning);
	
	CStatement	*statement=GetPC();
	
	if (statement)
		statement->Execute(*this);
	else
		return false;

	return true;
}
コード例 #10
0
void 
compressed_inst_record_t::Print(FILE *file) {
  fprintf(file, "0x%llx:%2d %c%c%c%c%c%c%c%c%c %8dF %8dD %8dQ %8dR %8dE %8dC %8dR", GetPC(), cir->uop_num,
          (cir->events & ICACHE_MISS ? 'I' : ' '), (cir->events & DCACHE_MISS ? 'D' : ' '), 
          (cir->events & BRANCH_MISP ? 'B' : ' '), (cir->events & ORDERING_VIOLATION_S ? 'S' : ' '), 
          (cir->events & ORDERING_VIOLATION_L ? 'L' : ' '), (cir->events & COHERENCE_VIOLATION ? 'C' : ' '), 
          (cir->events & WRONG_PATH ? 'W' : ' '), (cir->events & PIPELINE_RESET ? 'R' : ' '),
          (cir->events & UNALIGNED ? 'U' : ' '),
          (int)Get(FETCH_STAGE), (int)Get(DECODE_STAGE), (int)Get(QUEUE_STAGE), 
          (int)Get(READY_STAGE), (int)Get(EXECUTE_STAGE), (int)Get(COMPLETE_STAGE), 
          (int)Get(RETIRE_STAGE));
  for (int i = 0 ; i < 3 ; i ++) {
	 if (cir->dep_offset[i] != 0) { fprintf(file, " (%8d)", (int)(q - cir->dep_offset[i])); }
  }
  fprintf(file, "\n");
}
コード例 #11
0
ファイル: MachThread.cpp プロジェクト: ice799/lldb
bool
MachThread::NotifyException(MachException::Data& exc)
{
    if (m_stop_exception.IsValid())
    {
        // We may have more than one exception for a thread, but we need to
        // only remember the one that we will say is the reason we stopped.
        // We may have been single stepping and also gotten a signal exception,
        // so just remember the most pertinent one.
        if (m_stop_exception.IsBreakpoint())
            m_stop_exception = exc;
    }
    else
    {
        m_stop_exception = exc;
    }
    bool handled = m_arch.NotifyException(exc);
    if (!handled)
    {
        handled = true;
        nub_addr_t pc = GetPC();
        nub_break_t breakID = m_process->Breakpoints().FindIDByAddress(pc);
        SetCurrentBreakpoint(breakID);
        switch (exc.exc_type)
        {
        case EXC_BAD_ACCESS:
            break;
        case EXC_BAD_INSTRUCTION:
            break;
        case EXC_ARITHMETIC:
            break;
        case EXC_EMULATION:
            break;
        case EXC_SOFTWARE:
            break;
        case EXC_BREAKPOINT:
            break;
        case EXC_SYSCALL:
            break;
        case EXC_MACH_SYSCALL:
            break;
        case EXC_RPC_ALERT:
            break;
        }
    }
    return handled;
}
コード例 #12
0
ファイル: MachThread.cpp プロジェクト: llvm-project/lldb
bool MachThread::IsUserReady() {
  if (m_basic_info.run_state == 0)
    GetBasicInfo();

  switch (m_basic_info.run_state) {
  default:
  case TH_STATE_UNINTERRUPTIBLE:
    break;

  case TH_STATE_RUNNING:
  case TH_STATE_STOPPED:
  case TH_STATE_WAITING:
  case TH_STATE_HALTED:
    return true;
  }
  return GetPC(0) != 0;
}
コード例 #13
0
void
compressed_inst_record_t::Print(FILE *file, inst_record_t::stage_t stage){

  fprintf(file, "0x%llx:\t", GetPC());
  switch(stage){
  case QUEUE_STAGE:
    fprintf(file, "D\t");
    break;
  case COMPLETE_STAGE:
    fprintf(file, "E\t");
    break;
  case RETIRE_STAGE:
    fprintf(file, "C\t");
    break;
  default: 
    break;
  }
  fprintf(file, "%8d\n", (int)Get(stage));
}
コード例 #14
0
ファイル: MachThread.cpp プロジェクト: ice799/lldb
void
MachThread::NotifyBreakpointChanged (const DNBBreakpoint *bp)
{
    nub_break_t breakID = bp->GetID();
    if (bp->IsEnabled())
    {
        if (bp->Address() == GetPC())
        {
            SetCurrentBreakpoint(breakID);
        }
    }
    else
    {
        if (CurrentBreakpoint() == breakID)
        {
            SetCurrentBreakpoint(INVALID_NUB_BREAK_ID);
        }
    }
}
コード例 #15
0
ファイル: listing.c プロジェクト: cc65/cc65
void NewListingLine (const StrBuf* Line, unsigned char File, unsigned char Depth)
/* Create a new ListLine struct and insert it */
{
    /* Store only if listing is enabled */
    if (SB_GetLen (&ListingName) > 0) {

        ListLine* L;

        /* Get the length of the line */
        unsigned Len = SB_GetLen (Line);

        /* Ignore trailing newlines */
        while (Len > 0 && SB_AtUnchecked (Line, Len-1) == '\n') {
            --Len;
        }

        /* Allocate memory */
        L = xmalloc (sizeof (ListLine) + Len);

        /* Initialize the fields. */
        L->Next         = 0;
        L->FragList     = 0;
        L->FragLast     = 0;
        L->PC           = GetPC ();
        L->Reloc        = GetRelocMode ();
        L->File         = File;
        L->Depth        = Depth;
        L->Output       = (ListingEnabled > 0);
        L->ListBytes    = (unsigned char) ListBytes;
        memcpy (L->Line, SB_GetConstBuf (Line), Len);
        L->Line[Len] = '\0';

        /* Insert the line into the list of lines */
        if (LineList == 0) {
            LineList = L;
        } else {
            LineLast->Next = L;
        }
        LineLast = L;
    }
}
コード例 #16
0
ファイル: MachThread.cpp プロジェクト: eightcien/lldb
nub_break_t
MachThread::CurrentBreakpoint()
{
    return m_process->Breakpoints().FindIDByAddress(GetPC());
}
コード例 #17
0
void AFlareGame::ActivateCurrentSector()
{
	ActivateSector(GetPC()->GetPlayerShip()->GetCurrentSector());
}
コード例 #18
0
ファイル: mips_env.cpp プロジェクト: 8l/swimmer_riscv
void MipsEnv::StepExec (void)
{
    if (IsStopSim() == true) {
        return;
    }

    SetJumped (false);

    Word_t inst_hex;
    int32_t fetch_res;
    Addr_t  fetch_pc = GetPC();
    fetch_res = FetchMemory (fetch_pc, &inst_hex);

    if (fetch_res == -1) {
        DebugPrint ("<Error: Instructino is Misaligned>\n");
        return;
    }

    std::string func_symbol;
    if ((IsDebugFunc () == true) &&
        (FindSymbol (fetch_pc, &func_symbol) == true)) {
        DebugPrint ("<Func: %s>\n", func_symbol.c_str());
    }

    GetTrace()->SetInstHex (inst_hex);
    GetTrace()->SetTracePC (GetPC());
    GetTrace()->SetStep(GetStep());

    AdvanceStep ();    // Update Step Information

    uint32_t  inst_idx = MIPS_DEC (inst_hex);
    GetTrace()->SetInstIdx (inst_idx);

    if (inst_idx == static_cast<uint32_t>(-1)) {
        DebugPrint ("<Error: instruction is not decoded. [%08x]=%08x\n", GetPC (), inst_hex);
        exit (EXIT_FAILURE);
    } else {

        m_inst_env->MIPS_Inst_Exec (inst_idx, inst_hex);

        if (IsDebugTrace() == true) {
            if (GetTrace()->IsDelayedSlot() == false) {

                DebugPrint ("%10d : ", GetTrace()->GetStep ());
                DebugPrint ("[%08x] %08x : ", GetTrace()->GetTracePC (), GetTrace()->GetInstHex ());
                char inst_string[31];
                PrintInst (GetTrace()->GetInstHex(), GetTrace()->GetInstIdx(),
                           inst_string, 30);
                DebugPrint ("%-30s  ", inst_string);
                std::stringstream operand_str;
                PrintOperand (&operand_str);

                DebugPrint ("%s\n", operand_str.str().c_str());

                if (GetTrace()->IsDelayedSlotExecuted () != 0) {
                    GetTrace()->SetDelayedSlot ();
                    DebugPrint ("%10d : ", GetTrace()->GetStep ());
                    DebugPrint ("[%08x] %08x : ", GetTrace()->GetTracePC (), GetTrace()->GetInstHex());
                    char inst_string[31];
                    PrintInst (GetTrace()->GetInstHex(), GetTrace()->GetInstIdx(),
                               inst_string, 30);
                    DebugPrint ("%-30s  ", inst_string);
                    std::stringstream operand_str;
                    PrintOperand (&operand_str);
                    DebugPrint ("%s\n", operand_str.str().c_str());
                    GetTrace()->ClearDelayedSlot ();
                }
            }
        }
    }

    if ((GetTrace()->IsDelayedSlot() == false) && (GetJumped () == false)) {
        ProceedPC ();      // Update PC
    }
}
コード例 #19
0
ファイル: mips_env.cpp プロジェクト: 8l/swimmer_riscv
void MipsEnv::ProceedPC (void)
{
    SetPC (GetPC () + 4);
}
コード例 #20
0
ファイル: MachThread.cpp プロジェクト: emaste/lldb
DNBBreakpoint *MachThread::CurrentBreakpoint() {
  return m_process->Breakpoints().FindByAddress(GetPC());
}
コード例 #21
0
void AFlareGame::ActivateSector(UFlareSimulatedSector* Sector)
{
	if (!Sector)
	{
		// No sector to activate
		return;
	}

	// Load the sector level - Will call OnLevelLoaded()
	LoadStreamingLevel(Sector->GetDescription()->LevelName);

	// Check if we should really activate
	FLOGV("AFlareGame::ActivateSector : %s", *Sector->GetSectorName().ToString());
	if (ActiveSector)
	{
		FLOG("AFlareGame::ActivateSector : There is already an active sector");
		if (ActiveSector->GetSimulatedSector()->GetIdentifier() == Sector->GetIdentifier())
		{
			// Sector to activate is already active
			return;
		}

		// Deactivate the sector
		DeactivateSector();
	}

	// Ships
	FLOGV("AFlareGame::ActivateSector : Ship count = %d", Sector->GetSectorShips().Num());
	bool PlayerHasShip = false;
	for (int ShipIndex = 0; ShipIndex < Sector->GetSectorShips().Num(); ShipIndex++)
	{
		UFlareSimulatedSpacecraft* Ship = Sector->GetSectorShips()[ShipIndex];
		FLOGV("AFlareGame::ActivateSector : Found ship %s", *Ship->GetImmatriculation().ToString());
		if (Ship->GetCompany()->GetPlayerHostility()  == EFlareHostility::Owned)
		{
			PlayerHasShip = true;
			break;
		}
	}

	// Planetarium & sector setup
	FLOGV("AFlareGame::ActivateSector : PlayerHasShip = %d", PlayerHasShip);
	if (PlayerHasShip)
	{
		// Create the new sector
		ActiveSector = NewObject<UFlareSector>(this, UFlareSector::StaticClass());
		FFlareSectorSave* SectorData = Sector->Save();
		if ((SectorData->LocalTime / UFlareGameTools::SECONDS_IN_DAY)  < GetGameWorld()->GetDate())
		{
			// TODO Find time with light
			SectorData->LocalTime = GetGameWorld()->GetDate() * UFlareGameTools::SECONDS_IN_DAY;
		}

		// Load and setup the sector
		Planetarium->ResetTime();
		Planetarium->SkipNight(UFlareGameTools::SECONDS_IN_DAY);
		ActiveSector->Load(Sector);
		DebrisFieldSystem->Setup(this, Sector);

		GetPC()->OnSectorActivated(ActiveSector);
	}
	GetQuestManager()->OnSectorActivation(Sector);
}