diff --git a/Cargo.lock b/Cargo.lock index c79063463e..d161da8ef2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -63,7 +63,7 @@ version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "819e7219dbd41043ac279b19830f2efc897156490d7fd6ea916720117ee66311" dependencies = [ - "libc 0.2.159", + "libc 0.2.169", ] [[package]] @@ -414,7 +414,7 @@ dependencies = [ "cmake", "dunce", "fs_extra", - "libc 0.2.159", + "libc 0.2.169", "paste", ] @@ -471,7 +471,7 @@ checksum = "8d82cb332cdfaed17ae235a638438ac4d4839913cc2af585c3c6746e8f8bee1a" dependencies = [ "addr2line", "cfg-if", - "libc 0.2.159", + "libc 0.2.169", "miniz_oxide 0.8.0", "object 0.36.5", "rustc-demangle", @@ -595,7 +595,7 @@ checksum = "deb42921128af76c2ced7c723edfb0411695a96d2bfcdda21c3a6543f98b715a" dependencies = [ "cpp_demangle", "gimli", - "libc 0.2.159", + "libc 0.2.169", "memmap2", "miniz_oxide 0.8.0", "rustc-demangle", @@ -867,7 +867,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c2e7962b54006dcfcc61cb72735f4d89bb97061dd6a7ed882ec6b8ee53714c6f" dependencies = [ "jobserver", - "libc 0.2.159", + "libc 0.2.169", "shlex", ] @@ -943,7 +943,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "67523a3b4be3ce1989d607a828d036249522dd9c1c8de7f4dd2dae43a37369d1" dependencies = [ "glob", - "libc 0.2.159", + "libc 0.2.169", "libloading", ] @@ -1069,7 +1069,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "91e195e091a93c46f7102ec7818a2aa394e1e1771c3ab4825963fa03e45afb8f" dependencies = [ "core-foundation-sys", - "libc 0.2.159", + "libc 0.2.169", ] [[package]] @@ -1093,7 +1093,7 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e9e393a7668fe1fad3075085b86c781883000b4ede868f43627b34a87c8b7ded" dependencies = [ - "libc 0.2.159", + "libc 0.2.169", "winapi 0.3.9", ] @@ -1103,7 +1103,7 @@ version = "0.2.12" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "53fe5e26ff1b7aef8bca9c6080520cfb8d9333c7568e1829cef191a9723e5504" dependencies = [ - "libc 0.2.159", + "libc 0.2.169", ] [[package]] @@ -1328,7 +1328,7 @@ version = "10.0.0" source = "git+https://github.com/DataDog/libdatadog?tag=v10.0.0#b62562978bb8788ad2c84ca9390bfc28370d7d40" dependencies = [ "allocator-api2", - "libc 0.2.159", + "libc 0.2.169", "windows-sys 0.52.0", ] @@ -1344,7 +1344,7 @@ dependencies = [ "ddtelemetry", "http 0.2.11", "hyper 0.14.28", - "libc 0.2.159", + "libc 0.2.169", "nix", "os_info", "page_size", @@ -1367,7 +1367,9 @@ dependencies = [ "datadog-crashtracker", "ddcommon 0.0.1", "ddcommon-ffi", + "function_name", "hyper 0.14.28", + "libc 0.2.169", "symbolic-common", "symbolic-demangle", ] @@ -1401,7 +1403,7 @@ dependencies = [ "futures", "glibc_version", "io-lifetimes", - "libc 0.2.159", + "libc 0.2.169", "memfd", "nix", "page_size", @@ -1487,7 +1489,7 @@ dependencies = [ "env_logger 0.11.3", "indexmap 2.2.6", "lazy_static", - "libc 0.2.159", + "libc 0.2.169", "log", "once_cell", "perfcnt", @@ -1520,7 +1522,7 @@ dependencies = [ "hyper 0.14.28", "hyper-multipart-rfc7578", "indexmap 2.2.6", - "libc 0.2.159", + "libc 0.2.169", "lz4_flex", "mime", "mime_guess", @@ -1592,7 +1594,7 @@ dependencies = [ "hyper 0.14.28", "io-lifetimes", "lazy_static", - "libc 0.2.159", + "libc 0.2.169", "manual_future", "memory-stats", "microseh", @@ -1640,7 +1642,7 @@ dependencies = [ "ddtelemetry-ffi", "dogstatsd-client", "hyper 0.14.28", - "libc 0.2.159", + "libc 0.2.169", "paste", "tempfile", ] @@ -1745,7 +1747,7 @@ dependencies = [ "hyper-util", "indexmap 2.2.6", "lazy_static", - "libc 0.2.159", + "libc 0.2.169", "log", "maplit", "pin-project", @@ -1832,7 +1834,7 @@ dependencies = [ "ddcommon 0.0.1", "ddcommon-ffi", "ddtelemetry", - "libc 0.2.159", + "libc 0.2.169", "paste", "tempfile", ] @@ -1946,7 +1948,7 @@ version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "520f05a5cbd335fae5a99ff7a6ab8627577660ee5cfd6a94a6a929b52ff0321c" dependencies = [ - "libc 0.2.159", + "libc 0.2.169", "option-ext", "redox_users", "windows-sys 0.48.0", @@ -1958,7 +1960,7 @@ version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4ebda144c4fe02d1f7ea1a7d9641b6fc6b580adcfa024ae48797ecdeb6825b4d" dependencies = [ - "libc 0.2.159", + "libc 0.2.169", "redox_users", "winapi 0.3.9", ] @@ -2095,7 +2097,7 @@ version = "0.3.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a258e46cdc063eb8519c00b9fc845fc47bcfca4130e2f08e88665ceda8474245" dependencies = [ - "libc 0.2.159", + "libc 0.2.169", "windows-sys 0.52.0", ] @@ -2231,6 +2233,21 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a06f77d526c1a601b7c4cdd98f54b5eaabffc14d5f2f0296febdc7f357c6d3ba" +[[package]] +name = "function_name" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b1ab577a896d09940b5fe12ec5ae71f9d8211fff62c919c03a3750a9901e98a7" +dependencies = [ + "function_name-proc-macro", +] + +[[package]] +name = "function_name-proc-macro" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "673464e1e314dd67a0fd9544abc99e8eb28d0c7e3b69b033bcff9b2d00b87333" + [[package]] name = "futures" version = "0.3.30" @@ -2383,7 +2400,7 @@ checksum = "190092ea657667030ac6a35e305e62fc4dd69fd98ac98631e5d3a2b1575a12b5" dependencies = [ "cfg-if", "js-sys", - "libc 0.2.159", + "libc 0.2.169", "wasi", "wasm-bindgen", ] @@ -2945,7 +2962,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "eae7b9aee968036d54dce06cebaefd919e4472e753296daccd6d344e3e2df0c2" dependencies = [ "hermit-abi", - "libc 0.2.159", + "libc 0.2.169", "windows-sys 0.48.0", ] @@ -2956,7 +2973,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f23ff5ef2b80d608d61efee834934d862cd92461afc0560dedf493e4c033738b" dependencies = [ "hermit-abi", - "libc 0.2.159", + "libc 0.2.169", "windows-sys 0.52.0", ] @@ -2996,7 +3013,7 @@ version = "0.1.31" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d2b099aaa34a9751c5bf0878add70444e1ed2dd73f347be99003d4577277de6e" dependencies = [ - "libc 0.2.159", + "libc 0.2.169", ] [[package]] @@ -3090,9 +3107,9 @@ checksum = "e32a70cf75e5846d53a673923498228bbec6a8624708a9ea5645f075d6276122" [[package]] name = "libc" -version = "0.2.159" +version = "0.2.169" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "561d97a539a36e26a9a5fad1ea11a3039a67714694aaa379433e580854bc3dc5" +checksum = "b5aba8db14291edd000dfcc4d620c7ebfb122c613afb886ca8803fa4e128a20a" [[package]] name = "libloading" @@ -3117,7 +3134,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c0ff37bd590ca25063e35af745c343cb7a0271906fb7b37e4813e8f79f00268d" dependencies = [ "bitflags 2.4.2", - "libc 0.2.159", + "libc 0.2.169", ] [[package]] @@ -3211,7 +3228,7 @@ version = "0.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fe751422e4a8caa417e13c3ea66452215d7d63e19e604f4980461212f3ae1322" dependencies = [ - "libc 0.2.159", + "libc 0.2.169", ] [[package]] @@ -3229,7 +3246,7 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "34f79cf9964c5c9545493acda1263f1912f8d2c56c8a2ffee2606cb960acaacc" dependencies = [ - "libc 0.2.159", + "libc 0.2.169", "winapi 0.3.9", ] @@ -3240,7 +3257,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f26b2a7c5ccfb370edd57fda423f3a551516ee127e10bc22a6215e8c63b20a38" dependencies = [ "cc", - "libc 0.2.159", + "libc 0.2.169", "windows-sys 0.42.0", ] @@ -3291,7 +3308,7 @@ version = "0.8.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8f3d0b296e374a4e6f3c7b0a1f5a51d748a0d34c85e7dc48fc3fa9a87657fe09" dependencies = [ - "libc 0.2.159", + "libc 0.2.169", "wasi", "windows-sys 0.48.0", ] @@ -3341,7 +3358,7 @@ checksum = "2eb04e9c688eff1c89d72b407f168cf79bb9e867a9d3323ed6c01519eb9cc053" dependencies = [ "bitflags 2.4.2", "cfg-if", - "libc 0.2.159", + "libc 0.2.169", "memoffset", ] @@ -3418,7 +3435,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4161fcb6d602d4d2081af7c3a45852d875a03dd337a6bfdd6e06407b61342a43" dependencies = [ "hermit-abi", - "libc 0.2.159", + "libc 0.2.169", ] [[package]] @@ -3542,7 +3559,7 @@ version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "30d5b2194ed13191c1999ae0704b7839fb18384fa22e49b57eeaa97d79ce40da" dependencies = [ - "libc 0.2.159", + "libc 0.2.169", "winapi 0.3.9", ] @@ -3569,7 +3586,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4c42a9226546d68acdd9c0a280d17ce19bfe27a46bf68784e4066115788d008e" dependencies = [ "cfg-if", - "libc 0.2.159", + "libc 0.2.169", "redox_syscall", "smallvec", "windows-targets 0.48.5", @@ -3619,7 +3636,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4ba1fd955270ca6f8bd8624ec0c4ee1a251dd3cc0cc18e1e2665ca8f5acb1501" dependencies = [ "bitflags 1.3.2", - "libc 0.2.159", + "libc 0.2.169", "mmap", "nom 4.2.3", "x86", @@ -3778,7 +3795,7 @@ dependencies = [ "bitflags 1.3.2", "cfg-if", "concurrent-queue", - "libc 0.2.159", + "libc 0.2.169", "log", "pin-project-lite", "windows-sys 0.48.0", @@ -3825,7 +3842,7 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "059a34f111a9dee2ce1ac2826a68b24601c4298cfeb1a587c3cb493d5ab46f52" dependencies = [ - "libc 0.2.159", + "libc 0.1.12", "nix", ] @@ -4084,7 +4101,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "552840b97013b1a26992c11eac34bdd778e464601a4c2054b5f0bff7c6761293" dependencies = [ "fuchsia-cprng", - "libc 0.2.159", + "libc 0.2.169", "rand_core 0.3.1", "rdrand", "winapi 0.3.9", @@ -4096,7 +4113,7 @@ version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" dependencies = [ - "libc 0.2.159", + "libc 0.2.169", "rand_chacha", "rand_core 0.6.4", ] @@ -4292,7 +4309,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3053cf52e236a3ed746dfc745aa9cacf1b791d846bdaf412f60a8d7d6e17c8fc" dependencies = [ "cc", - "libc 0.2.159", + "libc 0.2.169", "once_cell", "spin 0.5.2", "untrusted 0.7.1", @@ -4308,7 +4325,7 @@ checksum = "688c63d65483050968b2a8937f7995f443e27041a0f7700aa59b0822aedebb74" dependencies = [ "cc", "getrandom", - "libc 0.2.159", + "libc 0.2.169", "spin 0.9.8", "untrusted 0.9.0", "windows-sys 0.48.0", @@ -4320,7 +4337,7 @@ version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f8a29d87a652dc4d43c586328706bb5cdff211f3f39a530f240b53f7221dab8e" dependencies = [ - "libc 0.2.159", + "libc 0.2.169", ] [[package]] @@ -4376,7 +4393,7 @@ dependencies = [ "bitflags 1.3.2", "errno", "io-lifetimes", - "libc 0.2.159", + "libc 0.2.169", "linux-raw-sys 0.3.8", "windows-sys 0.48.0", ] @@ -4389,7 +4406,7 @@ checksum = "6ea3e1a662af26cd7a3ba09c0297a31af215563ecf42817c98df621387f4e949" dependencies = [ "bitflags 2.4.2", "errno", - "libc 0.2.159", + "libc 0.2.169", "linux-raw-sys 0.4.13", "windows-sys 0.52.0", ] @@ -4622,7 +4639,7 @@ dependencies = [ "bitflags 1.3.2", "core-foundation", "core-foundation-sys", - "libc 0.2.159", + "libc 0.2.169", "security-framework-sys", ] @@ -4633,7 +4650,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e932934257d3b408ed8f30db49d85ea163bfe74961f017f405b025af298f0c7a" dependencies = [ "core-foundation-sys", - "libc 0.2.159", + "libc 0.2.169", ] [[package]] @@ -4651,7 +4668,7 @@ version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "604b71b8fc267e13bb3023a2c901126c8f349393666a6d98ac1ae5729b701798" dependencies = [ - "libc 0.2.159", + "libc 0.2.169", "tokio", ] @@ -4829,7 +4846,7 @@ version = "1.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d8229b473baa5980ac72ef434c4415e70c4b5e71b423043adb4ba059f89c99a1" dependencies = [ - "libc 0.2.159", + "libc 0.2.169", ] [[package]] @@ -4892,7 +4909,7 @@ version = "0.4.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9f7916fc008ca5542385b89a3d3ce689953c143e9304a9bf8beec1de48994c0d" dependencies = [ - "libc 0.2.159", + "libc 0.2.169", "winapi 0.3.9", ] @@ -4902,7 +4919,7 @@ version = "0.5.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7b5fac59a5cb5dd637972e5fca70daf0523c9067fcdc4842f053dae04a18f8e9" dependencies = [ - "libc 0.2.159", + "libc 0.2.169", "windows-sys 0.48.0", ] @@ -5054,7 +5071,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0b3a0d0aba8bf96a0e1ddfdc352fc53b3df7f39318c71854910c3c4b024ae52c" dependencies = [ "cc", - "libc 0.2.159", + "libc 0.2.169", ] [[package]] @@ -5330,7 +5347,7 @@ checksum = "61285f6515fa018fb2d1e46eb21223fff441ee8db5d0f1435e8ab4f5cdb80931" dependencies = [ "backtrace", "bytes", - "libc 0.2.159", + "libc 0.2.169", "mio", "num_cpus", "parking_lot", diff --git a/components-rs/common.h b/components-rs/common.h index c39e6369f6..9c4c237e46 100644 --- a/components-rs/common.h +++ b/components-rs/common.h @@ -866,16 +866,30 @@ typedef struct ddog_TracerHeaderTags { bool client_computed_stats; } ddog_TracerHeaderTags; +typedef enum ddog_crasht_BuildIdType { + DDOG_CRASHT_BUILD_ID_TYPE_GNU, + DDOG_CRASHT_BUILD_ID_TYPE_GO, + DDOG_CRASHT_BUILD_ID_TYPE_PDB, + DDOG_CRASHT_BUILD_ID_TYPE_PE, + DDOG_CRASHT_BUILD_ID_TYPE_SHA1, +} ddog_crasht_BuildIdType; + typedef enum ddog_crasht_DemangleOptions { DDOG_CRASHT_DEMANGLE_OPTIONS_COMPLETE, DDOG_CRASHT_DEMANGLE_OPTIONS_NAME_ONLY, } ddog_crasht_DemangleOptions; -typedef enum ddog_crasht_NormalizedAddressTypes { - DDOG_CRASHT_NORMALIZED_ADDRESS_TYPES_NONE = 0, - DDOG_CRASHT_NORMALIZED_ADDRESS_TYPES_ELF, - DDOG_CRASHT_NORMALIZED_ADDRESS_TYPES_PDB, -} ddog_crasht_NormalizedAddressTypes; +typedef enum ddog_crasht_ErrorKind { + DDOG_CRASHT_ERROR_KIND_PANIC, + DDOG_CRASHT_ERROR_KIND_UNHANDLED_EXCEPTION, + DDOG_CRASHT_ERROR_KIND_UNIX_SIGNAL, +} ddog_crasht_ErrorKind; + +typedef enum ddog_crasht_FileType { + DDOG_CRASHT_FILE_TYPE_APK, + DDOG_CRASHT_FILE_TYPE_ELF, + DDOG_CRASHT_FILE_TYPE_PDB, +} ddog_crasht_FileType; /** * This enum represents operations a the tracked library might be engaged in. @@ -900,6 +914,40 @@ typedef enum ddog_crasht_OpTypes { DDOG_CRASHT_OP_TYPES_SIZE, } ddog_crasht_OpTypes; +/** + * See https://man7.org/linux/man-pages/man2/sigaction.2.html + */ +typedef enum ddog_crasht_SiCodes { + DDOG_CRASHT_SI_CODES_BUS_ADRALN, + DDOG_CRASHT_SI_CODES_BUS_ADRERR, + DDOG_CRASHT_SI_CODES_BUS_MCEERR_AO, + DDOG_CRASHT_SI_CODES_BUS_MCEERR_AR, + DDOG_CRASHT_SI_CODES_BUS_OBJERR, + DDOG_CRASHT_SI_CODES_SEGV_ACCERR, + DDOG_CRASHT_SI_CODES_SEGV_BNDERR, + DDOG_CRASHT_SI_CODES_SEGV_MAPERR, + DDOG_CRASHT_SI_CODES_SEGV_PKUERR, + DDOG_CRASHT_SI_CODES_SI_ASYNCIO, + DDOG_CRASHT_SI_CODES_SI_KERNEL, + DDOG_CRASHT_SI_CODES_SI_MESGQ, + DDOG_CRASHT_SI_CODES_SI_QUEUE, + DDOG_CRASHT_SI_CODES_SI_SIGIO, + DDOG_CRASHT_SI_CODES_SI_TIMER, + DDOG_CRASHT_SI_CODES_SI_TKILL, + DDOG_CRASHT_SI_CODES_SI_USER, + DDOG_CRASHT_SI_CODES_SYS_SECCOMP, +} ddog_crasht_SiCodes; + +/** + * See https://man7.org/linux/man-pages/man7/signal.7.html + */ +typedef enum ddog_crasht_SignalNames { + DDOG_CRASHT_SIGNAL_NAMES_SIGABRT, + DDOG_CRASHT_SIGNAL_NAMES_SIGBUS, + DDOG_CRASHT_SIGNAL_NAMES_SIGSEGV, + DDOG_CRASHT_SIGNAL_NAMES_SIGSYS, +} ddog_crasht_SignalNames; + /** * Stacktrace collection occurs in the context of a crashing process. * If the stack is sufficiently corruputed, it is possible (but unlikely), @@ -917,17 +965,28 @@ typedef enum ddog_crasht_StacktraceCollection { DDOG_CRASHT_STACKTRACE_COLLECTION_ENABLED_WITH_SYMBOLS_IN_RECEIVER, } ddog_crasht_StacktraceCollection; +typedef struct ddog_crasht_CrashInfo ddog_crasht_CrashInfo; + +typedef struct ddog_crasht_CrashInfoBuilder ddog_crasht_CrashInfoBuilder; + +/** + * All fields are hex encoded integers. + */ +typedef struct ddog_crasht_StackFrame ddog_crasht_StackFrame; + +typedef struct ddog_crasht_StackTrace ddog_crasht_StackTrace; + /** - * A generic result type for when a crashtracking operation may fail, + * A generic result type for when an operation may fail, * but there's nothing to return in the case of success. */ -typedef enum ddog_crasht_Result_Tag { - DDOG_CRASHT_RESULT_OK, - DDOG_CRASHT_RESULT_ERR, -} ddog_crasht_Result_Tag; +typedef enum ddog_VoidResult_Tag { + DDOG_VOID_RESULT_OK, + DDOG_VOID_RESULT_ERR, +} ddog_VoidResult_Tag; -typedef struct ddog_crasht_Result { - ddog_crasht_Result_Tag tag; +typedef struct ddog_VoidResult { + ddog_VoidResult_Tag tag; union { struct { /** @@ -940,7 +999,7 @@ typedef struct ddog_crasht_Result { struct ddog_Error err; }; }; -} ddog_crasht_Result; +} ddog_VoidResult; typedef struct ddog_crasht_Slice_CharSlice { /** @@ -1021,13 +1080,17 @@ typedef struct ddog_crasht_Metadata { const struct ddog_Vec_Tag *tags; } ddog_crasht_Metadata; -typedef enum ddog_crasht_UsizeResult_Tag { - DDOG_CRASHT_USIZE_RESULT_OK, - DDOG_CRASHT_USIZE_RESULT_ERR, -} ddog_crasht_UsizeResult_Tag; +/** + * A generic result type for when an operation may fail, + * or may return in case of success. + */ +typedef enum ddog_crasht_Result_Usize_Tag { + DDOG_CRASHT_RESULT_USIZE_OK_USIZE, + DDOG_CRASHT_RESULT_USIZE_ERR_USIZE, +} ddog_crasht_Result_Usize_Tag; -typedef struct ddog_crasht_UsizeResult { - ddog_crasht_UsizeResult_Tag tag; +typedef struct ddog_crasht_Result_Usize { + ddog_crasht_Result_Usize_Tag tag; union { struct { uintptr_t ok; @@ -1036,112 +1099,104 @@ typedef struct ddog_crasht_UsizeResult { struct ddog_Error err; }; }; -} ddog_crasht_UsizeResult; +} ddog_crasht_Result_Usize; /** - * Represents a CrashInfo. Do not access its member for any reason, only use - * the C API functions on this struct. + * Represents an object that should only be referred to by its handle. + * Do not access its member for any reason, only use the C API functions on this struct. */ -typedef struct ddog_crasht_CrashInfo { +typedef struct ddog_crasht_Handle_CrashInfo { struct ddog_crasht_CrashInfo *inner; -} ddog_crasht_CrashInfo; +} ddog_crasht_Handle_CrashInfo; /** - * Returned by [ddog_prof_Profile_new]. + * Represents an object that should only be referred to by its handle. + * Do not access its member for any reason, only use the C API functions on this struct. */ -typedef enum ddog_crasht_CrashInfoNewResult_Tag { - DDOG_CRASHT_CRASH_INFO_NEW_RESULT_OK, - DDOG_CRASHT_CRASH_INFO_NEW_RESULT_ERR, -} ddog_crasht_CrashInfoNewResult_Tag; +typedef struct ddog_crasht_Handle_CrashInfoBuilder { + struct ddog_crasht_CrashInfoBuilder *inner; +} ddog_crasht_Handle_CrashInfoBuilder; -typedef struct ddog_crasht_CrashInfoNewResult { - ddog_crasht_CrashInfoNewResult_Tag tag; +/** + * A generic result type for when an operation may fail, + * or may return in case of success. + */ +typedef enum ddog_crasht_Result_HandleCrashInfoBuilder_Tag { + DDOG_CRASHT_RESULT_HANDLE_CRASH_INFO_BUILDER_OK_HANDLE_CRASH_INFO_BUILDER, + DDOG_CRASHT_RESULT_HANDLE_CRASH_INFO_BUILDER_ERR_HANDLE_CRASH_INFO_BUILDER, +} ddog_crasht_Result_HandleCrashInfoBuilder_Tag; + +typedef struct ddog_crasht_Result_HandleCrashInfoBuilder { + ddog_crasht_Result_HandleCrashInfoBuilder_Tag tag; union { struct { - struct ddog_crasht_CrashInfo ok; + struct ddog_crasht_Handle_CrashInfoBuilder ok; }; struct { struct ddog_Error err; }; }; -} ddog_crasht_CrashInfoNewResult; +} ddog_crasht_Result_HandleCrashInfoBuilder; -typedef struct ddog_crasht_SigInfo { - uint64_t signum; - ddog_CharSlice signame; -} ddog_crasht_SigInfo; +/** + * A generic result type for when an operation may fail, + * or may return in case of success. + */ +typedef enum ddog_crasht_Result_HandleCrashInfo_Tag { + DDOG_CRASHT_RESULT_HANDLE_CRASH_INFO_OK_HANDLE_CRASH_INFO, + DDOG_CRASHT_RESULT_HANDLE_CRASH_INFO_ERR_HANDLE_CRASH_INFO, +} ddog_crasht_Result_HandleCrashInfo_Tag; -typedef struct ddog_crasht_StackFrameNames { - struct ddog_Option_U32 colno; - ddog_CharSlice filename; - struct ddog_Option_U32 lineno; - ddog_CharSlice name; -} ddog_crasht_StackFrameNames; +typedef struct ddog_crasht_Result_HandleCrashInfo { + ddog_crasht_Result_HandleCrashInfo_Tag tag; + union { + struct { + struct ddog_crasht_Handle_CrashInfo ok; + }; + struct { + struct ddog_Error err; + }; + }; +} ddog_crasht_Result_HandleCrashInfo; -typedef struct ddog_crasht_Slice_StackFrameNames { - /** - * Should be non-null and suitably aligned for the underlying type. It is - * allowed but not recommended for the pointer to be null when the len is - * zero. - */ - const struct ddog_crasht_StackFrameNames *ptr; - /** - * The number of elements (not bytes) that `.ptr` points to. Must be less - * than or equal to [isize::MAX]. - */ - uintptr_t len; -} ddog_crasht_Slice_StackFrameNames; +typedef struct ddog_crasht_OsInfo { + ddog_CharSlice architecture; + ddog_CharSlice bitness; + ddog_CharSlice os_type; + ddog_CharSlice version; +} ddog_crasht_OsInfo; -typedef struct ddog_Slice_U8 { - /** - * Should be non-null and suitably aligned for the underlying type. It is - * allowed but not recommended for the pointer to be null when the len is - * zero. - */ - const uint8_t *ptr; - /** - * The number of elements (not bytes) that `.ptr` points to. Must be less - * than or equal to [isize::MAX]. - */ - uintptr_t len; -} ddog_Slice_U8; +typedef struct ddog_crasht_ProcInfo { + uint32_t pid; +} ddog_crasht_ProcInfo; + +typedef struct ddog_crasht_SigInfo { + ddog_CharSlice addr; + int code; + enum ddog_crasht_SiCodes code_human_readable; + int signo; + enum ddog_crasht_SignalNames signo_human_readable; +} ddog_crasht_SigInfo; + +typedef struct ddog_crasht_Span { + ddog_CharSlice id; + ddog_CharSlice thread_name; +} ddog_crasht_Span; /** - * Use to represent bytes -- does not need to be valid UTF-8. + * Represents an object that should only be referred to by its handle. + * Do not access its member for any reason, only use the C API functions on this struct. */ -typedef struct ddog_Slice_U8 ddog_ByteSlice; - -typedef struct ddog_crasht_NormalizedAddress { - uint64_t file_offset; - ddog_ByteSlice build_id; - uint64_t age; - ddog_CharSlice path; - enum ddog_crasht_NormalizedAddressTypes typ; -} ddog_crasht_NormalizedAddress; - -typedef struct ddog_crasht_StackFrame { - ddog_CharSlice build_id; - uintptr_t ip; - uintptr_t module_base_address; - struct ddog_crasht_Slice_StackFrameNames names; - struct ddog_crasht_NormalizedAddress normalized_ip; - uintptr_t sp; - uintptr_t symbol_address; -} ddog_crasht_StackFrame; - -typedef struct ddog_crasht_Slice_StackFrame { - /** - * Should be non-null and suitably aligned for the underlying type. It is - * allowed but not recommended for the pointer to be null when the len is - * zero. - */ - const struct ddog_crasht_StackFrame *ptr; - /** - * The number of elements (not bytes) that `.ptr` points to. Must be less - * than or equal to [isize::MAX]. - */ - uintptr_t len; -} ddog_crasht_Slice_StackFrame; +typedef struct ddog_crasht_Handle_StackTrace { + struct ddog_crasht_StackTrace *inner; +} ddog_crasht_Handle_StackTrace; + +typedef struct ddog_crasht_ThreadData { + bool crashed; + ddog_CharSlice name; + struct ddog_crasht_Handle_StackTrace stack; + ddog_CharSlice state; +} ddog_crasht_ThreadData; /** * Represents time since the Unix Epoch in seconds plus nanoseconds. @@ -1151,9 +1206,55 @@ typedef struct ddog_Timespec { uint32_t nanoseconds; } ddog_Timespec; -typedef struct ddog_crasht_ProcInfo { - uint32_t pid; -} ddog_crasht_ProcInfo; +/** + * Represents an object that should only be referred to by its handle. + * Do not access its member for any reason, only use the C API functions on this struct. + */ +typedef struct ddog_crasht_Handle_StackFrame { + struct ddog_crasht_StackFrame *inner; +} ddog_crasht_Handle_StackFrame; + +/** + * A generic result type for when an operation may fail, + * or may return in case of success. + */ +typedef enum ddog_crasht_Result_HandleStackFrame_Tag { + DDOG_CRASHT_RESULT_HANDLE_STACK_FRAME_OK_HANDLE_STACK_FRAME, + DDOG_CRASHT_RESULT_HANDLE_STACK_FRAME_ERR_HANDLE_STACK_FRAME, +} ddog_crasht_Result_HandleStackFrame_Tag; + +typedef struct ddog_crasht_Result_HandleStackFrame { + ddog_crasht_Result_HandleStackFrame_Tag tag; + union { + struct { + struct ddog_crasht_Handle_StackFrame ok; + }; + struct { + struct ddog_Error err; + }; + }; +} ddog_crasht_Result_HandleStackFrame; + +/** + * A generic result type for when an operation may fail, + * or may return in case of success. + */ +typedef enum ddog_crasht_Result_HandleStackTrace_Tag { + DDOG_CRASHT_RESULT_HANDLE_STACK_TRACE_OK_HANDLE_STACK_TRACE, + DDOG_CRASHT_RESULT_HANDLE_STACK_TRACE_ERR_HANDLE_STACK_TRACE, +} ddog_crasht_Result_HandleStackTrace_Tag; + +typedef struct ddog_crasht_Result_HandleStackTrace { + ddog_crasht_Result_HandleStackTrace_Tag tag; + union { + struct { + struct ddog_crasht_Handle_StackTrace ok; + }; + struct { + struct ddog_Error err; + }; + }; +} ddog_crasht_Result_HandleStackTrace; /** * A wrapper for returning owned strings from FFI @@ -1165,13 +1266,17 @@ typedef struct ddog_crasht_StringWrapper { struct ddog_Vec_U8 message; } ddog_crasht_StringWrapper; -typedef enum ddog_crasht_StringWrapperResult_Tag { - DDOG_CRASHT_STRING_WRAPPER_RESULT_OK, - DDOG_CRASHT_STRING_WRAPPER_RESULT_ERR, -} ddog_crasht_StringWrapperResult_Tag; +/** + * A generic result type for when an operation may fail, + * or may return in case of success. + */ +typedef enum ddog_crasht_Result_StringWrapper_Tag { + DDOG_CRASHT_RESULT_STRING_WRAPPER_OK_STRING_WRAPPER, + DDOG_CRASHT_RESULT_STRING_WRAPPER_ERR_STRING_WRAPPER, +} ddog_crasht_Result_StringWrapper_Tag; -typedef struct ddog_crasht_StringWrapperResult { - ddog_crasht_StringWrapperResult_Tag tag; +typedef struct ddog_crasht_Result_StringWrapper { + ddog_crasht_Result_StringWrapper_Tag tag; union { struct { struct ddog_crasht_StringWrapper ok; @@ -1180,7 +1285,7 @@ typedef struct ddog_crasht_StringWrapperResult { struct ddog_Error err; }; }; -} ddog_crasht_StringWrapperResult; +} ddog_crasht_Result_StringWrapper; #ifdef __cplusplus extern "C" { diff --git a/components-rs/crashtracker.h b/components-rs/crashtracker.h index 11bcb7602c..f2682769b6 100644 --- a/components-rs/crashtracker.h +++ b/components-rs/crashtracker.h @@ -33,7 +33,7 @@ extern "C" { * This function is not atomic. A crash during its execution may lead to * unexpected crash-handling behaviour. */ -DDOG_CHECK_RETURN struct ddog_crasht_Result ddog_crasht_shutdown(void); +DDOG_CHECK_RETURN struct ddog_VoidResult ddog_crasht_shutdown(void); /** * Reinitialize the crash-tracking infrastructure after a fork. @@ -55,9 +55,9 @@ DDOG_CHECK_RETURN struct ddog_crasht_Result ddog_crasht_shutdown(void); * unexpected crash-handling behaviour. */ DDOG_CHECK_RETURN -struct ddog_crasht_Result ddog_crasht_update_on_fork(struct ddog_crasht_Config config, - struct ddog_crasht_ReceiverConfig receiver_config, - struct ddog_crasht_Metadata metadata); +struct ddog_VoidResult ddog_crasht_update_on_fork(struct ddog_crasht_Config config, + struct ddog_crasht_ReceiverConfig receiver_config, + struct ddog_crasht_Metadata metadata); /** * Initialize the crash-tracking infrastructure. @@ -72,9 +72,9 @@ struct ddog_crasht_Result ddog_crasht_update_on_fork(struct ddog_crasht_Config c * unexpected crash-handling behaviour. */ DDOG_CHECK_RETURN -struct ddog_crasht_Result ddog_crasht_init(struct ddog_crasht_Config config, - struct ddog_crasht_ReceiverConfig receiver_config, - struct ddog_crasht_Metadata metadata); +struct ddog_VoidResult ddog_crasht_init(struct ddog_crasht_Config config, + struct ddog_crasht_ReceiverConfig receiver_config, + struct ddog_crasht_Metadata metadata); /** * Initialize the crash-tracking infrastructure without launching the receiver. @@ -89,8 +89,8 @@ struct ddog_crasht_Result ddog_crasht_init(struct ddog_crasht_Config config, * unexpected crash-handling behaviour. */ DDOG_CHECK_RETURN -struct ddog_crasht_Result ddog_crasht_init_without_receiver(struct ddog_crasht_Config config, - struct ddog_crasht_Metadata metadata); +struct ddog_VoidResult ddog_crasht_init_without_receiver(struct ddog_crasht_Config config, + struct ddog_crasht_Metadata metadata); /** * Resets all counters to 0. @@ -102,7 +102,7 @@ struct ddog_crasht_Result ddog_crasht_init_without_receiver(struct ddog_crasht_C * # Safety * No safety concerns. */ -DDOG_CHECK_RETURN struct ddog_crasht_Result ddog_crasht_reset_counters(void); +DDOG_CHECK_RETURN struct ddog_VoidResult ddog_crasht_reset_counters(void); /** * Atomically increments the count associated with `op`. @@ -111,7 +111,7 @@ DDOG_CHECK_RETURN struct ddog_crasht_Result ddog_crasht_reset_counters(void); * # Safety * No safety concerns. */ -DDOG_CHECK_RETURN struct ddog_crasht_Result ddog_crasht_begin_op(enum ddog_crasht_OpTypes op); +DDOG_CHECK_RETURN struct ddog_VoidResult ddog_crasht_begin_op(enum ddog_crasht_OpTypes op); /** * Atomically decrements the count associated with `op`. @@ -120,7 +120,7 @@ DDOG_CHECK_RETURN struct ddog_crasht_Result ddog_crasht_begin_op(enum ddog_crash * # Safety * No safety concerns. */ -DDOG_CHECK_RETURN struct ddog_crasht_Result ddog_crasht_end_op(enum ddog_crasht_OpTypes op); +DDOG_CHECK_RETURN struct ddog_VoidResult ddog_crasht_end_op(enum ddog_crasht_OpTypes op); /** * Resets all stored spans to 0. @@ -132,7 +132,7 @@ DDOG_CHECK_RETURN struct ddog_crasht_Result ddog_crasht_end_op(enum ddog_crasht_ * # Safety * No safety concerns. */ -DDOG_CHECK_RETURN struct ddog_crasht_Result ddog_crasht_clear_span_ids(void); +DDOG_CHECK_RETURN struct ddog_VoidResult ddog_crasht_clear_span_ids(void); /** * Resets all stored traces to 0. @@ -144,7 +144,7 @@ DDOG_CHECK_RETURN struct ddog_crasht_Result ddog_crasht_clear_span_ids(void); * # Safety * No safety concerns. */ -DDOG_CHECK_RETURN struct ddog_crasht_Result ddog_crasht_clear_trace_ids(void); +DDOG_CHECK_RETURN struct ddog_VoidResult ddog_crasht_clear_trace_ids(void); /** * Atomically registers an active traceId. @@ -168,8 +168,8 @@ DDOG_CHECK_RETURN struct ddog_crasht_Result ddog_crasht_clear_trace_ids(void); * No safety concerns. */ DDOG_CHECK_RETURN -struct ddog_crasht_UsizeResult ddog_crasht_insert_trace_id(uint64_t id_high, - uint64_t id_low); +struct ddog_crasht_Result_Usize ddog_crasht_insert_trace_id(uint64_t id_high, + uint64_t id_low); /** * Atomically registers an active SpanId. @@ -193,8 +193,8 @@ struct ddog_crasht_UsizeResult ddog_crasht_insert_trace_id(uint64_t id_high, * No safety concerns. */ DDOG_CHECK_RETURN -struct ddog_crasht_UsizeResult ddog_crasht_insert_span_id(uint64_t id_high, - uint64_t id_low); +struct ddog_crasht_Result_Usize ddog_crasht_insert_span_id(uint64_t id_high, + uint64_t id_low); /** * Atomically removes a completed SpanId. @@ -219,9 +219,9 @@ struct ddog_crasht_UsizeResult ddog_crasht_insert_span_id(uint64_t id_high, * No safety concerns. */ DDOG_CHECK_RETURN -struct ddog_crasht_Result ddog_crasht_remove_span_id(uint64_t id_high, - uint64_t id_low, - uintptr_t idx); +struct ddog_VoidResult ddog_crasht_remove_span_id(uint64_t id_high, + uint64_t id_low, + uintptr_t idx); /** * Atomically removes a completed TraceId. @@ -246,154 +246,436 @@ struct ddog_crasht_Result ddog_crasht_remove_span_id(uint64_t id_high, * No safety concerns. */ DDOG_CHECK_RETURN -struct ddog_crasht_Result ddog_crasht_remove_trace_id(uint64_t id_high, - uint64_t id_low, - uintptr_t idx); +struct ddog_VoidResult ddog_crasht_remove_trace_id(uint64_t id_high, + uint64_t id_low, + uintptr_t idx); + +/** + * # Safety + * The `builder` can be null, but if non-null it must point to a Frame + * made by this module, which has not previously been dropped. + */ +void ddog_crasht_CrashInfo_drop(struct ddog_crasht_Handle_CrashInfo *builder); + +/** + * # Safety + * The `crash_info` can be null, but if non-null it must point to a Builder made by this module, + * which has not previously been dropped. + */ +DDOG_CHECK_RETURN +struct ddog_VoidResult ddog_crasht_CrashInfo_normalize_ips(struct ddog_crasht_Handle_CrashInfo *crash_info, + uint32_t pid); + +/** + * # Safety + * The `crash_info` can be null, but if non-null it must point to a Builder made by this module, + * which has not previously been dropped. + */ +DDOG_CHECK_RETURN +struct ddog_VoidResult ddog_crasht_CrashInfo_resolve_names(struct ddog_crasht_Handle_CrashInfo *crash_info, + uint32_t pid); + +/** + * # Safety + * The `crash_info` can be null, but if non-null it must point to a Builder made by this module, + * which has not previously been dropped. + * The CharSlice must be valid. + */ +DDOG_CHECK_RETURN +struct ddog_VoidResult ddog_crasht_CrashInfo_upload_to_endpoint(struct ddog_crasht_Handle_CrashInfo *crash_info, + const struct ddog_Endpoint *endpoint); /** - * Create a new crashinfo, and returns an opaque reference to it. + * Create a new CrashInfoBuilder, and returns an opaque reference to it. * # Safety * No safety issues. */ -DDOG_CHECK_RETURN struct ddog_crasht_CrashInfoNewResult ddog_crasht_CrashInfo_new(void); +DDOG_CHECK_RETURN +struct ddog_crasht_Result_HandleCrashInfoBuilder ddog_crasht_CrashInfoBuilder_new(void); /** * # Safety - * The `crash_info` can be null, but if non-null it must point to a CrashInfo + * The `builder` can be null, but if non-null it must point to a Frame * made by this module, which has not previously been dropped. */ -void ddog_crasht_CrashInfo_drop(struct ddog_crasht_CrashInfo *crashinfo); +void ddog_crasht_CrashInfoBuilder_drop(struct ddog_crasht_Handle_CrashInfoBuilder *builder); /** - * Best effort attempt to normalize all `ip` on the stacktrace. - * `pid` must be the pid of the currently active process where the ips came from. - * * # Safety - * `crashinfo` must be a valid pointer to a `CrashInfo` object. + * The `builder` can be null, but if non-null it must point to a Builder made by this module, + * which has not previously been dropped. */ DDOG_CHECK_RETURN -struct ddog_crasht_Result ddog_crasht_CrashInfo_normalize_ips(struct ddog_crasht_CrashInfo *crashinfo, - uint32_t pid); +struct ddog_crasht_Result_HandleCrashInfo ddog_crasht_CrashInfoBuilder_build(struct ddog_crasht_Handle_CrashInfoBuilder *builder); /** - * Adds a "counter" variable, with the given value. Useful for determining if - * "interesting" operations were occurring when the crash did. - * * # Safety - * `crashinfo` must be a valid pointer to a `CrashInfo` object. - * `name` should be a valid reference to a utf8 encoded String. - * The string is copied into the crashinfo, so it does not need to outlive this - * call. + * The `builder` can be null, but if non-null it must point to a Builder made by this module, + * which has not previously been dropped. + * The CharSlice must be valid. */ DDOG_CHECK_RETURN -struct ddog_crasht_Result ddog_crasht_CrashInfo_add_counter(struct ddog_crasht_CrashInfo *crashinfo, - ddog_CharSlice name, - int64_t val); +struct ddog_VoidResult ddog_crasht_CrashInfoBuilder_with_counter(struct ddog_crasht_Handle_CrashInfoBuilder *builder, + ddog_CharSlice name, + int64_t value); /** - * Adds the contents of "file" to the crashinfo - * * # Safety - * `crashinfo` must be a valid pointer to a `CrashInfo` object. - * `name` should be a valid reference to a utf8 encoded String. - * The string is copied into the crashinfo, so it does not need to outlive this - * call. + * The `builder` can be null, but if non-null it must point to a Builder made by this module, + * which has not previously been dropped. + * The Kind must be valid. */ DDOG_CHECK_RETURN -struct ddog_crasht_Result ddog_crasht_CrashInfo_add_file(struct ddog_crasht_CrashInfo *crashinfo, - ddog_CharSlice filename); +struct ddog_VoidResult ddog_crasht_CrashInfoBuilder_with_kind(struct ddog_crasht_Handle_CrashInfoBuilder *builder, + enum ddog_crasht_ErrorKind kind); /** - * Adds the tag with given "key" and "value" to the crashinfo - * * # Safety - * `crashinfo` must be a valid pointer to a `CrashInfo` object. - * `key` should be a valid reference to a utf8 encoded String. - * `value` should be a valid reference to a utf8 encoded String. - * The string is copied into the crashinfo, so it does not need to outlive this - * call. + * The `builder` can be null, but if non-null it must point to a Builder made by this module, + * which has not previously been dropped. + * The CharSlice must be valid. */ DDOG_CHECK_RETURN -struct ddog_crasht_Result ddog_crasht_CrashInfo_add_tag(struct ddog_crasht_CrashInfo *crashinfo, - ddog_CharSlice key, - ddog_CharSlice value); +struct ddog_VoidResult ddog_crasht_CrashInfoBuilder_with_file(struct ddog_crasht_Handle_CrashInfoBuilder *builder, + ddog_CharSlice filename); /** - * Sets the crashinfo metadata - * * # Safety - * `crashinfo` must be a valid pointer to a `CrashInfo` object. - * All references inside `metadata` must be valid. - * Strings are copied into the crashinfo, and do not need to outlive this call. + * The `builder` can be null, but if non-null it must point to a Builder made by this module, + * which has not previously been dropped. + * The CharSlice must be valid. */ DDOG_CHECK_RETURN -struct ddog_crasht_Result ddog_crasht_CrashInfo_set_metadata(struct ddog_crasht_CrashInfo *crashinfo, - struct ddog_crasht_Metadata metadata); +struct ddog_VoidResult ddog_crasht_CrashInfoBuilder_with_file_and_contents(struct ddog_crasht_Handle_CrashInfoBuilder *builder, + ddog_CharSlice filename, + struct ddog_crasht_Slice_CharSlice contents); /** - * Sets the crashinfo siginfo - * * # Safety - * `crashinfo` must be a valid pointer to a `CrashInfo` object. - * All references inside `metadata` must be valid. - * Strings are copied into the crashinfo, and do not need to outlive this call. + * The `builder` can be null, but if non-null it must point to a Builder made by this module, + * which has not previously been dropped. + * The CharSlice must be valid. */ DDOG_CHECK_RETURN -struct ddog_crasht_Result ddog_crasht_CrashInfo_set_siginfo(struct ddog_crasht_CrashInfo *crashinfo, - struct ddog_crasht_SigInfo siginfo); +struct ddog_VoidResult ddog_crasht_CrashInfoBuilder_with_fingerprint(struct ddog_crasht_Handle_CrashInfoBuilder *builder, + ddog_CharSlice fingerprint); /** - * If `thread_id` is empty, sets `stacktrace` as the default stacktrace. - * Otherwise, adds an additional stacktrace with id "thread_id". - * * # Safety - * `crashinfo` must be a valid pointer to a `CrashInfo` object. - * All references inside `stacktraces` must be valid. - * Strings are copied into the crashinfo, and do not need to outlive this call. + * The `builder` can be null, but if non-null it must point to a Builder made by this module, + * which has not previously been dropped. + * The CharSlice must be valid. */ DDOG_CHECK_RETURN -struct ddog_crasht_Result ddog_crasht_CrashInfo_set_stacktrace(struct ddog_crasht_CrashInfo *crashinfo, - ddog_CharSlice thread_id, - struct ddog_crasht_Slice_StackFrame stacktrace); +struct ddog_VoidResult ddog_crasht_CrashInfoBuilder_with_incomplete(struct ddog_crasht_Handle_CrashInfoBuilder *builder, + bool incomplete); /** - * Sets the timestamp to the given unix timestamp - * * # Safety - * `crashinfo` must be a valid pointer to a `CrashInfo` object. + * The `builder` can be null, but if non-null it must point to a Builder made by this module, + * which has not previously been dropped. + * The CharSlice must be valid. */ DDOG_CHECK_RETURN -struct ddog_crasht_Result ddog_crasht_CrashInfo_set_timestamp(struct ddog_crasht_CrashInfo *crashinfo, - struct ddog_Timespec ts); +struct ddog_VoidResult ddog_crasht_CrashInfoBuilder_with_log_message(struct ddog_crasht_Handle_CrashInfoBuilder *builder, + ddog_CharSlice message); /** - * Sets the timestamp to the current time - * * # Safety - * `crashinfo` must be a valid pointer to a `CrashInfo` object. + * The `builder` can be null, but if non-null it must point to a Builder made by this module, + * which has not previously been dropped. + * All arguments must be valid. */ DDOG_CHECK_RETURN -struct ddog_crasht_Result ddog_crasht_CrashInfo_set_timestamp_to_now(struct ddog_crasht_CrashInfo *crashinfo); +struct ddog_VoidResult ddog_crasht_CrashInfoBuilder_with_metadata(struct ddog_crasht_Handle_CrashInfoBuilder *builder, + struct ddog_crasht_Metadata metadata); + +/** + * # Safety + * The `builder` can be null, but if non-null it must point to a Builder made by this module, + * which has not previously been dropped. + * All arguments must be valid. + */ +DDOG_CHECK_RETURN +struct ddog_VoidResult ddog_crasht_CrashInfoBuilder_with_os_info(struct ddog_crasht_Handle_CrashInfoBuilder *builder, + struct ddog_crasht_OsInfo os_info); + +/** + * # Safety + * The `builder` can be null, but if non-null it must point to a Builder made by this module, + * which has not previously been dropped. + * All arguments must be valid. + */ +DDOG_CHECK_RETURN +struct ddog_VoidResult ddog_crasht_CrashInfoBuilder_with_os_info_this_machine(struct ddog_crasht_Handle_CrashInfoBuilder *builder); + +/** + * # Safety + * The `builder` can be null, but if non-null it must point to a Builder made by this module, + * which has not previously been dropped. + * All arguments must be valid. + */ +DDOG_CHECK_RETURN +struct ddog_VoidResult ddog_crasht_CrashInfoBuilder_with_proc_info(struct ddog_crasht_Handle_CrashInfoBuilder *builder, + struct ddog_crasht_ProcInfo proc_info); + +/** + * # Safety + * The `builder` can be null, but if non-null it must point to a Builder made by this module, + * which has not previously been dropped. + * All arguments must be valid. + */ +DDOG_CHECK_RETURN +struct ddog_VoidResult ddog_crasht_CrashInfoBuilder_with_sig_info(struct ddog_crasht_Handle_CrashInfoBuilder *builder, + struct ddog_crasht_SigInfo sig_info); + +/** + * # Safety + * The `builder` can be null, but if non-null it must point to a Builder made by this module, + * which has not previously been dropped. + * All arguments must be valid. + */ +DDOG_CHECK_RETURN +struct ddog_VoidResult ddog_crasht_CrashInfoBuilder_with_span_id(struct ddog_crasht_Handle_CrashInfoBuilder *builder, + struct ddog_crasht_Span span_id); + +/** + * # Safety + * The `builder` can be null, but if non-null it must point to a Builder made by this module, + * which has not previously been dropped. + * All arguments must be valid. + * Consumes the stack argument. + */ +DDOG_CHECK_RETURN +struct ddog_VoidResult ddog_crasht_CrashInfoBuilder_with_stack(struct ddog_crasht_Handle_CrashInfoBuilder *builder, + struct ddog_crasht_Handle_StackTrace *stack); + +/** + * # Safety + * The `builder` can be null, but if non-null it must point to a Builder made by this module, + * which has not previously been dropped. + * All arguments must be valid. + * Consumes the stack argument. + */ +DDOG_CHECK_RETURN +struct ddog_VoidResult ddog_crasht_CrashInfoBuilder_with_thread(struct ddog_crasht_Handle_CrashInfoBuilder *builder, + struct ddog_crasht_ThreadData thread); + +/** + * # Safety + * The `builder` can be null, but if non-null it must point to a Builder made by this module, + * which has not previously been dropped. + * The CharSlice must be valid. + */ +DDOG_CHECK_RETURN +struct ddog_VoidResult ddog_crasht_CrashInfoBuilder_with_timestamp(struct ddog_crasht_Handle_CrashInfoBuilder *builder, + struct ddog_Timespec ts); + +/** + * # Safety + * The `builder` can be null, but if non-null it must point to a Builder made by this module, + * which has not previously been dropped. + * The CharSlice must be valid. + */ +DDOG_CHECK_RETURN +struct ddog_VoidResult ddog_crasht_CrashInfoBuilder_with_timestamp_now(struct ddog_crasht_Handle_CrashInfoBuilder *builder); /** - * Sets crashinfo procinfo - * * # Safety - * `crashinfo` must be a valid pointer to a `CrashInfo` object. + * The `builder` can be null, but if non-null it must point to a Builder made by this module, + * which has not previously been dropped. + * All arguments must be valid. */ DDOG_CHECK_RETURN -struct ddog_crasht_Result ddog_crasht_CrashInfo_set_procinfo(struct ddog_crasht_CrashInfo *crashinfo, - struct ddog_crasht_ProcInfo procinfo); +struct ddog_VoidResult ddog_crasht_CrashInfoBuilder_with_trace_id(struct ddog_crasht_Handle_CrashInfoBuilder *builder, + struct ddog_crasht_Span trace_id); + +/** + * # Safety + * The `builder` can be null, but if non-null it must point to a Builder made by this module, + * which has not previously been dropped. + * The CharSlice must be valid. + */ +DDOG_CHECK_RETURN +struct ddog_VoidResult ddog_crasht_CrashInfoBuilder_with_uuid(struct ddog_crasht_Handle_CrashInfoBuilder *builder, + ddog_CharSlice uuid); + +/** + * # Safety + * The `builder` can be null, but if non-null it must point to a Builder made by this module, + * which has not previously been dropped. + * The CharSlice must be valid. + */ +DDOG_CHECK_RETURN +struct ddog_VoidResult ddog_crasht_CrashInfoBuilder_with_uuid_random(struct ddog_crasht_Handle_CrashInfoBuilder *builder); + +/** + * Create a new StackFrame, and returns an opaque reference to it. + * # Safety + * No safety issues. + */ +DDOG_CHECK_RETURN struct ddog_crasht_Result_HandleStackFrame ddog_crasht_StackFrame_new(void); + +/** + * # Safety + * The `frame` can be null, but if non-null it must point to a Frame + * made by this module, which has not previously been dropped. + */ +void ddog_crasht_StackFrame_drop(struct ddog_crasht_Handle_StackFrame *frame); + +/** + * # Safety + * The `frame` can be null, but if non-null it must point to a Frame made by this module, + * which has not previously been dropped. + * The CharSlice must be valid. + */ +DDOG_CHECK_RETURN +struct ddog_VoidResult ddog_crasht_StackFrame_with_ip(struct ddog_crasht_Handle_StackFrame *frame, + ddog_CharSlice ip); + +/** + * # Safety + * The `frame` can be null, but if non-null it must point to a Frame made by this module, + * which has not previously been dropped. + * The CharSlice must be valid. + */ +DDOG_CHECK_RETURN +struct ddog_VoidResult ddog_crasht_StackFrame_with_module_base_address(struct ddog_crasht_Handle_StackFrame *frame, + ddog_CharSlice module_base_address); + +/** + * # Safety + * The `frame` can be null, but if non-null it must point to a Frame made by this module, + * which has not previously been dropped. + * The CharSlice must be valid. + */ +DDOG_CHECK_RETURN +struct ddog_VoidResult ddog_crasht_StackFrame_with_sp(struct ddog_crasht_Handle_StackFrame *frame, + ddog_CharSlice sp); + +/** + * # Safety + * The `frame` can be null, but if non-null it must point to a Frame made by this module, + * which has not previously been dropped. + * The CharSlice must be valid. + */ +DDOG_CHECK_RETURN +struct ddog_VoidResult ddog_crasht_StackFrame_with_symbol_address(struct ddog_crasht_Handle_StackFrame *frame, + ddog_CharSlice symbol_address); + +/** + * # Safety + * The `frame` can be null, but if non-null it must point to a Frame made by this module, + * which has not previously been dropped. + * The CharSlice must be valid. + */ +DDOG_CHECK_RETURN +struct ddog_VoidResult ddog_crasht_StackFrame_with_build_id(struct ddog_crasht_Handle_StackFrame *frame, + ddog_CharSlice build_id); + +/** + * # Safety + * The `frame` can be null, but if non-null it must point to a Frame made by this module, + * which has not previously been dropped. + * The BuildIdType must be valid. + */ +DDOG_CHECK_RETURN +struct ddog_VoidResult ddog_crasht_StackFrame_with_build_id_type(struct ddog_crasht_Handle_StackFrame *frame, + enum ddog_crasht_BuildIdType build_id_type); + +/** + * # Safety + * The `frame` can be null, but if non-null it must point to a Frame made by this module, + * which has not previously been dropped. + * The FileType must be valid. + */ +DDOG_CHECK_RETURN +struct ddog_VoidResult ddog_crasht_StackFrame_with_file_type(struct ddog_crasht_Handle_StackFrame *frame, + enum ddog_crasht_FileType file_type); + +/** + * # Safety + * The `frame` can be null, but if non-null it must point to a Frame made by this module, + * which has not previously been dropped. + * The CharSlice must be valid. + */ +DDOG_CHECK_RETURN +struct ddog_VoidResult ddog_crasht_StackFrame_with_path(struct ddog_crasht_Handle_StackFrame *frame, + ddog_CharSlice path); + +/** + * # Safety + * The `frame` can be null, but if non-null it must point to a Frame made by this module, + * which has not previously been dropped. + * The CharSlice must be valid. + */ +DDOG_CHECK_RETURN +struct ddog_VoidResult ddog_crasht_StackFrame_with_relative_address(struct ddog_crasht_Handle_StackFrame *frame, + ddog_CharSlice relative_address); + +/** + * # Safety + * The `frame` can be null, but if non-null it must point to a Frame made by this module, + * which has not previously been dropped. + */ +DDOG_CHECK_RETURN +struct ddog_VoidResult ddog_crasht_StackFrame_with_column(struct ddog_crasht_Handle_StackFrame *frame, + uint32_t column); + +/** + * # Safety + * The `frame` can be null, but if non-null it must point to a Frame made by this module, + * which has not previously been dropped. + * The CharSlice must be valid. + */ +DDOG_CHECK_RETURN +struct ddog_VoidResult ddog_crasht_StackFrame_with_file(struct ddog_crasht_Handle_StackFrame *frame, + ddog_CharSlice file); + +/** + * # Safety + * The `frame` can be null, but if non-null it must point to a Frame made by this module, + * which has not previously been dropped. + * The CharSlice must be valid. + */ +DDOG_CHECK_RETURN +struct ddog_VoidResult ddog_crasht_StackFrame_with_function(struct ddog_crasht_Handle_StackFrame *frame, + ddog_CharSlice function); + +/** + * # Safety + * The `frame` can be null, but if non-null it must point to a Frame made by this module, + * which has not previously been dropped. + */ +DDOG_CHECK_RETURN +struct ddog_VoidResult ddog_crasht_StackFrame_with_line(struct ddog_crasht_Handle_StackFrame *frame, + uint32_t line); + +/** + * Create a new StackTrace, and returns an opaque reference to it. + * # Safety + * No safety issues. + */ +DDOG_CHECK_RETURN struct ddog_crasht_Result_HandleStackTrace ddog_crasht_StackTrace_new(void); + +/** + * # Safety + * The `frame` can be null, but if non-null it must point to a Frame + * made by this module, which has not previously been dropped. + */ +void ddog_crasht_StackTrace_drop(struct ddog_crasht_Handle_StackTrace *trace); /** - * Exports `crashinfo` to the backend at `endpoint` - * Note that we support the "file://" endpoint for local file output. * # Safety - * `crashinfo` must be a valid pointer to a `CrashInfo` object. + * The `stacktrace` can be null, but if non-null it must point to a StackTrace made by this module, + * which has not previously been dropped. + * The frame can be non-null, but if non-null it must point to a Frame made by this module, + * which has not previously been dropped. + * The frame is consumed, and does not need to be dropped after this operation. */ DDOG_CHECK_RETURN -struct ddog_crasht_Result ddog_crasht_CrashInfo_upload_to_endpoint(struct ddog_crasht_CrashInfo *crashinfo, - const struct ddog_Endpoint *endpoint); +struct ddog_VoidResult ddog_crasht_StackTrace_push_frame(struct ddog_crasht_Handle_StackTrace *trace, + struct ddog_crasht_Handle_StackFrame *frame); /** * Demangles the string "name". @@ -404,8 +686,8 @@ struct ddog_crasht_Result ddog_crasht_CrashInfo_upload_to_endpoint(struct ddog_c * The string is copied into the result, and does not need to outlive this call */ DDOG_CHECK_RETURN -struct ddog_crasht_StringWrapperResult ddog_crasht_demangle(ddog_CharSlice name, - enum ddog_crasht_DemangleOptions options); +struct ddog_crasht_Result_StringWrapper ddog_crasht_demangle(ddog_CharSlice name, + enum ddog_crasht_DemangleOptions options); /** * Receives data from a crash collector via a pipe on `stdin`, formats it into @@ -419,7 +701,7 @@ struct ddog_crasht_StringWrapperResult ddog_crasht_demangle(ddog_CharSlice name, * # Safety * No safety concerns */ -DDOG_CHECK_RETURN struct ddog_crasht_Result ddog_crasht_receiver_entry_point_stdin(void); +DDOG_CHECK_RETURN struct ddog_VoidResult ddog_crasht_receiver_entry_point_stdin(void); /** * Receives data from a crash collector via a pipe on `stdin`, formats it into @@ -435,7 +717,7 @@ DDOG_CHECK_RETURN struct ddog_crasht_Result ddog_crasht_receiver_entry_point_std * No safety concerns */ DDOG_CHECK_RETURN -struct ddog_crasht_Result ddog_crasht_receiver_entry_point_unix_socket(ddog_CharSlice socket_path); +struct ddog_VoidResult ddog_crasht_receiver_entry_point_unix_socket(ddog_CharSlice socket_path); #ifdef __cplusplus } // extern "C" diff --git a/ext/signals.c b/ext/signals.c index c5d85406f0..ce51361b9e 100644 --- a/ext/signals.c +++ b/ext/signals.c @@ -91,8 +91,8 @@ static void ddtrace_sigsegv_handler(int sig) { _Exit(128 + sig); } -static bool ddtrace_crashtracker_check_result(ddog_crasht_Result result, const char *msg) { - if (result.tag != DDOG_CRASHT_RESULT_OK) { +static bool ddtrace_crashtracker_check_result(ddog_VoidResult result, const char *msg) { + if (result.tag != DDOG_VOID_RESULT_OK) { ddog_CharSlice error_msg = ddog_Error_message(&result.err); LOG(ERROR, "%s : %.*s", msg, (int) error_msg.len, error_msg.ptr); ddog_Error_drop(&result.err); diff --git a/libdatadog b/libdatadog index 38524d553b..9bd62bbb00 160000 --- a/libdatadog +++ b/libdatadog @@ -1 +1 @@ -Subproject commit 38524d553b8d66f2fedc58fcf2250b8f8fbc47a3 +Subproject commit 9bd62bbb0045dcbd80faf0d15f682e559009e689