debug_here/
lib.rs

1// Copyright 2018-2019 Ethan Pailes. See the COPYRIGHT
2// file at the top-level directory of this distribution.
3//
4// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
5// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
6// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
7// option. This file may not be copied, modified, or distributed
8// except according to those terms.
9
10/*!
11This crate provides a macro for launching the debugger most appropriate for
12your platform in a new terminal. The first time a program executes the
13`debug_here!()` macro, it launches a new terminal and automatically
14attaches either rust-gdb or rust-lldb to your program at the location
15of the macro.
16
17[The README](https://github.com/ethanpailes/debug-here/blob/master/README.md)
18contains more details and examples.
19
20The [debug-me](https://github.com/ethanpailes/debug-here/tree/master/debug-me)
21program provides a concrete usage example.
22*/
23
24#[macro_use] extern crate lazy_static;
25
26#[cfg(not(target_os = "windows"))]
27extern crate which;
28#[cfg(target_os = "windows")]
29extern crate winapi;
30
31pub mod internal;
32
33/// The debug here macro. Just invoke this macro somewhere in your
34/// source, and when your program reaches it a terminal running
35/// `rust-gdb` or `rust-lldb` will launch.
36///
37/// If you want to force a specific debugger backend, you can write
38/// `debug_here!(gdb)` or `debug_here!(lldb)`.
39#[cfg(not(target_os = "windows"))]
40#[macro_export]
41macro_rules! debug_here {
42    () => {
43        ::debug_here::internal::debug_here_unixy_impl(None);
44    };
45    ( gdb ) => {
46        ::debug_here::internal::debug_here_unixy_impl(Some("rust-gdb"));
47    };
48    ( lldb ) => {
49        ::debug_here::internal::debug_here_unixy_impl(Some("rust-lldb"));
50    };
51}
52
53#[cfg(target_os = "windows")]
54#[macro_export]
55macro_rules! debug_here {
56    () => {
57        ::debug_here::internal::debug_here_win_impl();
58    };
59    ( gdb ) => {
60        compile_error!("debug-here: gdb is not supported on windows");
61    };
62    ( lldb ) => {
63        compile_error!("debug-here: lldb is not supported on windows");
64    };
65}