@@ -188,261 +188,36 @@ purposes.
188
188
=== Basic Command Messages
189
189
190
190
These are concerned with the lifetime of the overall git process.
191
-
192
- `void trace2_initialize_clock()`::
193
-
194
- Initialize the Trace2 start clock and nothing else. This should
195
- be called at the very top of main() to capture the process start
196
- time and reduce startup order dependencies.
197
-
198
- `void trace2_initialize()`::
199
-
200
- Determines if any Trace2 Targets should be enabled and
201
- initializes the Trace2 facility. This includes setting up the
202
- Trace2 thread local storage (TLS).
203
- +
204
- This function emits a "version" message containing the version of git
205
- and the Trace2 protocol.
206
- +
207
- This function should be called from `main()` as early as possible in
208
- the life of the process after essential process initialization.
209
-
210
- `int trace2_is_enabled()`::
211
-
212
- Returns 1 if Trace2 is enabled (at least one target is
213
- active).
214
-
215
- `void trace2_cmd_start(int argc, const char **argv)`::
216
-
217
- Emits a "start" message containing the process command line
218
- arguments.
219
-
220
- `int trace2_cmd_exit(int exit_code)`::
221
-
222
- Emits an "exit" message containing the process exit-code and
223
- elapsed time.
224
- +
225
- Returns the exit-code.
226
-
227
- `void trace2_cmd_error(const char *fmt, va_list ap)`::
228
-
229
- Emits an "error" message containing a formatted error message.
230
-
231
- `void trace2_cmd_path(const char *pathname)`::
232
-
233
- Emits a "cmd_path" message with the full pathname of the
234
- current process.
191
+ e.g: `void trace2_initialize_clock()`, `void trace2_initialize()`,
192
+ `int trace2_is_enabled()`, `void trace2_cmd_start(int argc, const char **argv)`.
235
193
236
194
=== Command Detail Messages
237
195
238
196
These are concerned with describing the specific Git command
239
197
after the command line, config, and environment are inspected.
240
-
241
- `void trace2_cmd_name(const char *name)`::
242
-
243
- Emits a "cmd_name" message with the canonical name of the
244
- command, for example "status" or "checkout".
245
-
246
- `void trace2_cmd_mode(const char *mode)`::
247
-
248
- Emits a "cmd_mode" message with a qualifier name to further
249
- describe the current git command.
250
- +
251
- This message is intended to be used with git commands having multiple
252
- major modes. For example, a "checkout" command can checkout a new
253
- branch or it can checkout a single file, so the checkout code could
254
- emit a cmd_mode message of "branch" or "file".
255
-
256
- `void trace2_cmd_alias(const char *alias, const char **argv_expansion)`::
257
-
258
- Emits an "alias" message containing the alias used and the
259
- argument expansion.
260
-
261
- `void trace2_def_param(const char *parameter, const char *value)`::
262
-
263
- Emits a "def_param" message containing a key/value pair.
264
- +
265
- This message is intended to report some global aspect of the current
266
- command, such as a configuration setting or command line switch that
267
- significantly affects program performance or behavior, such as
268
- `core.abbrev`, `status.showUntrackedFiles`, or `--no-ahead-behind`.
269
-
270
- `void trace2_cmd_list_config()`::
271
-
272
- Emits a "def_param" messages for "important" configuration
273
- settings.
274
- +
275
- The environment variable `GIT_TRACE2_CONFIG_PARAMS` or the `trace2.configParams`
276
- config value can be set to a
277
- list of patterns of important configuration settings, for example:
278
- `core.*,remote.*.url`. This function will iterate over all config
279
- settings and emit a "def_param" message for each match.
280
-
281
- `void trace2_cmd_set_config(const char *key, const char *value)`::
282
-
283
- Emits a "def_param" message for a new or updated key/value
284
- pair IF `key` is considered important.
285
- +
286
- This is used to hook into `git_config_set()` and catch any
287
- configuration changes and update a value previously reported by
288
- `trace2_cmd_list_config()`.
289
-
290
- `void trace2_def_repo(struct repository *repo)`::
291
-
292
- Registers a repository with the Trace2 layer. Assigns a
293
- unique "repo-id" to `repo->trace2_repo_id`.
294
- +
295
- Emits a "worktree" messages containing the repo-id and the worktree
296
- pathname.
297
- +
298
- Region and data messages (described later) may refer to this repo-id.
299
- +
300
- The main/top-level repository will have repo-id value 1 (aka "r1").
301
- +
302
- The repo-id field is in anticipation of future in-proc submodule
303
- repositories.
198
+ e.g: `void trace2_cmd_name(const char *name)`,
199
+ `void trace2_cmd_mode(const char *mode)`.
304
200
305
201
=== Child Process Messages
306
202
307
203
These are concerned with the various spawned child processes,
308
204
including shell scripts, git commands, editors, pagers, and hooks.
309
205
310
- `void trace2_child_start(struct child_process *cmd)`::
311
-
312
- Emits a "child_start" message containing the "child-id",
313
- "child-argv", and "child-classification".
314
- +
315
- Before calling this, set `cmd->trace2_child_class` to a name
316
- describing the type of child process, for example "editor".
317
- +
318
- This function assigns a unique "child-id" to `cmd->trace2_child_id`.
319
- This field is used later during the "child_exit" message to associate
320
- it with the "child_start" message.
321
- +
322
- This function should be called before spawning the child process.
323
-
324
- `void trace2_child_exit(struct child_proess *cmd, int child_exit_code)`::
325
-
326
- Emits a "child_exit" message containing the "child-id",
327
- the child's elapsed time and exit-code.
328
- +
329
- The reported elapsed time includes the process creation overhead and
330
- time spend waiting for it to exit, so it may be slightly longer than
331
- the time reported by the child itself.
332
- +
333
- This function should be called after reaping the child process.
334
-
335
- `int trace2_exec(const char *exe, const char **argv)`::
336
-
337
- Emits a "exec" message containing the "exec-id" and the
338
- argv of the new process.
339
- +
340
- This function should be called before calling one of the `exec()`
341
- variants, such as `execvp()`.
342
- +
343
- This function returns a unique "exec-id". This value is used later
344
- if the exec() fails and a "exec-result" message is necessary.
345
-
346
- `void trace2_exec_result(int exec_id, int error_code)`::
347
-
348
- Emits a "exec_result" message containing the "exec-id"
349
- and the error code.
350
- +
351
- On Unix-based systems, `exec()` does not return if successful.
352
- This message is used to indicate that the `exec()` failed and
353
- that the current program is continuing.
206
+ e.g: `void trace2_child_start(struct child_process *cmd)`.
354
207
355
208
=== Git Thread Messages
356
209
357
210
These messages are concerned with Git thread usage.
358
211
359
- `void trace2_thread_start(const char *thread_name)`::
360
-
361
- Emits a "thread_start" message.
362
- +
363
- The `thread_name` field should be a descriptive name, such as the
364
- unique name of the thread-proc. A unique "thread-id" will be added
365
- to the name to uniquely identify thread instances.
366
- +
367
- Region and data messages (described later) may refer to this thread
368
- name.
369
- +
370
- This function must be called by the thread-proc of the new thread
371
- (so that TLS data is properly initialized) and not by the caller
372
- of `pthread_create()`.
373
-
374
- `void trace2_thread_exit()`::
375
-
376
- Emits a "thread_exit" message containing the thread name
377
- and the thread elapsed time.
378
- +
379
- This function must be called by the thread-proc before it returns
380
- (so that the coorect TLS data is used and cleaned up. It should
381
- not be called by the caller of `pthread_join()`.
212
+ e.g: `void trace2_thread_start(const char *thread_name)`.
382
213
383
214
=== Region and Data Messages
384
215
385
216
These are concerned with recording performance data
386
- over regions or spans of code.
387
-
388
- `void trace2_region_enter(const char *category, const char *label, const struct repository *repo)`::
389
-
390
- `void trace2_region_enter_printf(const char *category, const char *label, const struct repository *repo, const char *fmt, ...)`::
391
-
392
- `void trace2_region_enter_printf_va(const char *category, const char *label, const struct repository *repo, const char *fmt, va_list ap)`::
393
-
394
- Emits a thread-relative "region_enter" message with optional
395
- printf string.
396
- +
397
- This function pushes a new region nesting stack level on the current
398
- thread and starts a clock for the new stack frame.
399
- +
400
- The `category` field is an arbitrary category name used to classify
401
- regions by feature area, such as "status" or "index". At this time
402
- it is only just printed along with the rest of the message. It may
403
- be used in the future to filter messages.
404
- +
405
- The `label` field is an arbitrary label used to describe the activity
406
- being started, such as "read_recursive" or "do_read_index".
407
- +
408
- The `repo` field, if set, will be used to get the "repo-id", so that
409
- recursive oerations can be attributed to the correct repository.
410
-
411
- `void trace2_region_leave(const char *category, const char *label, const struct repository *repo)`::
412
-
413
- `void trace2_region_leave_printf(const char *category, const char *label, const struct repository *repo, const char *fmt, ...)`::
414
-
415
- `void trace2_region_leave_printf_va(const char *category, const char *label, const struct repository *repo, const char *fmt, va_list ap)`::
416
-
417
- Emits a thread-relative "region_leave" message with optional
418
- printf string.
419
- +
420
- This function pops the region nesting stack on the current thread
421
- and reports the elapsed time of the stack frame.
422
- +
423
- The `category`, `label`, and `repo` fields are the same as above.
424
- The `category` and `label` do not need to match the correpsonding
425
- "region_enter" message, but it makes the data stream easier to
426
- understand.
427
-
428
- `void trace2_data_string(const char *category, const struct repository *repo, const char *key, const char * value)`::
429
-
430
- `void trace2_data_intmax(const char *category, const struct repository *repo, const char *key, intmax value)`::
431
-
432
- `void trace2_data_json(const char *category, const struct repository *repo, const char *key, const struct json_writer *jw)`::
433
-
434
- Emits a region- and thread-relative "data" or "data_json" message.
435
- +
436
- This is a key/value pair message containing information about the
437
- current thread, region stack, and repository. This could be used
438
- to print the number of files in a directory during a multi-threaded
439
- recursive tree walk.
440
-
441
- `void trace2_printf(const char *fmt, ...)`::
442
-
443
- `void trace2_printf_va(const char *fmt, va_list ap)`::
217
+ over regions or spans of code. e.g:
218
+ `void trace2_region_enter(const char *category, const char *label, const struct repository *repo)`.
444
219
445
- Emits a region- and thread-relative "printf" message .
220
+ Refer to trace2.h for details about all trace2 functions .
446
221
447
222
== Trace2 Target Formats
448
223
0 commit comments