~ubuntu-branches/ubuntu/vivid/lazarus/vivid

« back to all changes in this revision

Viewing changes to debugger/debugutils.pp

  • Committer: Package Import Robot
  • Author(s): Paul Gevers, Abou Al Montacir, Paul Gevers
  • Date: 2013-06-22 13:31:45 UTC
  • mfrom: (1.1.10)
  • Revision ID: package-import@ubuntu.com-20130622133145-kf2awlf322usnrfv
Tags: 1.0.10+dfsg-1
[ Abou Al Montacir ]
* New upstream maintenance release offering many fixes improving the IDE and
  the LCL stability level.
  - The detailed list of changes can be found here:
    http://wiki.lazarus.freepascal.org/Lazarus_1.0_fixes_branch#Fixes_for_1.0.10
* Use compiler configuration file to pass debian custom compiler flags.
* Recover FTBFS on arm machines fix, dropped unintentionally when upgrading
  to 1.0.8. QT4 based LCL WS could not use QTOPIA. (Closes: Bug#712834)
* Update copyright notice to highlight that upstream source where repacked.

[ Paul Gevers ]
* Update Standard to 3.9.4 (no changes needed)
* Remove obsolete DM-Upload-Allowed
* Update lintian overrides
* Add myself to uploaders
* Update Vsc-Browser URL to the browse interface

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
{ $Id: debugutils.pp 36193 2012-03-21 19:13:34Z martin $ }
 
1
{ $Id: debugutils.pp 41301 2013-05-19 16:35:13Z martin $ }
2
2
{                   -------------------------------------------
3
3
                     dbgutils.pp  -  Debugger utility routines
4
4
                    -------------------------------------------
5
5
 
6
6
 @created(Sun Apr 28st WET 2002)
7
 
 @lastmod($Date: 2012-03-21 20:13:34 +0100 (Wed, 21 Mar 2012) $)
 
7
 @lastmod($Date: 2013-05-19 18:35:13 +0200 (So, 19 Mai 2013) $)
8
8
 @author(Marc Weustink <marc@@dommelstein.net>)
9
9
 
10
10
 This unit contains a collection of debugger support routines.
39
39
 
40
40
type
41
41
 
 
42
  TDBGPtr = type QWord;
 
43
 
42
44
  { TDelayedUdateItem }
43
45
 
44
46
  TDelayedUdateItem = class(TCollectionItem)
69
71
function ConvertToCString(const AText: String): String;
70
72
function ConvertPathDelims(const AFileName: String): String;
71
73
function DeleteEscapeChars(const AValue: String; const AEscapeChar: Char = '\'): String;
 
74
function MakePrintable(const AString: String): String; // Make a pascal like string
72
75
function UnEscapeBackslashed(const AValue: String; AFlags: TGdbUnEscapeFlags = [uefOctal]; ATabWidth: Integer = 0): String;
73
76
function UnQuote(const AValue: String): String;
74
77
function Quote(const AValue: String; AForce: Boolean=False): String;
75
78
function ConvertGdbPathAndFile(const AValue: String): String; // fix path, delim, unescape, and to utf8
76
79
function ParseGDBString(const AValue: String): String; // remove quotes(') and convert #dd chars: #9'ab'#9'x'
 
80
function GetLeadingAddr(var AValue: String; out AnAddr: TDBGPtr; ARemoveFromValue: Boolean = False): Boolean;
77
81
 
78
82
procedure SmartWriteln(const s: string);
79
83
 
198
202
      Result[i] := PathDelim;
199
203
end;
200
204
 
 
205
function MakePrintable(const AString: String): String; // Todo: Check invalid utf8
 
206
// Astring should not have quotes
 
207
var
 
208
  n, l, u: Integer;
 
209
  InString: Boolean;
 
210
 
 
211
  procedure ToggleInString;
 
212
  begin
 
213
    InString := not InString;
 
214
    Result := Result + '''';
 
215
  end;
 
216
 
 
217
begin
 
218
  Result := '';
 
219
  InString := False;
 
220
  n := 1;
 
221
  l := Length(AString);
 
222
  while n <= l do
 
223
  //for n := 1 to Length(AString) do
 
224
  begin
 
225
    case AString[n] of
 
226
      ' '..#127: begin
 
227
        if not InString then
 
228
          ToggleInString;
 
229
        Result := Result + AString[n];
 
230
        if AString[n] = '''' then Result := Result + '''';
 
231
      end;
 
232
    #192..#255: begin // Maybe utf8
 
233
        u := UTF8CharacterLength(@AString[n]);
 
234
        if (u > 0) and (n+u-1 <= l) then begin
 
235
          if not InString then
 
236
            ToggleInString;
 
237
          Result := Result + copy(AString, n, u);
 
238
          n := n + u - 1;
 
239
        end
 
240
        else begin
 
241
          if InString then
 
242
            ToggleInString;
 
243
          Result := Result + Format('#%d', [Ord(AString[n])]);
 
244
        end;
 
245
      end;
 
246
    else
 
247
      if InString then
 
248
        ToggleInString;
 
249
      Result := Result + Format('#%d', [Ord(AString[n])]);
 
250
    end;
 
251
    inc(n);
 
252
  end;
 
253
  if InString
 
254
  then Result := Result + '''';
 
255
end;
 
256
 
201
257
function UnEscapeBackslashed(const AValue: String; AFlags: TGdbUnEscapeFlags = [uefOctal]; ATabWidth: Integer = 0): String;
202
258
var
203
259
  c, cnt, len: Integer;
354
410
  SetLength(Result, j);
355
411
end;
356
412
 
 
413
function GetLeadingAddr(var AValue: String; out AnAddr: TDBGPtr;
 
414
  ARemoveFromValue: Boolean): Boolean;
 
415
var
 
416
  i, e: Integer;
 
417
begin
 
418
  AnAddr := 0;
 
419
  Result := (length(AValue) >= 2) and (AValue[1] = '0') and (AValue[2] = 'x');
 
420
 
 
421
  if not Result then exit;
 
422
 
 
423
  i := 2;
 
424
  while (i < length(AValue)) and (AValue[i+1] in ['0'..'9', 'a'..'f', 'A'..'F']) do inc(i);
 
425
  Result := i > 2;
 
426
  if not Result then exit;
 
427
 
 
428
  Val(copy(AValue,1 , i), AnAddr, e);
 
429
  Result := e = 0;
 
430
  if not Result then exit;
 
431
 
 
432
  if ARemoveFromValue then begin
 
433
    if (i < length(AValue)) and (AValue[i+1] in [' ']) then inc(i);
 
434
    delete(AValue, 1, i);
 
435
  end;
 
436
end;
 
437
 
357
438
function DeleteEscapeChars(const AValue: String; const AEscapeChar: Char): String;
358
439
var
359
440
  cnt, len: Integer;