1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319
|
{ TFPDSendFilenameCommand }
procedure TFPDSendFilenameCommand.ComposeJSon(AJsonObject: TJSONObject);
begin
inherited ComposeJSon(AJsonObject);
AJsonObject.Add('command','filename');
AJsonObject.Add('filename',FFileName);
end;
constructor TFPDSendFilenameCommand.create(AFileName: string);
begin
inherited create;
FFileName:=AFileName;
end;
{ TFPDSendRunCommand }
procedure TFPDSendRunCommand.DoOnCommandFailed(ACommandResponse: TJSonObject);
begin
FServerDebugger.DoOnRunFailed;
end;
procedure TFPDSendRunCommand.ComposeJSon(AJsonObject: TJSONObject);
begin
inherited ComposeJSon(AJsonObject);
AJsonObject.Add('command','run');
end;
{ TFPDSendStepOutCommand }
procedure TFPDSendStepOutCommand.ComposeJSon(AJsonObject: TJSONObject);
begin
inherited ComposeJSon(AJsonObject);
AJsonObject.Add('command','stepout');
end;
{ TFPDSendStepOverInstrCommand }
procedure TFPDSendStepOverInstrCommand.ComposeJSon(AJsonObject: TJSONObject);
begin
inherited ComposeJSon(AJsonObject);
AJsonObject.Add('command','stepoverinstr');
end;
{ TFPDSendStepIntoInstrCommand }
procedure TFPDSendStepIntoInstrCommand.ComposeJSon(AJsonObject: TJSONObject);
begin
inherited ComposeJSon(AJsonObject);
AJsonObject.Add('command','stepintoinstr');
end;
{ TFPDSendStepCommand }
procedure TFPDSendStepCommand.ComposeJSon(AJsonObject: TJSONObject);
begin
inherited ComposeJSon(AJsonObject);
AJsonObject.Add('command','step');
end;
{ TFPDSendStopCommand }
procedure TFPDSendStopCommand.ComposeJSon(AJsonObject: TJSONObject);
begin
inherited ComposeJSon(AJsonObject);
AJsonObject.Add('command','stop');
end;
{ TFPDSendNextCommand }
procedure TFPDSendNextCommand.ComposeJSon(AJsonObject: TJSONObject);
begin
inherited ComposeJSon(AJsonObject);
AJsonObject.Add('command','next');
end;
{ TFPDSendDoCurrentCommand }
procedure TFPDSendDoCurrentCommand.ComposeJSon(AJsonObject: TJSONObject);
begin
inherited ComposeJSon(AJsonObject);
AJsonObject.Add('command','getlocationinfo');
end;
procedure TFPDSendDoCurrentCommand.DoOnCommandSuccesfull(ACommandResponse: TJSonObject);
var
LocRecJSon: TJSONObject;
LocRec: TDBGLocationRec;
begin
LocRecJSon := ACommandResponse.Find('locationRec') as TJSONObject;
if assigned(LocRecJSon) then
begin
LocRec.Address:=Hex2Dec(LocRecJSon.Get('address','0'));
LocRec.FuncName:=LocRecJSon.Get('funcName','');
LocRec.SrcFile:=LocRecJSon.Get('srcFile','');
LocRec.SrcFullName:=LocRecJSon.Get('srcFullName','');
LocRec.SrcLine:=LocRecJSon.Get('srcLine',-1);
FServerDebugger.DoOnDoCurrentSuccessfull(LocRec);
end;
end;
{ TFPDSendAddBreakpointCommand }
procedure TFPDSendAddBreakpointCommand.DoOnCommandFailed(ACommandResponse: TJSonObject);
var
ABreakpoint: TFPBreakpoint;
begin
ABreakpoint := TFPBreakpoints(FServerDebugger.BreakPoints).FindByUID(CommandUID);
if assigned(ABreakpoint) then
begin
ABreakpoint.ServerId:=0;
ABreakpoint.SetInvalid;
ABreakpoint.DoChanged;
end;
end;
procedure TFPDSendAddBreakpointCommand.DoOnCommandSuccesfull(ACommandResponse: TJSonObject);
var
ABreakpoint: TFPBreakpoint;
begin
ABreakpoint := TFPBreakpoints(FServerDebugger.BreakPoints).FindByUID(CommandUID);
if assigned(ABreakpoint) then
begin
ABreakpoint.ServerId :=StrToInt(ACommandResponse.get('BreakpointServerIdr','0'));
ABreakpoint.SetValid;
ABreakpoint.DoChanged;
end;
end;
procedure TFPDSendAddBreakpointCommand.ComposeJSon(AJsonObject: TJSONObject);
begin
inherited ComposeJSon(AJsonObject);
AJsonObject.Add('command','addbreakpoint');
if FFileName<>'' then
begin
AJsonObject.Add('filename',FFileName);
AJsonObject.Add('line',FLineNr);
end
else
begin
AJsonObject.Add('location', Dec2Numb(FLocation, 8, 16));
end;
end;
constructor TFPDSendAddBreakpointCommand.create(AFileName: string; ALineNr: integer);
begin
inherited create;
FFileName:=AFileName;
FLineNr:=ALineNr;
end;
constructor TFPDSendAddBreakpointCommand.create(ALocation: TDBGPtr);
begin
inherited create;
FLocation:=ALocation;
end;
{ TFPDSendContinueCommand }
procedure TFPDSendContinueCommand.ComposeJSon(AJsonObject: TJSONObject);
begin
inherited ComposeJSon(AJsonObject);
AJsonObject.Add('command','continue');
end;
procedure TFPDSendContinueCommand.DoOnCommandSuccesfull(ACommandResponse: TJSonObject);
begin
inherited DoOnCommandSuccesfull(ACommandResponse);
FServerDebugger.DoOnContinueSuccessfull;
end;
{ TFPDSendCallStackCommand }
procedure TFPDSendCallStackCommand.DoCallStackFreed(Sender: TObject);
begin
FCallStack:=nil;
end;
procedure TFPDSendCallStackCommand.ComposeJSon(AJsonObject: TJSONObject);
begin
inherited ComposeJSon(AJsonObject);
AJsonObject.Add('command','stacktrace');
end;
constructor TFPDSendCallStackCommand.create(ACallStack: TCallStackBase; ACallStackSupplier: TCallStackSupplier);
begin
inherited create(True);
ACallStack.AddFreeNotification(@DoCallStackFreed);
FCallStack := ACallStack;
FCallStackSupplier := ACallStackSupplier;
end;
destructor TFPDSendCallStackCommand.Destroy;
begin
if assigned(FCallStack) then
FCallStack.RemoveFreeNotification(@DoCallStackFreed);
inherited Destroy;
end;
procedure TFPDSendCallStackCommand.DoOnCommandSuccesfull(ACommandResponse: TJSonObject);
var
JSonCallStackArr: TJSONArray;
JSonCallStackEntryObj: TJSONObject;
e: TCallStackEntry;
It: TMapIterator;
AnAddress: TDBGPtr;
FunctionName: string;
SourceFile: string;
Line: integer;
begin
inherited DoOnCommandSuccesfull(ACommandResponse);
if assigned(FCallStack) then
begin
JSonCallStackArr := ACommandResponse.Get('callstack', TJSONArray(nil));
if assigned(JSonCallStackArr) and (JSonCallStackArr.Count>0) then
begin
FCallStack.Count:=JSonCallStackArr.Count;
FCallStack.SetCountValidity(ddsValid);
It := TMapIterator.Create(FCallstack.RawEntries);
if not It.Locate(FCallstack.LowestUnknown )
then if not It.EOM
then It.Next;
while (not IT.EOM) and (TCallStackEntry(It.DataPtr^).Index < FCallstack.HighestUnknown) do
begin
e := TCallStackEntry(It.DataPtr^);
if e.Validity = ddsRequested then
begin
JSonCallStackEntryObj := JSonCallStackArr.Items[e.Index] as TJSONObject;
AnAddress:=Hex2Dec(JSonCallStackEntryObj.Get('address','0'));
FunctionName:=JSonCallStackEntryObj.Get('functionname','');
SourceFile:=JSonCallStackEntryObj.Get('sourcefile','');
Line:=JSonCallStackEntryObj.get('line',-1);
e.Init(AnAddress, nil, FunctionName, SourceFile, '', Line, ddsValid);
end;
It.Next;
end;
It.Free;
FCallStack.SetCountValidity(ddsValid);
TFPCallStackSupplier(FCallStackSupplier).DoUpdate;
end
else
begin
FCallStack.SetCountValidity(ddsInvalid);
FCallStack.SetHasAtLeastCountInfo(ddsInvalid);
end;
end;
end;
{ TFPDSendDisassembleCommand }
procedure TFPDSendDisassembleCommand.ComposeJSon(AJsonObject: TJSONObject);
begin
inherited ComposeJSon(AJsonObject);
AJsonObject.Add('command','disassemble');
if FStartAddr>0 then
AJsonObject.Add('address', Dec2Numb(FStartAddr, 8, 16));
if FLinesAfter>0 then
AJsonObject.Add('linesafter', FLinesAfter);
if FLinesBefore>0 then
AJsonObject.Add('linesbefore', FLinesBefore);
end;
constructor TFPDSendDisassembleCommand.create(ADisassembler: TDBGDisassembler; AStartAddr: TDBGPtr; ALinesBefore, ALinesAfter: integer);
begin
inherited create(true);
FDisassembler := ADisassembler;
FLinesBefore:=ALinesBefore;
FLinesAfter:=ALinesAfter;
FStartAddr:=AStartAddr;
end;
procedure TFPDSendDisassembleCommand.DoOnCommandSuccesfull(ACommandResponse: TJSonObject);
var
JSonCallStackArr: TJSONArray;
JSonCallStackEntryObj: TJSONObject;
ARange: TDBGDisassemblerEntryRange;
AnEntry: TDisassemblerEntry;
i: Integer;
begin
if assigned(FDisassembler) then
begin
JSonCallStackArr := ACommandResponse.Get('disassembly', TJSONArray(nil));
if assigned(JSonCallStackArr) and (JSonCallStackArr.Count>0) then
begin
ARange := TDBGDisassemblerEntryRange.Create;
ARange.RangeStartAddr:=Hex2Dec(ACommandResponse.Get('startaddress', Dec2Numb(FStartAddr, 8, 16)));
for i := 0 to JSonCallStackArr.Count-1 do
begin
JSonCallStackEntryObj := JSonCallStackArr.Items[i] as TJSONObject;
AnEntry.Addr:=Hex2Dec(JSonCallStackEntryObj.Get('address', '0'));
AnEntry.Dump:=JSonCallStackEntryObj.Get('dump', '');
AnEntry.Statement:=JSonCallStackEntryObj.Get('statement', '');
AnEntry.SrcFileName:=JSonCallStackEntryObj.Get('srcfilename', '');
AnEntry.SrcFileLine:=JSonCallStackEntryObj.Get('srcfileline', 0);
AnEntry.SrcStatementIndex:=JSonCallStackEntryObj.Get('srcstatementindex', 0);
AnEntry.SrcStatementCount:=JSonCallStackEntryObj.Get('srcstatementcount', 0);
AnEntry.FuncName:=JSonCallStackEntryObj.Get('functionname', '');
AnEntry.Offset:=JSonCallStackEntryObj.Get('offset', 0);
ARange.Append(@AnEntry);
end;
ARange.RangeEndAddr:=Hex2Dec(ACommandResponse.Get('endaddress', Dec2Numb(AnEntry.Addr, 8, 16)));
ARange.LastEntryEndAddr:=Hex2Dec(ACommandResponse.Get('lastentryendaddress', '0'));
TFPDBGDisassembler(FDisassembler).AddRange(ARange);
end
end;
end;
procedure TFPDSendCallStackCommand.DoOnCommandFailed(ACommandResponse: TJSonObject);
begin
FCallStack.SetCountValidity(ddsInvalid);
end;
|