; --------------------------------------------------------------------------------------------; Copyright (c) Fantaisie Software. All rights reserved.; Dual licensed under the GPL and Fantaisie Software licenses.; See LICENSE and LICENSE-FANTAISIE in the project root for license information.; --------------------------------------------------------------------------------------------; keep track of running standalone debuggers in order to update things like; watchlist when they update;Structure Standalone_DebuggersCompileTargetID.i; unique id of the compiletarget used for compilationCommFile$ ; the random filename used for communicationCommandLine$ ; settings used for RunProgramParameters$Directory$WaitStatus.l ; set to one after execution endedEndStructureGlobal NewList Standalone_Debuggers.Standalone_Debuggers()DisableDebuggerProcedureDLL StandaloneDebuggers_WaitThread(*Info.Standalone_Debuggers) ; DLL is important in MacOS XRunProgram(*Info\CommandLine,ドル *Info\Parameters,ドル *Info\Directory,ドル #PB_Program_Wait)*Info\WaitStatus = 1EndProcedure; Special one to execute the debugger in elevated mode on vista when; an admin mode tool is debugged...;CompilerIf #CompileWindowsProcedure StandaloneDebuggers_WaitThread_VistaAdmin(*Info.Standalone_Debuggers)info.SHELLEXECUTEINFOinfo\cbSize = SizeOf(SHELLEXECUTEINFO)info\fMask = #SEE_MASK_NOCLOSEPROCESSinfo\hwnd = WindowID(#WINDOW_Main)info\lpVerb = @"runas"info\lpFile = @*Info\CommandLine$info\lpParameters = @*Info\Parameters$info\lpDirectory = @*Info\Directory$info\nShow = #SW_SHOWNORMALIf ShellExecuteEx_(@info) And info\hProcessWaitForSingleObject_(info\hProcess, #INFINITE)CloseHandle_(info\hProcess)EndIf*Info\WaitStatus = 1EndProcedureCompilerEndIfEnableDebugger; This one manages everything there is to do to run the external debugger; it passes watchlist/breakpoints, and also handled the results; parameters are for the gui terminal on linux;Procedure ExecuteStandaloneDebugger(*Target.CompileTarget, DebuggerCMD,ドル Executable,ドル Directory,ドル Parameters$ = ""); generate the file to communicate with the debugger; use a (almost) unique filename to avoid overwriteing another one by a running debugger;CompilerIf #CompileWindowsCommFile$ = TempPath$ + "PureBasic_Debugger" + Str(Random($FFFF)) + ".txt"CompilerElseCommFile$ = TempPath$ + ".pb-DEBUGGER-" + Str(Random($FFFF)) + ".txt"CompilerEndIf; The OSX "open" command cuts the commandline parameters, so we; use a fixed filename for this case. Ugly, but works;CompilerIf #CompileMacIf DebuggerCMD$ = "open"CommFile$ = "/tmp/.pbstandalone.out"If OSVersion() > #PB_OS_MacOSX_10_5Parameters$ + " --args " ; needed to pass arg to the opened app to "open" commandline tool (only available on OS X 10.6+)EndIfEndIfCompilerEndIf; Register the command file for auto deletion on IDE end; (Deleting it when the program ends is too soon for Linux, with console mode; as the terminal starter seems to quit before the exe is loaded!);RegisterDeleteFile(CommFile$)If CreateFile(#FILE_StandaloneDebugger, CommFile$);; Important: the command file is utf-8!;; write the general stuff;WriteStringN(#FILE_StandaloneDebugger, "EXEFILE "+Executable,ドル #PB_UTF8)WriteStringN(#FILE_StandaloneDebugger, "COMMANDLINE "+*Target\CommandLine,ドル #PB_UTF8)WriteStringN(#FILE_StandaloneDebugger, "PREFERENCES "+PreferencesFile,ドル #PB_UTF8); Write warning mode;If *Target\CustomWarningMode = *Target\WarningModeElseMode = WarningMode ; global settingEndIfSelect ModeCase 0: WriteStringN(#FILE_StandaloneDebugger, "WARNINGS IGNORE", #PB_UTF8)Case 1: WriteStringN(#FILE_StandaloneDebugger, "WARNINGS DISPLAY", #PB_UTF8)Case 2: WriteStringN(#FILE_StandaloneDebugger, "WARNINGS ERROR", #PB_UTF8)EndSelectIf *Target\EnablePurifier And *Target\PurifierGranularity$WriteStringN(#FILE_StandaloneDebugger, "PURIFIER "+*Target\PurifierGranularity,ドル #PB_UTF8)EndIf; we no longer get the CompileFile passed here!If *Target\UseMainFileWriteStringN(#FILE_StandaloneDebugger, "SOURCEFILE "+ResolveRelativePath(GetPathPart(*Target\FileName$), *Target\MainFile$), #PB_UTF8)ElseIf *Target\FileName$ <> ""WriteStringN(#FILE_StandaloneDebugger, "SOURCEFILE "+*Target\FileName,ドル #PB_UTF8)ElseCompilerIf #CompileMacWriteStringN(#FILE_StandaloneDebugger, "SOURCEFILE "+"/tmp/PB_EditorOutput.pb", #PB_UTF8)CompilerElseWriteStringN(#FILE_StandaloneDebugger, "SOURCEFILE "+Language("FileStuff", "NewSource"), #PB_UTF8)CompilerEndIfEndIfEndIf; write the watchlist;index = 1While StringField(*Target\Watchlist,ドル index, ";") <> ""WriteStringN(#FILE_StandaloneDebugger, "WATCH "+StringField(*Target\Watchlist,ドル index, ";"), #PB_UTF8)index + 1Wend; just write breakpoints of any open file, those that are not compiled; with this source will be ignored;ForEach FileList()If @FileList() <> *ProjectInfoLine = -1RepeatLine = GetBreakPoint(@FileList(), Line+1)If Line <> -1If @FileList() = *Target ; this is the main source, include no filenameWriteStringN(#FILE_StandaloneDebugger, "BREAK "+Str(Line+1), #PB_UTF8)ElseWriteStringN(#FILE_StandaloneDebugger, "BREAK "+Str(Line+1)+","+FileList()\FileName,ドル #PB_UTF8)EndIfEndIfUntil Line = -1EndIfNext FileList()ChangeCurrentElement(FileList(), *ActiveSource)CloseFile(#FILE_StandaloneDebugger)AddElement(Standalone_Debuggers())Standalone_Debuggers()\Directory$ = Directory$Standalone_Debuggers()\WaitStatus = 0Standalone_Debuggers()\CommandLine$ = DebuggerCMD$Standalone_Debuggers()\CommFile$ = CommFile$Standalone_Debuggers()\Parameters$ = Parameters$ + " -o "+Chr(34)+CommFile$+Chr(34)Standalone_Debuggers()\CompileTargetID= *Target\IDDebug "Standalone: "Debug Standalone_Debuggers()\CommandLine$Debug Standalone_Debuggers()\Parameters$Debug Standalone_Debuggers()\Directory$Debug CommFile$; Use a special one for elevated mode of the debugger; when debugging an admin tool on vista;CompilerIf #CompileWindowsIf *Target\RunEnableAdmin And OSVersion() >= #PB_OS_Windows_VistaCreateThread(@StandaloneDebuggers_WaitThread_VistaAdmin(), @Standalone_Debuggers())ProcedureReturnEndIfCompilerEndIfCreateThread(@StandaloneDebuggers_WaitThread(), @Standalone_Debuggers())Else; could not create the file; Note: on linux, with the GUITerminal, this will not work, but this condition should not happen anywayRunProgram(DebuggerCMD,ドル Parameters$ + " " + Executable$ + " " + *Target\CommandLine,ドル Directory$)EndIf; make sure the timer for event processing is runningIf IsDebuggerTimer = 0Debug "[Activate debugger timer]"AddWindowTimer(#WINDOW_Main, #TIMER_DebuggerProcessing, 20) ; check every 20 msIsDebuggerTimer = 1EndIfEndProcedure; checks if a running externaldebugger has quit, and updates; the watchlist that was passed back by it;Procedure StandaloneDebuggers_CheckExits()ForEach Standalone_Debuggers()If Standalone_Debuggers()\WaitStatus ; the debugger has quit!If Standalone_Debuggers()\CommFile$; we only need the watchlist and purifier, but first we must check if the; given target structure is still valid;; the breakpoints are ignored for now,as it might be a little confusing; if they are altered after you quit the debugger;*Target.CompileTarget = FindTargetFromID(Standalone_Debuggers()\CompileTargetID)If *TargetIf ReadFile(#FILE_StandaloneDebugger, Standalone_Debuggers()\CommFile$)*Target\Watchlist$ = ""While Eof(#FILE_StandaloneDebugger) = 0Line$ = ReadString(#FILE_StandaloneDebugger)If Left(Line,ドル 6) = "WATCH "*Target\Watchlist$ + Right(Line,ドル Len(Line$)-6) + ";"ElseIf Left(Line,ドル 9) = "PURIFIER "*Target\PurifierGranularity$ = Right(Line,ドル Len(Line$)-9)EndIfWendIf *Target\Watchlist$ <> ""*Target\Watchlist$ = Left(*Target\Watchlist,ドル Len(*Target\Watchlist$)-1) ; cut the last ";"EndIfCloseFile(#FILE_StandaloneDebugger)EndIfEndIf; Do not delete here. This is too soon on Linux with debugger in a terminal; (these files are deleted on IDE end); DeleteFile(Standalone_Debuggers()\CommFile$)EndIfDeleteElement(Standalone_Debuggers())BreakEndIfNext Standalone_Debuggers()EndProcedureProcedure StandaloneDebuggers_IsRunning()If ListSize(Standalone_Debuggers()) > 0ProcedureReturn 1ElseProcedureReturn 0EndIfEndProcedure
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。