mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-08 11:38:21 +02:00
Allowing HTTP requests for source servers
This commit is contained in:
parent
cb84684517
commit
c2d086fe8e
7 changed files with 110 additions and 31 deletions
41
BeefLibs/Beefy2D/src/utils/HTTP.bf
Normal file
41
BeefLibs/Beefy2D/src/utils/HTTP.bf
Normal file
|
@ -0,0 +1,41 @@
|
||||||
|
using System;
|
||||||
|
|
||||||
|
namespace Beefy2D.utils
|
||||||
|
{
|
||||||
|
class HTTPRequest
|
||||||
|
{
|
||||||
|
public enum HTTPResult
|
||||||
|
{
|
||||||
|
NotDone = -1,
|
||||||
|
Failed = 0,
|
||||||
|
Success = 1
|
||||||
|
}
|
||||||
|
|
||||||
|
void* mNativeNetRequest;
|
||||||
|
|
||||||
|
[StdCall, CLink]
|
||||||
|
static extern void* HTTP_GetFile(char8* url, char8* destPath);
|
||||||
|
|
||||||
|
[StdCall, CLink]
|
||||||
|
static extern int32 HTTP_GetResult(void* netRequest, int32 waitMS);
|
||||||
|
|
||||||
|
[StdCall, CLink]
|
||||||
|
static extern void HTTP_Delete(void* netRequest);
|
||||||
|
|
||||||
|
public ~this()
|
||||||
|
{
|
||||||
|
if (mNativeNetRequest != null)
|
||||||
|
HTTP_Delete(mNativeNetRequest);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void GetFile(StringView url, StringView destPath)
|
||||||
|
{
|
||||||
|
mNativeNetRequest = HTTP_GetFile(url.ToScopeCStr!(), destPath.ToScopeCStr!());
|
||||||
|
}
|
||||||
|
|
||||||
|
public HTTPResult GetResult()
|
||||||
|
{
|
||||||
|
return (HTTPResult)HTTP_GetResult(mNativeNetRequest, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -1616,6 +1616,42 @@ BF_EXPORT const char* BF_CALLTYPE Debugger_GetHotResolveData(uint8* outTypeData,
|
||||||
return outString.c_str();
|
return outString.c_str();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BF_EXPORT NetResult* HTTP_GetFile(char* url, char* destPath)
|
||||||
|
{
|
||||||
|
AutoCrit autoCrit(gDebugManager->mNetManager->mThreadPool.mCritSect);
|
||||||
|
|
||||||
|
auto netResult = gDebugManager->mNetManager->QueueGet(url, destPath);
|
||||||
|
netResult->mDoneEvent = new SyncEvent();
|
||||||
|
return netResult;
|
||||||
|
}
|
||||||
|
|
||||||
|
BF_EXPORT int HTTP_GetResult(NetResult* netResult, int waitMS)
|
||||||
|
{
|
||||||
|
if (netResult->mDoneEvent->WaitFor(waitMS))
|
||||||
|
{
|
||||||
|
return netResult->mFailed ? 0 : 1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
BF_EXPORT void HTTP_Delete(NetResult* netResult)
|
||||||
|
{
|
||||||
|
if (!netResult->mDoneEvent->WaitFor(0))
|
||||||
|
{
|
||||||
|
///
|
||||||
|
{
|
||||||
|
AutoCrit autoCrit(gDebugManager->mNetManager->mThreadPool.mCritSect);
|
||||||
|
if (netResult->mCurRequest != NULL)
|
||||||
|
netResult->mCurRequest->Cancel();
|
||||||
|
}
|
||||||
|
netResult->mDoneEvent->WaitFor(-1);
|
||||||
|
}
|
||||||
|
delete netResult;
|
||||||
|
}
|
||||||
|
|
||||||
BF_EXPORT void Debugger_SetAliasPath(char* origPath, char* localPath)
|
BF_EXPORT void Debugger_SetAliasPath(char* origPath, char* localPath)
|
||||||
{
|
{
|
||||||
gDebugger->SetAliasPath(origPath, localPath);
|
gDebugger->SetAliasPath(origPath, localPath);
|
||||||
|
|
|
@ -339,25 +339,11 @@ DbgSrcFile* DebugTarget::GetSrcFile(const String& srcFilePath)
|
||||||
return srcFile;
|
return srcFile;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DebugTarget::FindSymbolAt(addr_target addr, String* outSymbol, addr_target* outOffset, DbgModule** outDWARF)
|
bool DebugTarget::FindSymbolAt(addr_target addr, String* outSymbol, addr_target* outOffset, DbgModule** outDWARF, bool allowRemote)
|
||||||
{
|
{
|
||||||
//TODO: First search for symbol, then determine if the addr is within the defining DbgModule
|
//TODO: First search for symbol, then determine if the addr is within the defining DbgModule
|
||||||
|
|
||||||
DbgModule* insideDWARF = NULL;
|
DbgModule* insideDWARF = NULL;
|
||||||
/*for (auto dbgModule : mDbgModules)
|
|
||||||
{
|
|
||||||
for (int i = 0; i < (int)dbgModule->mSections.size(); i++)
|
|
||||||
{
|
|
||||||
auto section = &dbgModule->mSections[i];
|
|
||||||
if ((addr >= section->mAddrStart + dbgModule->mImageBase) && (addr < section->mAddrStart + dbgModule->mImageBase + section->mAddrLength))
|
|
||||||
{
|
|
||||||
insideDWARF = dbgModule;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}*/
|
|
||||||
|
|
||||||
//mDebugger->ReadMemory(addr, )
|
|
||||||
|
|
||||||
|
|
||||||
auto dbgModule = FindDbgModuleForAddress(addr);
|
auto dbgModule = FindDbgModuleForAddress(addr);
|
||||||
if (dbgModule != NULL)
|
if (dbgModule != NULL)
|
||||||
|
@ -385,12 +371,13 @@ bool DebugTarget::FindSymbolAt(addr_target addr, String* outSymbol, addr_target*
|
||||||
{
|
{
|
||||||
if (dbgModule->HasPendingDebugInfo())
|
if (dbgModule->HasPendingDebugInfo())
|
||||||
{
|
{
|
||||||
if ((dbgModule->WantsAutoLoadDebugInfo()) && (!mDebugger->mPendingDebugInfoLoad.Contains(dbgModule)))
|
if (dbgModule->WantsAutoLoadDebugInfo())
|
||||||
{
|
{
|
||||||
mDebugger->mPendingDebugInfoLoad.Add(dbgModule);
|
DbgPendingDebugInfoLoad* dbgPendingDebugInfoLoad = NULL;
|
||||||
|
mDebugger->mPendingDebugInfoLoad.TryAdd(dbgModule, NULL, &dbgPendingDebugInfoLoad);
|
||||||
|
dbgPendingDebugInfoLoad->mModule = dbgModule;
|
||||||
|
dbgPendingDebugInfoLoad->mAllowRemote |= allowRemote;
|
||||||
}
|
}
|
||||||
|
|
||||||
//mDebugger->LoadDebugInfoForModule(dbgModule);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
isInsideSomeSegment = true;
|
isInsideSomeSegment = true;
|
||||||
|
@ -402,9 +389,6 @@ bool DebugTarget::FindSymbolAt(addr_target addr, String* outSymbol, addr_target*
|
||||||
if (!isInsideSomeSegment)
|
if (!isInsideSomeSegment)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
//if ((addr < dwSymbol->mDbgModule->mImageBase) || (addr >= dwSymbol->mDbgModule->mImageBase + dwSymbol->mDbgModule->mImageSize))
|
|
||||||
//return false;
|
|
||||||
|
|
||||||
if (dwSymbol == NULL)
|
if (dwSymbol == NULL)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
|
|
@ -86,7 +86,7 @@ public:
|
||||||
DbgSrcFile* AddSrcFile(const String& srcFilePath);
|
DbgSrcFile* AddSrcFile(const String& srcFilePath);
|
||||||
DbgSrcFile* GetSrcFile(const String& srcFilePath);
|
DbgSrcFile* GetSrcFile(const String& srcFilePath);
|
||||||
|
|
||||||
bool FindSymbolAt(addr_target addr, String* outSymbol, addr_target* outOffset = NULL, DbgModule** outDWARF = NULL);
|
bool FindSymbolAt(addr_target addr, String* outSymbol, addr_target* outOffset = NULL, DbgModule** outDWARF = NULL, bool allowRemote = true);
|
||||||
addr_target FindSymbolAddr(const StringImpl& name);
|
addr_target FindSymbolAddr(const StringImpl& name);
|
||||||
|
|
||||||
addr_target GetStaticAddress(DbgVariable* dwVariable);
|
addr_target GetStaticAddress(DbgVariable* dwVariable);
|
||||||
|
|
|
@ -95,7 +95,7 @@ void NetRequest::Cleanup()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void NetRequest::Perform()
|
void NetRequest::DoTransfer()
|
||||||
{
|
{
|
||||||
if (mCancelling)
|
if (mCancelling)
|
||||||
return;
|
return;
|
||||||
|
@ -193,6 +193,11 @@ void NetRequest::Perform()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void NetRequest::Perform()
|
||||||
|
{
|
||||||
|
DoTransfer();
|
||||||
|
}
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
|
@ -375,6 +380,11 @@ NetRequest::~NetRequest()
|
||||||
{
|
{
|
||||||
mResult->mFailed = mFailed;
|
mResult->mFailed = mFailed;
|
||||||
mResult->mCurRequest = NULL;
|
mResult->mCurRequest = NULL;
|
||||||
|
if (mResult->mDoneEvent != NULL)
|
||||||
|
{
|
||||||
|
mResult->mDoneEvent->Set();
|
||||||
|
BF_ASSERT(!mResult->mRemoved);
|
||||||
|
}
|
||||||
if (mResult->mRemoved)
|
if (mResult->mRemoved)
|
||||||
delete mResult;
|
delete mResult;
|
||||||
}
|
}
|
||||||
|
@ -592,4 +602,3 @@ void NetManager::SetCancelOnSuccess(NetResult* dependentResult, NetResult* cance
|
||||||
dependentResult->mCurRequest->mCancelOnSuccess = cancelOnSucess;
|
dependentResult->mCurRequest->mCancelOnSuccess = cancelOnSucess;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -58,6 +58,8 @@ public:
|
||||||
}
|
}
|
||||||
~NetRequest();
|
~NetRequest();
|
||||||
|
|
||||||
|
void DoTransfer();
|
||||||
|
|
||||||
void Cleanup();
|
void Cleanup();
|
||||||
void Fail(const StringImpl& error);
|
void Fail(const StringImpl& error);
|
||||||
bool Cancel() override;
|
bool Cancel() override;
|
||||||
|
@ -73,12 +75,19 @@ public:
|
||||||
bool mFailed;
|
bool mFailed;
|
||||||
NetRequest* mCurRequest;
|
NetRequest* mCurRequest;
|
||||||
bool mRemoved;
|
bool mRemoved;
|
||||||
|
SyncEvent* mDoneEvent;
|
||||||
|
|
||||||
NetResult()
|
NetResult()
|
||||||
{
|
{
|
||||||
mFailed = false;
|
mFailed = false;
|
||||||
mCurRequest = NULL;
|
mCurRequest = NULL;
|
||||||
mRemoved = false;
|
mRemoved = false;
|
||||||
|
mDoneEvent = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
~NetResult()
|
||||||
|
{
|
||||||
|
delete mDoneEvent;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue