]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - packages/Python/lldbsuite/test/functionalities/darwin_log/filter/exact_match/activity-chain/main.c
Vendor import of lldb trunk r290819:
[FreeBSD/FreeBSD.git] / packages / Python / lldbsuite / test / functionalities / darwin_log / filter / exact_match / activity-chain / main.c
1 //===-- main.c --------------------------------------------------*- C++ -*-===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9
10 #include <os/activity.h>
11 #include <os/log.h>
12 #include <stdio.h>
13
14 #include "../../../common/darwin_log_common.h"
15
16 int main(int argc, char** argv)
17 {
18     os_log_t logger_sub1 = os_log_create("org.llvm.lldb.test.sub1", "cat1");
19     os_log_t logger_sub2 = os_log_create("org.llvm.lldb.test.sub2", "cat2");
20     if (!logger_sub1 || !logger_sub2)
21         return 1;
22
23     // Note we cannot use the os_log() line as the breakpoint because, as of
24     // the initial writing of this test, we get multiple breakpoints for that
25     // line, which confuses the pexpect test logic.
26     printf("About to log\n"); // break here
27     os_activity_t parent_activity = os_activity_create("parent-activity",
28         OS_ACTIVITY_CURRENT, OS_ACTIVITY_FLAG_DEFAULT);
29     os_activity_apply(parent_activity, ^{
30         os_log(logger_sub1, "source-log-sub1-cat1");
31         os_activity_t child_activity = os_activity_create("child-activity",
32             OS_ACTIVITY_CURRENT, OS_ACTIVITY_FLAG_DEFAULT);
33         os_activity_apply(child_activity, ^{
34             os_log(logger_sub2, "source-log-sub2-cat2");
35             });
36         });
37
38     // Sleep, as the darwin log reporting doesn't always happen until a bit
39     // later.  We need the message to come out before the process terminates.
40     sleep(FINAL_WAIT_SECONDS);
41
42     return 0;
43 }