From 2ccb6663acd958d2728399b47a0febf36013bd4c Mon Sep 17 00:00:00 2001 From: marc Date: Fri, 18 Dec 2009 23:28:58 +0000 Subject: [PATCH] * Debugger: Fix PID detection on OSX 10.6. Fixes #0014588 git-svn-id: trunk@23192 - --- debugger/gdbmidebugger.pp | 40 ++++++++++++++++++++++++++++++++++++--- 1 file changed, 37 insertions(+), 3 deletions(-) diff --git a/debugger/gdbmidebugger.pp b/debugger/gdbmidebugger.pp index 1b745589c0..bc480c9b93 100644 --- a/debugger/gdbmidebugger.pp +++ b/debugger/gdbmidebugger.pp @@ -3079,6 +3079,31 @@ begin end; procedure TGDBMIDebugger.Init; + function ParseGDBVersionMI: Boolean; + var + R: TGDBMIExecResult; + S: String; + List: TGDBMINameValueList; + begin + if not ExecuteCommand('-gdb-version', [], [], R) + then Exit(False); + + if R.Values = '' then Exit(False); + + List := TGDBMINameValueList.Create(R); + + FGDBVersion := List.Values['version']; + S := List.Values['target']; + + FGDBCPU := GetPart('', '-', S); + GetPart('-', '-', S); // strip vendor + FGDBOS := GetPart(['-'], ['-', ''], S); + + List.Free; + + Result := FGDBVersion <> ''; + end; + procedure ParseGDBVersion; var R: TGDBMIExecResult; @@ -3141,7 +3166,7 @@ begin // ignore the error on other platforms ExecuteCommand('-gdb-set new-console off', [cfIgnoreError]); - ParseGDBVersion; + if not ParseGDBVersionMI then ParseGDBVersion; CheckGDBVersion; inherited Init; @@ -4094,8 +4119,7 @@ begin and ExecuteCommand('-exec-run', [], R) then begin // some versions of gdb (OSX) output the PID here - TargetPIDPart := GetPart(['process '], - [' local'], R.Values, True); + TargetPIDPart := GetPart(['process '], [' local', ']'], R.Values, True); FTargetPID := StrToIntDef(TargetPIDPart, 0); R.State := dsNone; end; @@ -4109,6 +4133,16 @@ begin FTargetPID := StrToIntDef(TargetPIDPart, 0); end; + // apple + if (FTargetPID = 0) + and ExecuteCommand('info pid', [], [cfIgnoreError], R) + and (R.State <> dsError) + then begin + List := TGDBMINameValueList.Create(R); + FTargetPID := StrToIntDef(List.Values['process-id'], 0); + List.Free; + end; + if FTargetPID = 0 then begin Result := False;