初识rust


调试下rust 的执行流程

参考:

认识 Cargo - Rust语言圣经(Rust Course)

新建一个hello world 程序:

fn main() {
    println!("Hello, world!");
}

用IDA 打开exe,并加载符号:

根据字符串找到主程序入口:

双击该符号,然后按x,快捷键,查看所有的符号引用:

之后跳转到对应的程序位置:

PE 起始地址为140000000

读取"hello,world"字符的指令地址:140001040:

使用windbg ,加载该程序,并在lea 指令的位置下断点:

0:000> kp
 # Child-SP          RetAddr               Call Site
00 000000e6`c38ff9a8 00007ff7`b2571006     hello_world!__ImageBase
01 000000e6`c38ff9b0 00007ff7`b257101c     hello_world!__ImageBase
02 000000e6`c38ff9e0 00007ff7`b25736a8     hello_world!__ImageBase
03 (Inline Function) --------`--------     hello_world!std::rt::lang_start_internal::closure$2(void)+0xb [/rustc/cc66ad468955717ab92600c770da8c1601a4ff33/library\std\src\rt.rs @ 148] 
04 (Inline Function) --------`--------     hello_world!std::panicking::try::do_call(void)+0xb [/rustc/cc66ad468955717ab92600c770da8c1601a4ff33/library\std\src\panicking.rs @ 502] 
05 (Inline Function) --------`--------     hello_world!std::panicking::try(void)+0xb [/rustc/cc66ad468955717ab92600c770da8c1601a4ff33/library\std\src\panicking.rs @ 466] 
06 (Inline Function) --------`--------     hello_world!std::panic::catch_unwind(void)+0xb [/rustc/cc66ad468955717ab92600c770da8c1601a4ff33/library\std\src\panic.rs @ 142] 
07 000000e6`c38ffa10 00007ff7`b25710ac     hello_world!std::rt::lang_start_internal(void)+0xb8 [/rustc/cc66ad468955717ab92600c770da8c1601a4ff33/library\std\src\rt.rs @ 148] 
08 000000e6`c38ffb10 00007ff7`b258a510     hello_world!main+0x2c
09 (Inline Function) --------`--------     hello_world!invoke_main(void)+0x22 [D:\a\_work\1\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl @ 78] 
0a 000000e6`c38ffb50 00007ffc`c2a0257d     hello_world!__scrt_common_main_seh(void)+0x10c [D:\a\_work\1\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl @ 288] 
0b 000000e6`c38ffb90 00007ffc`c39caa78     KERNEL32!BaseThreadInitThunk+0x1d
0c 000000e6`c38ffbc0 00000000`00000000     ntdll!RtlUserThreadStart+0x28
//! Runtime services
//!
//! The `rt` module provides a narrow set of runtime services,
//! including the global heap (exported in `heap`) and unwinding and
//! backtrace support. The APIs in this module are highly unstable,
//! and should be considered as private implementation details for the
//! time being.

#![unstable(
    feature = "rt",
    reason = "this public module should not exist and is highly likely \
              to disappear",
    issue = "none"
)]
#![doc(hidden)]
#![deny(unsafe_op_in_unsafe_fn)]
#![allow(unused_macros)]

use crate::ffi::CString;

// Re-export some of our utilities which are expected by other crates.
pub use crate::panicking::{begin_panic, panic_count};
pub use core::panicking::{panic_display, panic_fmt};

use crate::sync::Once;
use crate::sys;
use crate::sys_common::thread_info;
use crate::thread::Thread;

// Prints to the "panic output", depending on the platform this may be:
// - the standard error output
// - some dedicated platform specific output
// - nothing (so this macro is a no-op)
macro_rules! rtprintpanic {
    ($($t:tt)*) => {
        if let Some(mut out) = crate::sys::stdio::panic_output() {
            let _ = crate::io::Write::write_fmt(&mut out, format_args!($($t)*));
        }
    }
}

macro_rules! rtabort {
    ($($t:tt)*) => {
        {
            rtprintpanic!("fatal runtime error: {}\n", format_args!($($t)*));
            crate::sys::abort_internal();
        }
    }
}

macro_rules! rtassert {
    ($e:expr) => {
        if !$e {
            rtabort!(concat!("assertion failed: ", stringify!($e)));
        }
    };
}

macro_rules! rtunwrap {
    ($ok:ident, $e:expr) => {
        match $e {
            $ok(v) => v,
            ref err => {
                let err = err.as_ref().map(drop); // map Ok/Some which might not be Debug
                rtabort!(concat!("unwrap failed: ", stringify!($e), " = {:?}"), err)
            }
        }
    };
}

// One-time runtime initialization.
// Runs before `main`.
// SAFETY: must be called only once during runtime initialization.
// NOTE: this is not guaranteed to run, for example when Rust code is called externally.
//
// # The `sigpipe` parameter
//
// Since 2014, the Rust runtime on Unix has set the `SIGPIPE` handler to
// `SIG_IGN`. Applications have good reasons to want a different behavior
// though, so there is a `#[unix_sigpipe = "..."]` attribute on `fn main()` that
// can be used to select how `SIGPIPE` shall be setup (if changed at all) before
// `fn main()` is called. See <https://github.com/rust-lang/rust/issues/97889>
// for more info.
//
// The `sigpipe` parameter to this function gets its value via the code that
// rustc generates to invoke `fn lang_start()`. The reason we have `sigpipe` for
// all platforms and not only Unix, is because std is not allowed to have `cfg`
// directives as this high level. See the module docs in
// `src/tools/tidy/src/pal.rs` for more info. On all other platforms, `sigpipe`
// has a value, but its value is ignored.
//
// Even though it is an `u8`, it only ever has 4 values. These are documented in
// `compiler/rustc_session/src/config/sigpipe.rs`.
#[cfg_attr(test, allow(dead_code))]
unsafe fn init(argc: isize, argv: *const *const u8, sigpipe: u8) {
    unsafe {
        sys::init(argc, argv, sigpipe);

        let main_guard = sys::thread::guard::init();
        // Next, set up the current Thread with the guard information we just
        // created. Note that this isn't necessary in general for new threads,
        // but we just do this to name the main thread and to give it correct
        // info about the stack bounds.
        let thread = Thread::new(Some(rtunwrap!(Ok, CString::new("main"))));
        thread_info::set(main_guard, thread);
    }
}

// One-time runtime cleanup.
// Runs after `main` or at program exit.
// NOTE: this is not guaranteed to run, for example when the program aborts.
pub(crate) fn cleanup() {
    static CLEANUP: Once = Once::new();
    CLEANUP.call_once(|| unsafe {
        // Flush stdout and disable buffering.
        crate::io::cleanup();
        // SAFETY: Only called once during runtime cleanup.
        sys::cleanup();
    });
}

// To reduce the generated code of the new `lang_start`, this function is doing
// the real work.
#[cfg(not(test))]
fn lang_start_internal(
    main: &(dyn Fn() -> i32 + Sync + crate::panic::RefUnwindSafe),
    argc: isize,
    argv: *const *const u8,
    sigpipe: u8,
) -> Result<isize, !> {
    use crate::{mem, panic};
    let rt_abort = move |e| {
        mem::forget(e);
        rtabort!("initialization or cleanup bug");
    };
    // Guard against the code called by this function from unwinding outside of the Rust-controlled
    // code, which is UB. This is a requirement imposed by a combination of how the
    // `#[lang="start"]` attribute is implemented as well as by the implementation of the panicking
    // mechanism itself.
    //
    // There are a couple of instances where unwinding can begin. First is inside of the
    // `rt::init`, `rt::cleanup` and similar functions controlled by bstd. In those instances a
    // panic is a std implementation bug. A quite likely one too, as there isn't any way to
    // prevent std from accidentally introducing a panic to these functions. Another is from
    // user code from `main` or, more nefariously, as described in e.g. issue #86030.
    // SAFETY: Only called once during runtime initialization.
    panic::catch_unwind(move || unsafe { init(argc, argv, sigpipe) }).map_err(rt_abort)?;
    let ret_code = panic::catch_unwind(move || panic::catch_unwind(main).unwrap_or(101) as isize)
        .map_err(move |e| {
            mem::forget(e);
            rtabort!("drop of the panic payload panicked");
        });
    panic::catch_unwind(cleanup).map_err(rt_abort)?;
    ret_code
}

#[cfg(not(test))]
#[lang = "start"]
fn lang_start<T: crate::process::Termination + 'static>(
    main: fn() -> T,
    argc: isize,
    argv: *const *const u8,
    sigpipe: u8,
) -> isize {
    let Ok(v) = lang_start_internal(
        &move || crate::sys_common::backtrace::__rust_begin_short_backtrace(main).report().to_i32(),
        argc,
        argv,
        sigpipe,
    );
    v
}

其核心运行时如上

panic

看起来是利用panic 库进行一些基本的异常捕获与异常处理。

panic! 深入剖析 - Rust语言圣经(Rust Course)

实验:

主动 异常
fn main() {
    panic!("crash and burn");
}
PS E:\learn\rust\panic_test> $env:RUST_BACKTRACE="full" ; cargo run release
   Compiling panic_test v0.1.0 (E:\learn\rust\panic_test)
    Finished dev [unoptimized + debuginfo] target(s) in 0.18s
     Running `target\debug\panic_test.exe release`
thread 'main' panicked at src\main.rs:2:5:
crash and burn
stack backtrace:
   0:     0x7ff7a439709a - std::sys_common::backtrace::_print::impl$0::fmt
                               at /rustc/cc66ad468955717ab92600c770da8c1601a4ff33/library\std\src\sys_common\backtrace.rs:44
   1:     0x7ff7a43a52db - core::fmt::rt::Argument::fmt
                               at /rustc/cc66ad468955717ab92600c770da8c1601a4ff33/library\core\src\fmt\rt.rs:138
   2:     0x7ff7a43a52db - core::fmt::write
                               at /rustc/cc66ad468955717ab92600c770da8c1601a4ff33/library\core\src\fmt\mod.rs:1094
   3:     0x7ff7a43953d1 - std::io::Write::write_fmt<std::sys::windows::stdio::Stderr>
                               at /rustc/cc66ad468955717ab92600c770da8c1601a4ff33/library\std\src\io\mod.rs:1714
   4:     0x7ff7a4396e1a - std::sys_common::backtrace::_print
                               at /rustc/cc66ad468955717ab92600c770da8c1601a4ff33/library\std\src\sys_common\backtrace.rs:47
   5:     0x7ff7a4396e1a - std::sys_common::backtrace::print
                               at /rustc/cc66ad468955717ab92600c770da8c1601a4ff33/library\std\src\sys_common\backtrace.rs:34
   6:     0x7ff7a4398e4a - std::panicking::default_hook::closure$1
                               at /rustc/cc66ad468955717ab92600c770da8c1601a4ff33/library\std\src\panicking.rs:270
   7:     0x7ff7a4398ab8 - std::panicking::default_hook
                               at /rustc/cc66ad468955717ab92600c770da8c1601a4ff33/library\std\src\panicking.rs:290
   8:     0x7ff7a43994fe - std::panicking::rust_panic_with_hook
                               at /rustc/cc66ad468955717ab92600c770da8c1601a4ff33/library\std\src\panicking.rs:707
   9:     0x7ff7a43993aa - std::panicking::begin_panic_handler::closure$0
                               at /rustc/cc66ad468955717ab92600c770da8c1601a4ff33/library\std\src\panicking.rs:597
  10:     0x7ff7a4397a89 - std::sys_common::backtrace::__rust_end_short_backtrace<std::panicking::begin_panic_handler::closure_env$0,never$>
                               at /rustc/cc66ad468955717ab92600c770da8c1601a4ff33/library\std\src\sys_common\backtrace.rs:170    
  11:     0x7ff7a43990f0 - std::panicking::begin_panic_handler
                               at /rustc/cc66ad468955717ab92600c770da8c1601a4ff33/library\std\src\panicking.rs:595
  12:     0x7ff7a43aa235 - core::panicking::panic_fmt
                               at /rustc/cc66ad468955717ab92600c770da8c1601a4ff33/library\core\src\panicking.rs:67
  13:     0x7ff7a43910a1 - panic_test::main
                               at E:\learn\rust\panic_test\src\main.rs:2
  14:     0x7ff7a439123b - core::ops::function::FnOnce::call_once<void (*)(),tuple$<> >
                               at /rustc/cc66ad468955717ab92600c770da8c1601a4ff33\library\core\src\ops\function.rs:250
  15:     0x7ff7a439119e - std::sys_common::backtrace::__rust_begin_short_backtrace<void (*)(),tuple$<> >
                               at /rustc/cc66ad468955717ab92600c770da8c1601a4ff33\library\std\src\sys_common\backtrace.rs:154    
  16:     0x7ff7a439119e - std::sys_common::backtrace::__rust_begin_short_backtrace<void (*)(),tuple$<> >
                               at /rustc/cc66ad468955717ab92600c770da8c1601a4ff33\library\std\src\sys_common\backtrace.rs:154    
  17:     0x7ff7a4391061 - std::rt::lang_start::closure$0<tuple$<> >
                               at /rustc/cc66ad468955717ab92600c770da8c1601a4ff33\library\std\src\rt.rs:166
  18:     0x7ff7a4393558 - std::rt::lang_start_internal::closure$2
                               at /rustc/cc66ad468955717ab92600c770da8c1601a4ff33/library\std\src\rt.rs:148
  19:     0x7ff7a4393558 - std::panicking::try::do_call
                               at /rustc/cc66ad468955717ab92600c770da8c1601a4ff33/library\std\src\panicking.rs:502
  20:     0x7ff7a4393558 - std::panicking::try
                               at /rustc/cc66ad468955717ab92600c770da8c1601a4ff33/library\std\src\panicking.rs:466
  21:     0x7ff7a4393558 - std::panic::catch_unwind
                               at /rustc/cc66ad468955717ab92600c770da8c1601a4ff33/library\std\src\panic.rs:142
  22:     0x7ff7a4393558 - std::rt::lang_start_internal
                               at /rustc/cc66ad468955717ab92600c770da8c1601a4ff33/library\std\src\rt.rs:148
  23:     0x7ff7a439103a - std::rt::lang_start<tuple$<> >
                               at /rustc/cc66ad468955717ab92600c770da8c1601a4ff33\library\std\src\rt.rs:165
  24:     0x7ff7a43910c9 - main
  25:     0x7ff7a43a8c80 - invoke_main
                               at D:\a\_work\1\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:78
  26:     0x7ff7a43a8c80 - __scrt_common_main_seh
                               at D:\a\_work\1\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:288
  27:     0x7ffcc2a0257d - BaseThreadInitThunk
  28:     0x7ffcc39caa78 - RtlUserThreadStart
error: process didn't exit successfully: `target\debug\panic_test.exe release` (exit code: 101)
被动 异常
fn main() {
    let v = vec![1, 2, 3];

    v[99];
}
PS E:\learn\rust\panic_test> $env:RUST_BACKTRACE="full" ; cargo run release
    Finished dev [unoptimized + debuginfo] target(s) in 0.00s
     Running `target\debug\panic_test.exe release`
thread 'main' panicked at src\main.rs:4:6:
index out of bounds: the len is 3 but the index is 99
stack backtrace:
   0:     0x7ff75aca794a - std::sys_common::backtrace::_print::impl$0::fmt
                               at /rustc/cc66ad468955717ab92600c770da8c1601a4ff33/library\std\src\sys_common\backtrace.rs:44
   1:     0x7ff75acb5c1b - core::fmt::rt::Argument::fmt
                               at /rustc/cc66ad468955717ab92600c770da8c1601a4ff33/library\core\src\fmt\rt.rs:138
   2:     0x7ff75acb5c1b - core::fmt::write
                               at /rustc/cc66ad468955717ab92600c770da8c1601a4ff33/library\core\src\fmt\mod.rs:1094
   3:     0x7ff75aca5c81 - std::io::Write::write_fmt<std::sys::windows::stdio::Stderr>
                               at /rustc/cc66ad468955717ab92600c770da8c1601a4ff33/library\std\src\io\mod.rs:1714
   4:     0x7ff75aca76ca - std::sys_common::backtrace::_print
                               at /rustc/cc66ad468955717ab92600c770da8c1601a4ff33/library\std\src\sys_common\backtrace.rs:47
   5:     0x7ff75aca76ca - std::sys_common::backtrace::print
                               at /rustc/cc66ad468955717ab92600c770da8c1601a4ff33/library\std\src\sys_common\backtrace.rs:34
   6:     0x7ff75aca978a - std::panicking::default_hook::closure$1
                               at /rustc/cc66ad468955717ab92600c770da8c1601a4ff33/library\std\src\panicking.rs:270
   7:     0x7ff75aca93f8 - std::panicking::default_hook
                               at /rustc/cc66ad468955717ab92600c770da8c1601a4ff33/library\std\src\panicking.rs:290
   8:     0x7ff75aca9e3e - std::panicking::rust_panic_with_hook
                               at /rustc/cc66ad468955717ab92600c770da8c1601a4ff33/library\std\src\panicking.rs:707
   9:     0x7ff75aca9d2d - std::panicking::begin_panic_handler::closure$0
                               at /rustc/cc66ad468955717ab92600c770da8c1601a4ff33/library\std\src\panicking.rs:599
  10:     0x7ff75aca8339 - std::sys_common::backtrace::__rust_end_short_backtrace<std::panicking::begin_panic_handler::closure_env$0,never$>
                               at /rustc/cc66ad468955717ab92600c770da8c1601a4ff33/library\std\src\sys_common\backtrace.rs:170    
  11:     0x7ff75aca9a30 - std::panicking::begin_panic_handler
                               at /rustc/cc66ad468955717ab92600c770da8c1601a4ff33/library\std\src\panicking.rs:595
  12:     0x7ff75acbab75 - core::panicking::panic_fmt
                               at /rustc/cc66ad468955717ab92600c770da8c1601a4ff33/library\core\src\panicking.rs:67
  13:     0x7ff75acbacee - core::panicking::panic_bounds_check
                               at /rustc/cc66ad468955717ab92600c770da8c1601a4ff33/library\core\src\panicking.rs:162
  14:     0x7ff75aca1afd - core::slice::index::impl$2::index<i32>
                               at /rustc/cc66ad468955717ab92600c770da8c1601a4ff33\library\core\src\slice\index.rs:261
  15:     0x7ff75aca1076 - alloc::vec::impl$12::index<i32,usize,alloc::alloc::Global>
                               at /rustc/cc66ad468955717ab92600c770da8c1601a4ff33\library\alloc\src\vec\mod.rs:2675
  16:     0x7ff75aca1366 - panic_test::main
                               at E:\learn\rust\panic_test\src\main.rs:4
  17:     0x7ff75aca14ab - core::ops::function::FnOnce::call_once<void (*)(),tuple$<> >
                               at /rustc/cc66ad468955717ab92600c770da8c1601a4ff33\library\core\src\ops\function.rs:250
  18:     0x7ff75aca13de - std::sys_common::backtrace::__rust_begin_short_backtrace<void (*)(),tuple$<> >
                               at /rustc/cc66ad468955717ab92600c770da8c1601a4ff33\library\std\src\sys_common\backtrace.rs:154    
  19:     0x7ff75aca13de - std::sys_common::backtrace::__rust_begin_short_backtrace<void (*)(),tuple$<> >
                               at /rustc/cc66ad468955717ab92600c770da8c1601a4ff33\library\std\src\sys_common\backtrace.rs:154    
  20:     0x7ff75aca12e1 - std::rt::lang_start::closure$0<tuple$<> >
                               at /rustc/cc66ad468955717ab92600c770da8c1601a4ff33\library\std\src\rt.rs:166
  21:     0x7ff75aca3e08 - std::rt::lang_start_internal::closure$2
                               at /rustc/cc66ad468955717ab92600c770da8c1601a4ff33/library\std\src\rt.rs:148
  22:     0x7ff75aca3e08 - std::panicking::try::do_call
                               at /rustc/cc66ad468955717ab92600c770da8c1601a4ff33/library\std\src\panicking.rs:502
  23:     0x7ff75aca3e08 - std::panicking::try
                               at /rustc/cc66ad468955717ab92600c770da8c1601a4ff33/library\std\src\panicking.rs:466
  24:     0x7ff75aca3e08 - std::panic::catch_unwind
                               at /rustc/cc66ad468955717ab92600c770da8c1601a4ff33/library\std\src\panic.rs:142
  25:     0x7ff75aca3e08 - std::rt::lang_start_internal
                               at /rustc/cc66ad468955717ab92600c770da8c1601a4ff33/library\std\src\rt.rs:148
  26:     0x7ff75aca12ba - std::rt::lang_start<tuple$<> >
                               at /rustc/cc66ad468955717ab92600c770da8c1601a4ff33\library\std\src\rt.rs:165
  27:     0x7ff75aca13c9 - main
  28:     0x7ff75acb95c0 - invoke_main
                               at D:\a\_work\1\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:78
  29:     0x7ff75acb95c0 - __scrt_common_main_seh
                               at D:\a\_work\1\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:288
  30:     0x7ffcc2a0257d - BaseThreadInitThunk
  31:     0x7ffcc39caa78 - RtlUserThreadStart
error: process didn't exit successfully: `target\debug\panic_test.exe release` (exit code: 101)

可以看到,包括我们用windbg 看到的,比较完整的js 运行时的入口都看到了

 rust 程序main 入口前,就已经安装了一个默认的panic handler ,用来打印一些全局的错误信息,和堆栈列表。

rt.rs 详解

int __cdecl main(int argc, const char **argv, const char **envp)
{
  char v4; // [rsp+20h] [rbp-18h]
  __int64 (__fastcall *v5)(); // [rsp+30h] [rbp-8h] BYREF

  v5 = sub_140001040;
  v4 = 0;
  return std::rt::lang_start_internal::h8a2184178aa988dc(&v5, &off_14001D360, argc, argv, v4);
}

其中,sub_140001040 即为main 函数:

 

__int64 sub_140001040()
{
  __int64 v1[3]; // [rsp+28h] [rbp-30h] BYREF
  __int128 v2; // [rsp+40h] [rbp-18h]

  v1[0] = (__int64)&off_14001D3A0;
  v1[1] = 1i64;
  v1[2] = (__int64)"called `Option::unwrap()` on a `None` value";
  v2 = 0i64;
  return std::io::stdio::_print::h445fdab5382e0576(v1);
}

 

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:/a/119332.html

如若内容造成侵权/违法违规/事实不符,请联系我们进行投诉反馈qq邮箱809451989@qq.com,一经查实,立即删除!

相关文章

MySQL进阶之性能优化与调优技巧

数据库开发-MySQL 1. 多表查询1.1 概述1.1.2 介绍1.1.3 分类 1.2 内连接1.3 外连接1.4 子查询1.4.1 介绍1.4.2 标量子查询1.4.3 列子查询1.4.4 行子查询1.4.5 表子查询 2. 事务2.1 介绍2.2 操作2.3 四大特性 3. 索引3.1 介绍3.2 结构3.3 语法 1. 多表查询 1.1 概述 1.1.2 介绍…

云计算的大模型之争,亚马逊云科技落后了?

文丨智能相对论 作者丨沈浪 “OpenAI使用了Azure的智能云服务”——在过去的半年&#xff0c;这几乎成为了微软智能云最好的广告词。 正所谓“水涨船高”&#xff0c;凭借OpenAI旗下的ChatGPT在全球范围内爆发&#xff0c;微软趁势拉了一波自家的云计算业务。2023年二季度&a…

个人和企业如何做跨境电商?用API电商接口教你选平台选品决胜跨境电商

当下是跨境电商快速发展的阶段&#xff0c;在未来将会朝向成熟系统化的方向发展&#xff0c;对于跨境电商从业者来说既是机遇&#xff0c;也是挑战。那么&#xff0c;个人做跨境电商的核心要素是什么&#xff1f;又该如何去做&#xff1f;对此&#xff0c;小编总结以下四大核心…

【C/C++】什么是POD(Plain Old Data)类型

2023年11月6日&#xff0c;周一下午 目录 POD类型的定义标量类型POD类型的特点POD类型的例子整数类型&#xff1a;C 风格的结构体&#xff1a;数组&#xff1a;C 风格的字符串&#xff1a;std::array:使用 memcpy 对 POD 类型进行复制把POD类型存储到文件中&#xff0c;并从文…

3.Netty中Channel通道概述

Selector 模型 Java NIO 是基于 Selector 模型来实现非阻塞的 I/O。Netty 底层是基于 Java NIO 实现的&#xff0c;因此也使用了 Selector 模型。 Selector 模型解决了传统的阻塞 I/O 编程一个客户端一个线程的问题。Selector 提供了一种机制&#xff0c;用于监视一个或多个 …

Java2 - 数据结构

5 数据类型 5.1 整数类型 在Java中&#xff0c;数据类型用于定义变量或表达式可以存储的数据的类型。Java的数据类型可分为两大类&#xff1a;基本数据类型和引用数据类型。 byte&#xff0c;字节 【1字节】表示范围&#xff1a;-128 ~ 127 即&#xff1a;-2^7 ~ 2^7 -1 sho…

第二章:人工智能深度学习教程-深度学习简介

深度学习是基于人工神经网络的机器学习的一个分支。它能够学习数据中的复杂模式和关系。在深度学习中&#xff0c;我们不需要显式地对所有内容进行编程。近年来&#xff0c;由于处理能力的进步和大型数据集的可用性&#xff0c;它变得越来越流行。因为它基于人工神经网络&#…

mac装不了python3.7.6

今天发现一个很奇怪的问题 但是我一换成 conda create -n DCA python3.8.12就是成功的 这个就很奇怪

【ElasticSearch系列-04】ElasticSearch的聚合查询操作

ElasticSearch系列整体栏目 内容链接地址【一】ElasticSearch下载和安装https://zhenghuisheng.blog.csdn.net/article/details/129260827【二】ElasticSearch概念和基本操作https://blog.csdn.net/zhenghuishengq/article/details/134121631【三】ElasticSearch的高级查询Quer…

【机器学习3】有监督学习经典分类算法

1 支持向量机 在现实世界的机器学习领域&#xff0c; SVM涵盖了各个方面的知识&#xff0c; 也是面试题目中常见的基础模型。 SVM的分类结果仅依赖于支持向量&#xff0c;对于任意线性可分的两组点&#xff0c;它 们在SVM分类的超平面上的投影都是线性不可分的。 2逻辑回归 …

#龙迅视频转换IC LT7911D是一款高性能Type-C/DP/EDP 转MIPI®DSI/CSI/LVDS 芯片,适用于VR/显示应用。

1.说明 应用功能&#xff1a;LT7911D适用于DP1.2转MIPIDSI/MIPICSI/LVDS&#xff0c;EDP转MIPIDSI/MIPICSI/LVDS&#xff0c;TYPE-C转MIPIDSI/MIPICSI/LVDS应用方案 分辨率&#xff1a;单PORT高达4K30HZ&#xff0c;双PORT高达4K 60HZ 工作温度范围&#xff1a;−40C to 85C 产…

Linux--进程间通信

1.进程间通信 进程间通信的背景&#xff1a; 进程之间是相互独立的&#xff0c;进程由内核数据结构和它所对应的代码和数据&#xff0c;通信成本比较高。 进程间通信目的&#xff1a; 数据传输&#xff1a;一个进程需要将它的数据发送给另一个进程 资源共享&#xff1a;多个进程…

AI绘画 | stable-diffusion-web-ui的基本操作

前言 我们下载安装完成stable-diffusion-web-ui以后&#xff0c;下载对应风格的模型&#xff0c;就可以开始我们的绘画操作了。进行Ai绘画操作前&#xff0c;我们最好先弄清楚web ui界面上的参数按钮的含义。这样我们就能更轻松的绘画出我们想要stable-diffusion-web-ui创作出…

【C/PTA】循环结构进阶练习(二)

本文结合PTA专项练习带领读者掌握循环结构&#xff0c;刷题为主注释为辅&#xff0c;在代码中理解思路&#xff0c;其它不做过多叙述。 7-1 二分法求多项式单根 二分法求函数根的原理为&#xff1a;如果连续函数f(x)在区间[a,b]的两个端点取值异号&#xff0c;即f(a)f(b)<0…

AR眼镜硬件解决方案_AR/VR智能眼镜安卓主板芯片方案介绍

随着近两年来增强现实(AR)技术的逐渐成熟&#xff0c;采用MT8788芯片解决方案的AR眼镜已经问世。众所周知&#xff0c;AR技术可以帮助开发者打造一个既强大而又实用的混合现实世界&#xff0c;将虚拟与真实世界相结合。 据了解&#xff0c;MT8788芯片采用了多芯片分布式处理系统…

卡牌游戏类型定制开发微信卡牌小程序游戏

卡牌类型的游戏开发具有一些独特的特点和挑战&#xff0c;以下是一些主要的特点&#xff1a; 卡牌设计和平衡&#xff1a;卡牌游戏的核心是卡牌设计和平衡。开发团队需要设计各种卡牌&#xff0c;确保它们在游戏中相互平衡&#xff0c;以便提供有趣的游戏体验。卡牌的特性、效…

C语言,数据结构指针,结构构体操作符 •,->,*的区别,看这篇就够了

在朋友们学习指针和数据结构这一章的时候&#xff0c;对各种操作符云里雾里。当你看到这么文章之后你就会明白了。 一 • 和 ->运算符 • 运算符&#xff1a;是结构变量访问结构体成员时用的操作符 -> 运算符&#xff1a;这是结构体指针访问结构体成员时调用的运算符。 …

04-react基础知识-路由

一、react路由环境安装 使用指令&#xff1a;npm i --save react-router-dom type/react-router-dom进行react路由环境安装 二、引入路由 在main.jsx文件中引入该语句&#xff1a; import { createBrowserRouter, RouterProvider } from react-router-dom 定义一个变量rou…

借助 DevChat AI 之力,成就我之全栈梦想

何为 DevChat &#xff1f; DevChat 是集好多种 AI 大模型的智能编程工具,可以大大增加我们上班摸鱼的时间。 整合了如 ChatGPT、Codex等热门 AI 模型支持自然语言编程、代码生成与编写、代码补全等功能因其集成热门 AI 智能&#xff0c;相当于站在了巨人的肩膀上&#xff0c…

节省服务器资源、实现双向数据传输——深度解析WebSocket协议

&#x1f3ac; 江城开朗的豌豆&#xff1a;个人主页 &#x1f525; 个人专栏 :《 VUE 》 《 javaScript 》 &#x1f4dd; 个人网站 :《 江城开朗的豌豆&#x1fadb; 》 ⛺️ 生活的理想&#xff0c;就是为了理想的生活 ! 目录 ⭐ 专栏简介 &#x1f4d8; 文章引言 一、W…