summaryrefslogtreecommitdiff
path: root/fpcdocs/dbugintf.xml
blob: fe1c892ee2bd7de55e9909f7ddc93bdf41ce05cc (plain)
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
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
<?xml version="1.0" encoding="ISO-8859-1"?>
<fpdoc-descriptions>
<package name="fcl">

<!--
  ====================================================================
    dbugintf
  ====================================================================
-->

<module name="dbugintf">
<short>Unit to send commands to a debug server process</short>
<descr>
<p>
Use <file>dbugintf</file> to add debug messages to your application.
The messages are not sent to standard output, but are sent to a debug server
process which collects messages from various clients and displays them
somehow on screen. 
</p>
<p>
The unit is transparant in its use: it does not need initialization, it
will start the debug server by itself if it can find it: the program should
be called <file>debugserver</file> and should be in the <var>PATH</var>.
When the first debug message is sent, the unit will initialize itself.
</p>
<p>
The FCL contains a sample debug server (<file>dbugsvr</file>) which can be
started in advance, and which writes debug message to the console (both on
Windows and Linux). The Lazarus project contains a visual application which
displays the messages in a GUI.
</p>
<p>
The <file>dbugintf</file> unit relies on the <link id="SimpleIPC"/>
mechanism to communicate with the debug server, hence it works on all
platforms that have a functional version of that unit. It also uses
<var>TProcess</var> to start the debug server if needed, so the 
<link id="process"/> unit should also be functional.
</p>
</descr>

<topic name="debugservers">
<short>Writing a debug server</short>
<descr>
<p>
Writing a debug server is relatively easy. It should instantiate a
<var>TSimpleIPCServer</var> class from the <link id="SimpleIPC"/> unit, and
use the <var>DebugServerID</var> as <var>ServerID</var> identification. This
constant, as well as the record containing the message which is sent between 
client  and server is defined in the <file>msgintf</file> unit.
</p>
<p>
The <file>dbugintf</file> unit relies on the <link id="SimpleIPC"/>
mechanism to communicate with the debug server, hence it works on all
platforms that have a functional version of that unit. It also uses
<var>TProcess</var> to start the debug server if needed, so the 
<link id="process"/> unit should also be functional.
</p>
</descr>
</topic>

<!-- enumeration type Visibility: default -->
<element name="TDebugLevel">
<short>Level of the message.</short>
<descr>
<var>TDebugLevel</var> indicates the severity level of the debug 
message to be sent. By default, an informational message is sent. 
</descr>
<seealso>
<link id="SendDebugFmtEx"/>
<link id="SendDebugEx"/>
</seealso>
</element>

<!-- enumeration value Visibility: default -->
<element name="TDebugLevel.dlInformation">
<short>Informational message</short>
</element>

<!-- enumeration value Visibility: default -->
<element name="TDebugLevel.dlWarning">
<short>Warning message</short>
</element>

<!-- enumeration value Visibility: default -->
<element name="TDebugLevel.dlError">
<short>Error message</short>
</element>

<!-- procedure Visibility: default -->
<element name="SendBoolean">
<short>Send the value of a boolean variable</short>
<descr>
<var>SendBoolean</var> is a simple wrapper around <link id="SendDebug"/>
which sends the name and value of a boolean value as an informational
message.
</descr>
<errors>
None.
</errors>
<seealso>
<link id="SendDebug"/>
<link id="SendDateTime"/>
<link id="SendInteger"/>
<link id="SendPointer"/>
</seealso>
</element>

<!-- argument Visibility: default -->
<element name="SendBoolean.Identifier">
<short>Name of the boolean variable</short>
</element>

<!-- argument Visibility: default -->
<element name="SendBoolean.Value">
<short>Value of the boolean variable.</short>
</element>

<!-- procedure Visibility: default -->
<element name="SendDateTime">
<short>Send the value of a <var>TDateTime</var> variable.</short>
<descr>
<var>SendDateTime</var> is a simple wrapper around <link id="SendDebug"/>
which sends the name and value of an integer value as an informational
message. The value is converted to a string using the <link
id="#rtl.sysutils.DateTimeToStr">DateTimeToStr</link> call.
</descr>
<errors>
None.
</errors>
<seealso>
<link id="SendDebug"/>
<link id="SendBoolean"/>
<link id="SendInteger"/>
<link id="SendPointer"/>
</seealso>
</element>

<!-- argument Visibility: default -->
<element name="SendDateTime.Identifier">
<short>Name of the <var>TDateTime</var> variable</short>
</element>

<!-- argument Visibility: default -->
<element name="SendDateTime.Value">
<short>The actual date/time</short>
</element>

<element name="SendInteger">
<short>Send the value of an integer variable.</short>
<descr>
<var>SendInteger</var> is a simple wrapper around <link id="SendDebug"/>
which sends the name and value of an integer value as an informational
message. If <var>HexNotation</var> is <var>True</var>, then the value will be
displayed using hexadecimal notation.
</descr>
<errors>
None.
</errors>
<seealso>
<link id="SendDebug"/>
<link id="SendBoolean"/>
<link id="SendDateTime"/>
<link id="SendPointer"/>
</seealso>
</element>

<!-- argument Visibility: default -->
<element name="SendInteger.Identifier">
<short>Name of the integer variable</short>
</element>

<!-- argument Visibility: default -->
<element name="SendInteger.Value">
<short>The actual value</short>
</element>

<element name="SendInteger.HexNotation">
<short>Format integer using hexadecimal notation</short>
</element>

<element name="SendPointer">
<short>Send the value of a pointer variable.</short>
<descr>
<var>SendInteger</var> is a simple wrapper around <link id="SendDebug"/>
which sends the name and value of a pointer value as an informational
message. The pointer value is displayed using hexadecimal notation.
</descr>
<errors>
None.
</errors>
<seealso>
<link id="SendDebug"/>
<link id="SendBoolean"/>
<link id="SendDateTime"/>
<link id="SendInteger"/>
</seealso>
</element>

<!-- argument Visibility: default -->
<element name="SendPointer.Identifier">
<short>Name of the pointer variable</short>
</element>

<!-- argument Visibility: default -->
<element name="SendPointer.Value">
<short>The actual pointer value</short>
</element>

<!-- procedure Visibility: default -->
<element name="SendDebugEx">
<short>Send debug message other than informational messages</short>
<descr>
<p>
<var>SendDebugEx</var> allows to specify the debug level of the message
to be sent in <var>MType</var>. By default, <link id="SendDebug"/> uses 
informational messages.
</p>
<p>
Other than that the function of <var>SendDebugEx</var> is equal to that of
<var>SendDebug</var>
</p>
</descr>
<errors>
None.
</errors>
<seealso>
<link id="SendDebug"/>
<link id="SendDebugFmt"/>
<link id="SendDebugFmtEx"/>
</seealso>
</element>

<!-- argument Visibility: default -->
<element name="SendDebugEx.Msg">
<short>Message to be sent</short>
</element>

<!-- argument Visibility: default -->
<element name="SendDebugEx.MType">
<short>Debug level of the message to be sent</short>
</element>

<!-- procedure Visibility: default -->
<element name="SendDebug">
<short>Send a message to the debug server.</short>
<descr>
<p>
<var>SendDebug</var> sends the message <var>Msg</var> to the debug server as
an informational message (debug level <var>dlInformation</var>).
If no debug server is running, then an attempt will be made to start the 
server first.
</p>
<p>
The binary that is started is called <file>debugserver</file> and should be somewhere
on the <var>PATH</var>. A sample binary which writes received messages to
standard output is included in the FCL, it is called <file>dbugsrv</file>.
This binary can be renamed to <file>debugserver</file> or can be started
before the program is started.
</p>
</descr>
<errors>
Errors are silently ignored, any exception messages are stored in <link id="SendError"/>.
</errors>
<seealso>
<link id="SendDebugEx"/>
<link id="SendDebugFmt"/>
<link id="SendDebugFmtEx"/>
</seealso>
</element>

<!-- argument Visibility: default -->
<element name="SendDebug.Msg">
<short>The message to be sent to the server.</short>
</element>

<!-- procedure Visibility: default -->
<element name="SendMethodEnter">
<short>Send method enter message</short>
<descr>
<p>
<var>SendMethodEnter</var> sends a "Entering <var>MethodName</var>" message 
to the debug server. After that it increases the message indentation 
(currently 2 characters). By sending a corresponding <link id="SendMethodExit"/>, 
the indentation of messages can be decreased again.
</p>
<p>
By using the <var>SendMethodEnter</var> and <var>SendMethodExit</var>
methods at the beginning and end of a procedure/method, 
it is possible to visually trace program execution.
</p>
</descr>
<errors>
None.
</errors>
<seealso>
<link id="SendDebug"/>
<link id="SendMethodExit"/>
<link id="SendSeparator"/>
</seealso>
</element>

<!-- argument Visibility: default -->
<element name="SendMethodEnter.MethodName">
<short>Name of the entered method</short>
</element>

<!-- procedure Visibility: default -->
<element name="SendMethodExit">
<short>Send method exit message </short>
<descr>
<p>
<var>SendMethodExit</var> sends a "Exiting <var>MethodName</var>" message 
to the debug server. After that it decreases the message indentation 
(currently 2 characters). By sending a corresponding <link
id="SendMethodEnter"/>, the indentation of messages can be increased again.
</p>
<p>
By using the <var>SendMethodEnter</var> and <var>SendMethodExit</var>
methods at the beginning and end of a procedure/method, 
it is possible to visually trace program execution.
</p>
<p>
Note that the indentation level will not be made negative.
</p>
</descr>
<errors>
None.
</errors>
<seealso>
<link id="SendDebug"/>
<link id="SendMethodEnter"/>
<link id="SendSeparator"/>
</seealso>
</element>

<!-- argument Visibility: default -->
<element name="SendMethodExit.MethodName">
<short>Name of the method that is entered</short>
</element>

<!-- procedure Visibility: default -->
<element name="SendSeparator">
<short>Send a separator message</short>
<descr>
<var>SendSeparator</var> is a simple wrapper around <link id="SendDebug"/>
which sends a short horizontal line to the debug server. It can be used to 
visually separate execution of blocks of code or blocks of values.
</descr>
<errors>
None.
</errors>
<seealso>
<link id="SendDebug"/>
<link id="SendMethodEnter"/>
<link id="SendMethodExit"/>
</seealso>
</element>

<!-- procedure Visibility: default -->
<element name="SendDebugFmt">
<short>Format and send a debug message</short>
<descr>
<var>SendDebugFmt</var> is a utility routine which formats a message by
passing <var>Msg</var> and <var>Args</var> to <link
id="#rtl.sysutils.format">Format</link> and sends the result to the debug server
using <link id="SendDebug"/>. It exists mainly to avoid the
<var>Format</var> call in calling code.
</descr>
<errors>
None.
</errors>
<seealso>
<link id="SendDebug"/>
<link id="SendDebugEx"/>
<link id="SendDebugFmtEx"/>
<link id="#rtl.sysutils.format"/>
</seealso>
</element>

<!-- argument Visibility: default -->
<element name="SendDebugFmt.Msg">
<short>Template for message</short>
</element>

<!-- argument Visibility: default -->
<element name="SendDebugFmt.Args">
<short>Arguments to be inserted in template</short>
</element>

<!-- procedure Visibility: default -->
<element name="SendDebugFmtEx">
<short>Format and send message with alternate type</short>
<descr>
<var>SendDebugFmtEx</var> is a utility routine which formats a message by
passing <var>Msg</var> and <var>Args</var> to <link
id="#rtl.sysutils.format">Format</link> and sends the result to the debug server
using <link id="SendDebugEx"/> with Debug level <var>MType</var>. It exists mainly to avoid the
<var>Format</var> call in calling code.
</descr>
<errors>
None.
</errors>
<seealso>
<link id="SendDebug"/>
<link id="SendDebugEx"/>
<link id="SendDebugFmt"/>
<link id="#rtl.sysutils.format"/>
</seealso>
</element>

<!-- argument Visibility: default -->
<element name="SendDebugFmtEx.Msg">
<short>Message template</short>
</element>

<!-- argument Visibility: default -->
<element name="SendDebugFmtEx.Args">
<short>Arguments to insert in template</short>
</element>

<!-- argument Visibility: default -->
<element name="SendDebugFmtEx.MType">
<short>Debug level of message</short>
</element>

<!-- function Visibility: default -->
<element name="StartDebugServer">
<short>Start the debug server</short>
<descr>
<p>
<var>StartDebugServer</var> attempts to start the debug server. The process
started is called <file>debugserver</file> and should be located in the
<var>PATH</var>.
</p>
<p>
Normally this function should not be called. The <link id="SendDebug"/> call
will attempt to start the server by itself if it is not yet running.
</p>
</descr>
<errors>
On error, <var>False</var> is returned.
</errors>
<seealso>
<link id="SendDebug"/>
<link id="InitDebugClient"/>
</seealso>
</element>

<!-- function result Visibility: default -->
<element name="StartDebugServer.Result">
<short>True if started succesfully, false otherwise</short>
</element>

<!-- procedure Visibility: default -->
<element name="InitDebugClient">
<short>Initialize the debug client.</short>
<descr>
<p>
<var>InitDebugClient</var> starts the debug server and then performs all
necessary initialization of the debug IPC communication channel.
</p>
<p>
Normally this function should not be called. The <link id="SendDebug"/> call
will initialize the debug client when it is first called.
</p>
</descr>
<errors>
None.
</errors>
<seealso>
<link id="SendDebug"/>
<link id="StartDebugServer"/>
</seealso>
</element>

<!-- constant Visibility: default -->
<element name="SendError">
<short>Last error in the debug system.</short>
<descr>
Whenever a call encounteres an exception, the exception message is stored in
this variable.
</descr>
</element>

<!-- resource string Visibility: default -->
<element name="SProcessID">
<short>String used when sending identification message to the server.</short>
</element>

<!-- resource string Visibility: default -->
<element name="SEntering">
<short>String used when sending method enter message.</short>
</element>

<!-- resource string Visibility: default -->
<element name="SExiting">
<short>String used when sending method exit message.</short>
</element>

<!-- resource string Visibility: default -->
<element name="SSeparator">
<short>String used when sending a separator line.</short>
</element>

<!-- procedure Visibility: default -->
<element name="SetDebuggingEnabled">
<short>Temporary enables or disables debugging</short>
<descr>
<p>
<var>SetDebuggingEnabled</var> can be used to temporarily enable or disable
sending of debug messages: this allows to control the amount of messages
sent to the debug server without having to remove the <link id="SendDebug"/>
statements. By default, debugging is enabled. If set to false, debug
messages are simply discarded till debugging is enabled again.
</p>
<p>
A value of <var>True</var> enables sending of debug messages. A value of
<var>False</var> disables sending.
</p>
</descr>
<errors>
None.
</errors>
<seealso>
<link id="GetDebuggingEnabled"/>
<link id="SendDebug"/>
</seealso>
</element>

<!-- argument Visibility: default -->
<element name="SetDebuggingEnabled.AValue">
<short>Should sending of debug messages be enabled or not</short>
</element>

<!-- function Visibility: default -->
<element name="GetDebuggingEnabled">
<short>Check if sending of debug messages is enabled.</short>
<descr>
<var>GetDebuggingEnabled</var> returns the value set by the last call to 
<var>SetDebuggingEnabled</var>. It is <var>True</var> by default.
</descr>
<seealso>
<link id="SetDebuggingEnabled"/>
<link id="SendDebug"/>
</seealso>
</element>

<!-- function result Visibility: default -->
<element name="GetDebuggingEnabled.Result">
<short>True if sending debug messages is currently enabled.</short>
</element>

<!-- function result Visibility: default -->
<element name="InitDebugClient.Result">
<short>True if the client was successfully started.</short>
</element>

<element name="SServerStartFailed">
<short>String used to display an error message when the start of the debug server failed</short>
</element>

</module> <!-- dbugintf -->
</package>
</fpdoc-descriptions>