LLDB 详解

LLDB 详解

  • LLDB 详解
    • 编译器集成优势
    • LLDB 的主要功能
    • 命令格式
      • 原始(raw)命令
      • 选项终止符: --
    • LLDB 中的变量
    • 唯一匹配原则
    • help
    • expression
    • print、call、po
    • 控制流程:continue、next、step、finish
    • register read / write
    • thread backtrace
    • thread return
    • frame 相关命令
    • breakpoint
      • 设置断点
      • 管理断点
      • 断点命令
    • watchpoint

LLDB 详解

LLDB,全称为Low-Level Debugger,是苹果公司开发的一款开源、高性能的源代码级调试器。作为Clang和LLVM项目的一部分,LLDB被设计为C、C++、Objective-C和Swift等编程语言的原生调试器。它提供了丰富的功能和灵活的接口,使得开发者能够有效地定位和修复代码中的错误。

编译器集成优势

LLDB将调试信息转换为Clang类型,以便利用Clang编译器基础设施。这允许LLDB在表达式中支持最新的C、C++、Objective-C语言功能和运行时,而无需重新实现任何此功能。它还利用编译器在使函数调用表达式、解码指令和提取指令详细信息等时处理所有ABI细节。

LLDB的主要优点有:

  1. C、C++、Objective-C的最新语言支持。
  2. 可以声明局部变量和类型的多行表达式。
  3. 当支持时,使用JIT作为表达式。
  4. 当无法使用JIT时,评估表达式中间表示(IR)。

LLDB 的主要功能

  • 断点设置:在特定的代码行或函数处设置断点,控制程序的执行流程。
  • 变量查看与修改:在运行时查看和修改变量的值,包括基本类型、结构体、类和数组等。
  • 内存查看:检查和修改内存内容,帮助理解程序的数据布局。
  • 线程和进程控制:管理线程和进程的执行状态,如暂停、继续、切换线程和终止进程。
  • 表达式计算:在调试环境中计算复杂的表达式,支持多种编程语言的语法。
  • 堆栈回溯:查看函数调用栈,追踪代码执行路径。
  • 插件支持:通过插件系统扩展LLDB的功能,以满足特定的调试需求。
  • 脚本编写:使用Python或Swift编写自定义调试脚本,自动化调试过程。

命令格式

<noun> <verb> [-option [option-value]] [argument [argument...]]
// [] 项为可选项
<命令> <子命令> [-选项 [选项值]] [参数 [参数值...]]

原始(raw)命令

LLDB支持不带命令选项(options)的原始(raw)命令,原始命令会将命令后面的所有东西当做参数(arguement)传递。不过很多原始命令也可以带命令选项,当你使用命令选项的时候,需要区分命令选项和参数。

常用的 expression 就是 raw 命令,一般情况下我们使用 expression 打印一个东西是这样的:

这里写图片描述

选项终止符: –

「选项」可以放在命令行的任何位置,但是如果参数以“-”开头,则必须通过添加选项终止符--来告诉 LLDB 你已经完成了当前命令的选项。

// 选项: -stop-at-entry, 参数:-program_arg
process launch --stop-at-entry -- -program_arg value

当我们想用 expression 打印一个对象的时候。需要使用 -O 命令选项,我们应该用 – 将命令选项和参数区分:

这里写图片描述

该命令可以简写为 po。

LLDB 中的变量

在 LLDB 中定义变量时,需要在变量前面添加$符号。定义好变量后就可以像平常一样使用变量,调用方法。方法调用时,LLDB 无法确定返回值的类型,需要自己指定。

// 定义变量array
(lldb) e NSArray *$array = @[@"I", @"love", @"LLDB"]
  
(lldb) po $array
<__NSArrayI 0x600000ffdb00>(
I,
love,
LLDB
)
  
// 调用方法
(lldb) po [$array count]
3
(lldb) po [[$array objectAtIndex:1] uppercaseString]
LOVE

(lldb) e int $b = 0
(lldb) po $b
0

// 不指定返回值
(lldb) po [[$array objectAtIndex:$b] characterAtIndex:0]
0x0000000000000049

// 指定返回值
(lldb) po (char)[[$array objectAtIndex:$b] characterAtIndex:0]
'I'

唯一匹配原则

LLDB的命令遵循唯一匹配原则:假如根据前n个字母已经能唯一匹配到某个命令,则只写前n个字母等效于写下完整的命令。利用该规则,可以简写一些命令。

help

好记性不如 help 命令。和平常的 pod --help ruby --help 不一样,LLDB help 本身是一个命令而不是一个选项,它可以告诉你关于某个命令(包括 help 命令)的一切信息。

(lldb) help
Debugger commands:
  apropos           -- List debugger commands related to a word or subject.
  breakpoint        -- Commands for operating on breakpoints (see 'help b' for
                       shorthand.)
  command           -- Commands for managing custom LLDB commands.
  disassemble       -- Disassemble specified instructions in the current
                       target.  Defaults to the current function for the
                       current thread and stack frame.
  dwim-print        -- Print a variable or expression.
  expression        -- Evaluate an expression on the current thread.  Displays
                       any returned value with LLDB's default formatting.
  frame             -- Commands for selecting and examing the current thread's
                       stack frames.
  gdb-remote        -- Connect to a process via remote GDB server.
                       If no host is specifed, localhost is assumed.
                       gdb-remote is an abbreviation for 'process connect
                       --plugin gdb-remote connect://<hostname>:<port>'
  gui               -- Switch into the curses based GUI mode.
  help              -- Show a list of all debugger commands, or give details
                       about a specific command.
  kdp-remote        -- Connect to a process via remote KDP server.
                       If no UDP port is specified, port 41139 is
                       assumed.
                       kdp-remote is an abbreviation for 'process connect
                       --plugin kdp-remote udp://<hostname>:<port>'
  language          -- Commands specific to a source language.
  log               -- Commands controlling LLDB internal logging.
  memory            -- Commands for operating on memory in the current target
                       process.
  platform          -- Commands to manage and create platforms.
  plugin            -- Commands for managing LLDB plugins.
  process           -- Commands for interacting with processes on the current
                       platform.
  quit              -- Quit the LLDB debugger.
  register          -- Commands to access registers for the current thread and
                       stack frame.
  script            -- Invoke the script interpreter with provided code and
                       display any results.  Start the interactive interpreter
                       if no code is supplied.
  session           -- Commands controlling LLDB session.
  settings          -- Commands for managing LLDB settings.
  source            -- Commands for examining source code described by debug
                       information for the current target process.
  statistics        -- Print statistics about a debugging session
  swift-healthcheck -- Provides logging related to the Swift expression
                       evaluator, including Swift compiler diagnostics. This
                       makes it easier to identify project misconfigurations
                       that result in module import failures in the debugger.
                       The command is meant to be run after a expression
                       evaluator failure has occurred.
  target            -- Commands for operating on debugger targets.
  thread            -- Commands for operating on one or more threads in the
                       current process.
  trace             -- Commands for loading and using processor trace
                       information.
  type              -- Commands for operating on the type system.
  version           -- Show the LLDB debugger version.
  watchpoint        -- Commands for operating on watchpoints.
Current command abbreviations (type 'help command alias' for more info):
  add-dsym  -- Add a debug symbol file to one of the target's current modules
               by specifying a path to a debug symbols file or by using the
               options to specify a module.
  attach    -- Attach to process by ID or name.
  b         -- Set a breakpoint using one of several shorthand formats.
  bt        -- Show the current thread's call stack.  Any numeric argument
               displays at most that many frames.  The argument 'all' displays
               all threads.
  c         -- Continue execution of all threads in the current process.
  call      -- Evaluate an expression on the current thread.  Displays any
               returned value with LLDB's default formatting.
  continue  -- Continue execution of all threads in the current process.
  detach    -- Detach from the current target process.
  di        -- Disassemble specified instructions in the current target. 
               Defaults to the current function for the current thread and
               stack frame.
  dis       -- Disassemble specified instructions in the current target. 
               Defaults to the current function for the current thread and
               stack frame.
  display   -- Evaluate an expression at every stop (see 'help target
               stop-hook'.)
  down      -- Select a newer stack frame.  Defaults to moving one frame, a
               numeric argument can specify an arbitrary number.
  env       -- Shorthand for viewing and setting environment variables.
  exit      -- Quit the LLDB debugger.
  f         -- Select the current stack frame by index from within the current
               thread (see 'thread backtrace'.)
  file      -- Create a target using the argument as the main executable.
  finish    -- Finish executing the current stack frame and stop after
               returning.  Defaults to current thread unless specified.
  history   -- Dump the history of commands in this session.
               Commands in the history list can be run again using "!<INDEX>". 
               "!-<OFFSET>" will re-run the command that is <OFFSET> commands
               from the end of the list (counting the current command).
  image     -- Commands for accessing information for one or more target
               modules.
  j         -- Set the program counter to a new address.
  jump      -- Set the program counter to a new address.
  kill      -- Terminate the current target process.
  l         -- List relevant source code using one of several shorthand formats.
  list      -- List relevant source code using one of several shorthand formats.
  n         -- Source level single step, stepping over calls.  Defaults to
               current thread unless specified.
  next      -- Source level single step, stepping over calls.  Defaults to
               current thread unless specified.
  nexti     -- Instruction level single step, stepping over calls.  Defaults to
               current thread unless specified.
  ni        -- Instruction level single step, stepping over calls.  Defaults to
               current thread unless specified.
  p         -- Print a variable or expression.
  parray    -- parray <COUNT> <EXPRESSION> -- lldb will evaluate EXPRESSION to
               get a typed-pointer-to-an-array in memory, and will display
               COUNT elements of that type from the array.
  po        -- Evaluate an expression on the current thread.  Displays any
               returned value with formatting controlled by the type's author.
  poarray   -- poarray <COUNT> <EXPRESSION> -- lldb will evaluate EXPRESSION to
               get the address of an array of COUNT objects in memory, and will
               call po on them.
  print     -- Print a variable or expression.
  q         -- Quit the LLDB debugger.
  r         -- Launch the executable in the debugger.
  rbreak    -- Sets a breakpoint or set of breakpoints in the executable.
  re        -- Commands to access registers for the current thread and stack
               frame.
  repl      -- Evaluate an expression on the current thread.  Displays any
               returned value with LLDB's default formatting.
  run       -- Launch the executable in the debugger.
  s         -- Source level single step, stepping into calls.  Defaults to
               current thread unless specified.
  shell     -- Run a shell command on the host.
  si        -- Instruction level single step, stepping into calls.  Defaults to
               current thread unless specified.
  sif       -- Step through the current block, stopping if you step directly
               into a function whose name matches the TargetFunctionName.
  step      -- Source level single step, stepping into calls.  Defaults to
               current thread unless specified.
  stepi     -- Instruction level single step, stepping into calls.  Defaults to
               current thread unless specified.
  t         -- Change the currently selected thread.
  tbreak    -- Set a one-shot breakpoint using one of several shorthand formats.
  undisplay -- Stop displaying expression at every stop (specified by stop-hook
               index.)
  up        -- Select an older stack frame.  Defaults to moving one frame, a
               numeric argument can specify an arbitrary number.
  v         -- Show variables for the current stack frame. Defaults to all
               arguments and local variables in scope. Names of argument,
               local, file static and file global variables can be specified.
  var       -- Show variables for the current stack frame. Defaults to all
               arguments and local variables in scope. Names of argument,
               local, file static and file global variables can be specified.
  vo        -- Show variables for the current stack frame. Defaults to all
               arguments and local variables in scope. Names of argument,
               local, file static and file global variables can be specified.
  x         -- Read from the memory of the current target process.
For more information on any command, type 'help <command-name>'.

expression

expression 命令的作用是执行一个表达式,并将表达式返回的结果输出。

  1. 执行某个表达式。 我们在代码运行过程中,可以通过执行某个表达式来动态改变程序运行的轨迹。 假如我们在运行过程中,突然想把 self.view 颜色改成红色,看看效果。我们不必写下代码,重新 run,只需暂停程序,用 expression 改变颜色,再刷新一下界面,就能看到效果。
(lldb) expression -- self.view.backgroundColor = [UIColor purpleColor];
(lldb) expression -- (void)[CAtransaction flush]
  1. 将返回值输出。 也就是说我们可以通过 expression 来打印东西。 假如我们想打印 self.view:
(lldb) expression -- self.view

print、call、po

一般情况下,我们直接用 expression 还是用得比较少的,更多时候我们用的是 print、call、po。这三个命令其实都是 expression 命令,执行某个表达式,并将执行的结果输出到控制台上。常用来动态调用方法,动态修改变量。

// 调用 description 进行打印
'call' is an abbreviation for 'expression --'
'print' is an abbreviation for 'expression --'

下面代码效果相同:

这里写图片描述

根据唯一匹配原则,如果你没有自己添加特殊的命令别名。e 也可以表示 expression 的意思,p 和 print 等价。

上面打印的都是指针,而不是对象本身。如果我们想打印对象,需要使用到命令选项:-O。为了更方便的使用,LLDB 为 expression -O 定义了一个别名:po。

// 调用 description 进行打印
'po' is an abbreviation for 'expression -O  --'

使用 po 指令动态修改变量:

// 背景颜色为 red
(lldb) po [self.view backgroundColor]
UIExtendedSRGBColorSpace 1 0 0 1
// 修改背景颜色为blue
(lldb) po [self.view setBackgroundColor:[UIColor blueColor]]
UICachedDeviceRGBColor
// 背景颜色发生改变
(lldb) po [self.view backgroundColor]
UIExtendedSRGBColorSpace 0 0 1 1
// 不用继续运行程序,马上进行渲染,模拟器/真机上也发生改变
(lldb) po [CATransaction flush]

控制流程:continue、next、step、finish

img

上图为 Xcode 里面的控制按键,其实都是与 LLDB 命令对应的,从左至右分别为:

  1. continue 按钮, 对应命令 process continue(简写 continuec),会取消程序的暂停,允许程序正常执行。
  2. step over 按钮,对应命令 thread step-over(简写 nextn),会以黑盒的方式执行一行代码。如果所在这行代码是一个函数调用,不会跳进这个函数,而是会执行这个函数,然后继续。
  3. step in 按钮,对应命令 thread step-in(简写 steps),如果所在这行代码是一个函数调用,会跳进这个函数,可用来调试或检查函数调用。当前行不是函数调用时,next 和 step 效果是一样的。
  4. step out 按钮,对应命令 thread step-out(简写 finish )。如果你不小心跳进一个函数,但实际上你想跳过它,可以用该命令跳出函数。

register read / write

寄存器指令,用来查看或修改系统库函数调用参数和返回值,寄存器与 CPU 架构有关。

(lldb) register read
General Purpose Registers:
        x0 = 0x000000010140a590
        x1 = 0x000000016f0ef2b0
        x2 = 0x0000000000000001
        x3 = 0x000000016f0ef578
        x4 = 0x0000000000000010
        x5 = 0x0000000000000620
        x6 = 0x0000000280ecc620
        x7 = 0x0000000000000000
        x8 = 0x0000000100d29000  (void *)0x0000000800000003
        x9 = 0x0000000201644dc0  dyld`_main_thread
       x10 = 0x0000000000000002
       x11 = 0x0000000101414488
       x12 = 0x0000000000000002
       x13 = 0x0000000000000000
       x14 = 0x0000000249680000
       x15 = 0x00000001a954f065  UIKitCore`_OBJC_$_INSTANCE_METHODS_UIViewController(UIAlertControllerContentViewController|UIResponderChainTraversal|UIActionSheetPresentationControllerAccess|UIImagePickerControllerAdditions|PLImagePickerViewControllerInterface|ForHomeOnly|UIPopoverController_Internal|_UIMultiColumnViewController|_UIKitIsUIViewController|UIPerformsActions|UITabBarControllerItem|UISplitViewController|BinaryCompatibility|UINavigationControllerItemInternal|UINavigationControllerItem|UINavigationControllerContextualToolbar|UINavigationControllerContextToolbar_Internal|UIContainerViewControllerProtectedMethods|UIContainerViewControllerCallbacks|UIContainerViewControllerCallbacks_Internal|StateRestoration_Internal|StateRestoration|ActivityContinuationPrivate|ActivityContinuationInternal|ActivityContinuation|EmbeddedViewSupport|UIFirstResponderSupport|UICollectionViewControllerSupport|UIViewControllerTransitioning|AdaptiveSizing|AdaptiveSizing_Internal|UIViewControllerClassDumpWarning|UIKeyCommand|ForUISplitViewController|AccessibilityHUD|OrientationDebugging|NSExtensionAdditionsInternal|NSExtensionAdditions|_UIApplicationRotationFollowing|_UIAlwaysOnEnvironment|_UIFallbackEnvironment|UnwindSegueSupport|_UISheetPresentationController|ViewServices|ViewService_Internal|ViewService_StateRestoration) + 1965
       x16 = 0x00000001a8861570  UIKitCore`-[UIViewController viewDidLoad]
       x17 = 0x0000000100e1dd4c  libMainThreadChecker.dylib`__trampolines + 18880
       x18 = 0x0000000000000000
       x19 = 0x000000010140ada0
       x20 = 0x000000010140a590
       x21 = 0x00000002016bb000  UIKitCore`UIKeyboardCachedIsRightHandDrive
       x22 = 0x0000000000000000
       x23 = 0x0000000000000000
       x24 = 0x0000000000000018
       x25 = 0x0000000000000000
       x26 = 0x0000000000000000
       x27 = 0x0000000000000460
       x28 = 0x0000000201694000  UIKitCore`_MergedGlobals + 4
        fp = 0x000000016f0ef410
        lr = 0x0000000100d10644  Landmarks`-[ViewController viewDidLoad] + 100 at ViewController.m:20:5
        sp = 0x000000016f0eed10
        pc = 0x0000000100d10648  Landmarks`-[ViewController viewDidLoad] + 104 at ViewController.m:23:6
      cpsr = 0x60000000

thread backtrace

有时候我们想要了解线程堆栈信息,可以使用 thread backtrace(简写为 bt),它的作用是将线程的堆栈打印出来。

这里写图片描述

thread return

thread return 可以接受一个表达式,调用命令之后直接从当前的 frame 返回表达式的值。

这里写图片描述

效果相当于在断点位置直接调用 return NO;,不会执行断点后面的代码。

frame 相关命令

  • frame variable:打印出当前 frame 的所有变量。

  • frame info:查看当前 frame 的信息。

  • frame select:选择某个 frame。

breakpoint

调试过程中,我们用得最多的可能就是断点了。LLDB 中的断点命令也非常强大。

设置断点

breakpoint set 命令用于设置断点,LLDB 提供了很多种设置断点的方式。

使用 -n 根据方法名设置断点:

// 给所有类中的 viewWillAppear: 设置一个断点
(lldb) breakpoint set -n viewWillAppear:

设置好断点后,会为该断点生成一个编号(id),从 1 开始递增。

使用 -f 指定文件:

// 给所有类中的 viewWillAppear: 设置一个断点
(lldb) breakpoint set -f ViewController.m -n viewDidLoad

使用 -l 指定文件某一行设置断点:

// 给 ViewController.m 第 38 行设置断点
(lldb) breakpoint set -f ViewController.m -l 38

使用 -c 设置条件断点:

//  text: 方法接受一个 ret 的参数,我们想让 ret == YES 的时候程序中断
(lldb) breakpoint set -n text: -c ret == YES

使用 -o 设置单次断点:

// 如果刚刚那个断点我们只想让它中断一次
(lldb) breakpoint set -n text: -o

管理断点

  • breakpoint list:查看已经设置了哪些断点。
  • breakpoint disable x:使 id 为 x 的断点暂时失效。
  • breakpoint enable x:使 id 为 x 的断点生效。
  • breakpoint delete x:删除 d 为 x 的断点。

断点命令

breakpoint command add 命令就是给断点添加命令的命令。

假设我们需要在 ViewController 的 viewDidLoad 中查看 self.view 的值,我们首先给 -[ViewController viewDidLoad] 添加一个断点。添加成功之后,这个断点的 id 为 3,然后我们给它增加一个命令:po self.view:

这里写图片描述

-o 完整写法是 –one-liner,表示增加一条命令。添加完命令之后,每次程序执行到这个断点就可以自动打印出 self.view 的值了。

如果我们想增加多条命令,我们可以输入 breakpoint command add 3,对断点 3 增加命令,输入 DONE 表示结束:

这里写图片描述

如果想查看某个断点已有的命令,可以使用 breakpoint command list。

// 查看 id 为 3 的断点已有的命令
breakpoint command list 3

breakpoint command delete 可以让我们删除某个断点的命令:

// 删除 id 为 3 的断点的所有命令
breakpoint command delete 3

watchpoint

breakpoint 有一个孪生兄弟 watchpoint。如果说 breakpoint 是对方法生效的断点,watchpoint 就是对地址生效的断点。我们可以用 watchpoint 观察这个属性的地址。如果地址里面的东西改变了,就让程序中断。

和 breakpoint 一样,watchpoint 也有 id。失效、生效、删除的语法也和 breakpoint 一致。

watchpoint set 命令用于添加一个 watchpoint。只要这个地址中的内容变化了,程序就会中断。一般情况下,要观察变量或者属性,使用 watchpoint set variable 命令即可:

// 观察 self->_string
watchpoint set variable self->_string

watchpoint set variable 传入的是变量名。需要注意的是,这里不接受方法,所以不能使用watchpoint set variable self.string,因为 self.string 调用的是 _string 的取方法。

给 watchpoint 添加命令的方法,和 breakpoint 完全一致,这里就不赘述了。

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

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

相关文章

基于weixin小程序新生报到系统的设计

管理员账户功能包括&#xff1a;系统首页&#xff0c;个人中心&#xff0c;学生管理&#xff0c;班级信息管理&#xff0c;师资力量管理&#xff0c;宿舍信息管理&#xff0c;宿舍安排管理&#xff0c;签到信息管理&#xff0c;论坛管理 小程序功能包括&#xff1a;系统首页&am…

考研数学一有多难?130+背后的残酷真相

考研数学一很难 大家平时在网上上看到很多人说自己考了130&#xff0c;其实这些人只占参加考研数学人数的极少部分&#xff0c;有个数据可以展示出来考研数学到底有多难&#xff1a; 在几百万考研大军中&#xff0c;能考到120分以上的考生只有2%。绝大多数人的分数集中在30到…

【MySQL进阶之路 | 高级篇】MySQL8.0索引新特性->降序索引与隐藏索引

1. 支持降序索引 降序索引以降序存储键值.虽然在语法上&#xff0c;从MySQL4版本已经支持降序索引的语法了&#xff0c;但实际上该DESC定义是被忽略的.知道MySQL8.x版本才开始真正支持降序索引.(仅限于InnoDB存储引擎). MySQL在8.0版本前创建的仍然是升序索引&#xff0c;使用…

【C++11(二)】lambda表达式和可变参数模板

一、可变参数模板 C11的新特性可变参数模板 能够让您创建可以接受 可变参数的函数模板和类模板 // Args是一个模板参数包&#xff0c;args是一个函数形参参数包 // 声明一个参数包Args...args&#xff0c;这个参数包中可以包含0到任意个模板参数。 template <class ...Arg…

vue3 使用JsMind的方法,以及引入提示报错,无法找到模块“jsmind”的声明文件

最终结果&#xff1a; 一、使用&#xff1a;使用yarn或者npm 安装 yarn add jsmind npm install vue-jsmind 二、引入 两种方法&#xff1a;&#xff08;如果这样引入没问题按照这样引入&#xff09; import "jsmind/style/jsmind.css"; import JsMind from &quo…

【SSM】医疗健康平台-用户端-体检预约

知识目标 了解FreeMarker&#xff0c;能够简述FreeMarker的作用和生成文件的原理 熟悉FreeMarker的常用指令&#xff0c;能够在FTL标签中正确使用assign指令、include指令、if指令和list指令 掌握显示套餐列表功能的实现 掌握显示套餐详情功能的实现 掌握体检预约功能的实现…

nodejs——ejs模版遇到原型链污染产生rce

[GYCTF2020]Ez_Express 打开是一个登陆框 在源代码中找到 在代码里找到敏感关键字 找到merge 想到原型链污染 这里登陆只能用ADMIN才能登陆成功 但是这里index.php又设置了一个waf ban了admin的大小写 这里需要绕过这个waf 看注册这段代码 用的是这个toUpperCase()函数 之前…

【深度强化学习】如何使用多进程(multiprocessing、pipe)来加速训练

文章目录 实验结果实现思路思路1思路2 进程与线程介绍如何实现multiprocessing、Pipe的范例关于时间对比上的问题代码修改收敛为何不稳定 技巧进程资源抢占问题线程问题cpu和gpu问题 进阶&#xff08;还没看懂/还没实验&#xff09;附代码raw代码mul代码 实验结果 实验平台&am…

natsort 自然排序

1、安装 pip install natsort 2、为什么使用natsort 而不是sorted 在python中只需要调用sorted函数就可以了&#xff0c;但是这个函数有一个缺点&#xff0c;就是它是按照从第一位开始的顺序排列的。意思是&#xff1a; wav_file [1.wav, 13.wav, 9.wav, 2.wav,"23.wav…

Golang | Leetcode Golang题解之第198题打家劫舍

题目&#xff1a; 题解&#xff1a; func rob(nums []int) int {if len(nums) 0 {return 0}if len(nums) 1 {return nums[0]}first : nums[0]second : max(nums[0], nums[1])for i : 2; i < len(nums); i {first, second second, max(first nums[i], second)}return se…

图形编辑器基于Paper.js教程04: Paper.js中的基础知识

背景 了解paper.js的基础知识&#xff0c;在往后的开发过程中会让你如履平地。 基础知识 paper.js 提供了两种编写方式&#xff0c;一种是纯粹的JavaScript编写&#xff0c;还有一种是使用官方提供的PaperScript。 区别就是在于&#xff0c;调用paper下的字对象是否需要加pa…

Linux核心基础详解(第13天)

系列文章目录 一、Linux基础详解&#xff0c; 二、网编三要素和SSH原理 三、shell编程&#xff08;补充&#xff09; 文章目录 系列文章目录前言一、linux简介二、虚拟机简介1、设置VMware网卡1.1 修改VMware中网络1.2 修改本地net8网卡ip 2、安装命令版裸机3、安装centos操作…

Elasticsearch:使用 Llamaindex 的 RAG 与 Elastic 和 Llama3

这篇文章是对之前的文章 “使用 Llama 3 开源和 Elastic 构建 RAG” 的一个补充。我们可以在本地部署 Elasticsearch&#xff0c;并进行展示。我们将一步一步地来进行配置并展示。你还可以参考我之前的另外一篇文章 “Elasticsearch&#xff1a;使用在本地计算机上运行的 LLM 以…

【MySQL】 -- 事务

如果对表中的数据进行CRUD操作时&#xff0c;不加控制&#xff0c;会带来一些问题。 比如下面这种场景&#xff1a; 有一个tickets表&#xff0c;这个数据库被两个客户端机器A和B用时连接对此表进行操作。客户端A检查tickets表中还有一张票的时候&#xff0c;将票出售了&#x…

DOM遍历

DOM 遍历是指在 HTML 文档中导航和定位元素的过程。通过 DOM 遍历&#xff0c;您可以在文档中移动并查找特定的元素&#xff0c;以便对其进行操作或者检索信息。 寻找子元素 //DOM遍历 const h1 document.querySelector(h1);//寻找子元素 console.log(h1.querySelectorAll(.…

华为鸿蒙正式杀入工业自动化,反攻开始了!

导语 大家好&#xff0c;我是社长&#xff0c;老K。专注分享智能制造和智能仓储物流等内容。 新书《智能物流系统构成与技术实践》 在近日举行的2024华为开发者大会上&#xff0c;华龙讯达与华为共同发布了基于鸿蒙内核技术的“HualongOS 华龙工业操作系统”&#xff0c;这一里…

运维.Linux下执行定时任务(上:Cron简介与用法解析)

运维专题 Linux下执行定时任务&#xff08;上&#xff1a;Cron简介与用法解析&#xff09; - 文章信息 - Author: 李俊才 (jcLee95) Visit me at CSDN: https://jclee95.blog.csdn.netMy WebSite&#xff1a;http://thispage.tech/Email: 291148484163.com. Shenzhen ChinaAd…

基于飞腾腾云S2500的ATS部署及调优指南(反向代理篇)

【写在前面】 飞腾开发者平台是基于飞腾自身强大的技术基础和开放能力&#xff0c;聚合行业内优秀资源而打造的。该平台覆盖了操作系统、算法、数据库、安全、平台工具、虚拟化、存储、网络、固件等多个前沿技术领域&#xff0c;包含了应用使能套件、软件仓库、软件支持、软件适…

TensorRt(6)yolov3.weight转换、onnx_graphsurgeon和c++ api实现添加NMS

前面博文 【opencv dnn模块 示例(3) 目标检测 object_detection (2) YOLO object detection】 介绍了 使用opencv dnn模块加载yolo weights格式模型的详细说明。 又在博文 【TensorRt&#xff08;4&#xff09;yolov3加载测试】 说明了如何将onnx编译为tensorrt格式并使用的方式…

[论文笔记]Mixture-of-Agents Enhances Large Language Model Capabilities

引言 今天带来一篇多智能体的论文笔记&#xff0c;Mixture-of-Agents Enhances Large Language Model Capabilities。 随着LLMs数量的增加&#xff0c;如何利用多个LLMs的集体专业知识是一个令人兴奋的开放方向。为了实现这个目标&#xff0c;作者提出了一种新的方法&#xf…