Token导航 LogoToken导航

Agent Skill · 研究检索

debugging-instruments(调试仪器)

debugging-instruments 用于查找、检索和筛选相关信息,适合在 Codex、Claude、Cursor、Gemini CLI 中需要根据关键词、任务场景或来源线索快速定位候选结果时使用。可结合来源仓库、安装命令和原始 README 继续核验具体用法。安装前建议确认权限范围、维护状态,以及是否会触发联网、命令执行或文件读写。

debugging-instruments 是研究检索类 Agent Skill,可用宿主为 Codex、Claude、Cursor、Gemini CLI,通过GitHub 仓库获取,权限为需要联网;许可证信息还不明确,第三方扫描已通过,按安装量在研究检索类的 73,675 个 Skill 里排第 5,236。

总安装 26,928周安装 1,122GitHub Stars 523下载 8,712核验 2026-05-01

安装说明

本站只整理中文说明,不托管安装包,也不代用户安装。
GitHub
许可证
unknown

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:debugging-instruments(调试仪器)
来源仓库:https://github.com/dpearson2699/swift-ios-skills
仓库路径:skills/debugging-instruments
安装命令:
npx skills add https://github.com/dpearson2699/swift-ios-skills --skill debugging-instruments
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。该命令会通过 npx skills 从第三方来源获取 Skill;本站只展示命令,不托管安装包,也不自动执行。

skills.shnpx skills
npx skills add https://github.com/dpearson2699/swift-ios-skills --skill debugging-instruments

这个 Skill 是做什么的

研究检索类 Skill 主要解决「找资料、核对事实、把来源整理清楚」的问题,通常会让助手先检索再总结。

该技能提供 iOS 应用调试工具使用指南,涵盖 LLDB、内存分析器和性能检测。适用于需要诊断崩溃、内存泄漏或主线程阻塞等问题的开发场景。通过 GitHub 仓库安装,需确认本地环境是否支持相关调试工具链。建议先验证项目是否使用 Swift/Objective-C 及 Xcode 版本兼容性。

debugging-instruments 属于研究检索类 Skill,可作为该场景下的辅助能力补充。

来源仓库内路径:skills/debugging-instruments

上手步骤

4 步
  1. 1

    确认自己的宿主工具

    公开资料标注支持 Codex、Claude、Cursor、Gemini CLI;先确认自己用的是其中之一,再按对应工具的 Skills 目录放置。

  2. 2

    拿到安装命令

    可以直接复制的命令是 npx skills add https://github.com/dpearson2699/swift-ios-skills --skill debuggin…;命令里的占位符换成自己的路径或密钥再执行。

  3. 3

    安装后重启宿主

    命令执行完要完全退出宿主工具再打开,让新装的 Skill 被重新扫描到,否则列表里可能看不到。

  4. 4

    按最小权限试用

    它需要需要联网,先在测试目录或测试账号里跑,确认没问题再放到正式项目。

常见问题

6 条

debugging-instruments 怎么安装?

在终端执行 npx skills add https://github.com/dpearson2699/swift-ios-skills --skill debugging-instrume…。装完完全退出宿主工具再打开,让它重新扫描本地 Skill。

debugging-instruments 支持哪些 AI 工具?

公开资料标注支持 Codex、Claude、Cursor、Gemini CLI。其他工具只要能读取本地 Skill 目录,一般也能手动放进去,但要自己确认触发方式是否一致。

debugging-instruments 需要什么权限?

权限级别是需要联网。该 Skill 可能需要联网访问来源站点、仓库或外部 API;具体网络访问范围需要结合源码和 README 复核。

debugging-instruments 是免费的吗?

公开资料没有标注明确许可证,收费和商用限制都无法确认。正式使用前请到来源仓库核对授权说明。

debugging-instruments 用的人多吗?

公开数据是累计安装 26,928 次,近一周安装 1,122 次,下载 8,712 次,GitHub 523 星。这些数字来自第三方目录统计,只能当作热度参考,不代表质量或安全性。

debugging-instruments 安全吗?

第三方扫描结果为通过,但这只覆盖已知的静态检查项,不能替代自己读一遍源码和安装命令。

值得选的地方和要先想清楚的地方

值得选的地方

  • 同时适配 4 种工具,换客户端不用重新找替代品。
  • 第三方扫描已通过,常见的高风险行为没有命中。

先想清楚的地方

  • 许可证没有明确标注,能不能商用、能不能再分发都不确定。
  • 第三方目录整理,版本更新和行为细节以来源仓库为准。

适不适合你

更适合

  • 已经在用 Codex,想直接扩展它能力的人。
  • 需要处理研究检索类任务、又不想每次都手写提示词的人。

不太适合

  • 需要明确授权才能用到公司项目里的场景。
  • 需要厂商级技术支持和 SLA 的生产系统。

研究检索类 Skill 对比

6 个同类
Skill总安装GitHub 星权限许可证扫描
find-skills

寻找技能 · Codex、Claude

31,199,81316,486操作浏览器MIT有提醒
self-improving-agent

自我改进 Agent · OpenClaw

16,464,0023,396接触敏感数据MIT-0通过
soultrace

灵魂追踪 · Codex、Claude

7,588,94412需要联网未明确有提醒
self-improving

自我完善 · OpenClaw

6,829,2841,046需要联网MIT-0通过
microsoft-foundry

微软代工厂 · Codex、Claude

6,614,144764调用外部服务未明确有提醒
debugging-instruments

调试仪器 · 本页

26,928523需要联网未明确通过

按安装量取同分类前几名;数字来自第三方目录统计,只作热度参考,不代表质量结论。

SKILL.md 原文

Debugging and Instruments

Diagnose crashes, memory leaks, retain cycles, main thread hangs, and performance bottlenecks in iOS apps using LLDB, Memory Graph Debugger, and Instruments. Covers breakpoint workflows, memory graph analysis, hang detection, build failure triage, and Instruments profiling for CPU, memory, energy, and network.

Contents

LLDB Debugging

Essential Commands

(lldb) po myObject              # Print object description (calls debugDescription)
(lldb) p myInt                  # Print with type info (uses LLDB formatter)
(lldb) v myLocal                # Frame variable — fast, no code execution
(lldb) bt                       # Backtrace current thread
(lldb) bt all                   # Backtrace all threads
(lldb) frame select 3           # Jump to frame #3 in the backtrace
(lldb) thread list              # List all threads and their states
(lldb) thread select 4          # Switch to thread #4

Use v over po when you only need a local variable value — it does not execute code and cannot trigger side effects.

Breakpoint Management

(lldb) br set -f ViewModel.swift -l 42          # Break at file:line
(lldb) br set -n viewDidLoad                     # Break on function name
(lldb) br set -S setValue:forKey:                 # Break on ObjC selector
(lldb) br modify 1 -c "count > 10"              # Add condition to breakpoint 1
(lldb) br modify 1 --auto-continue true          # Log and continue (logpoint)
(lldb) br command add 1                          # Attach commands to breakpoint
> po self.title
> continue
> DONE
(lldb) br disable 1                              # Disable without deleting
(lldb) br delete 1                               # Remove breakpoint

Expression Evaluation

(lldb) expr myArray.count                        # Evaluate Swift expression
(lldb) e -l swift -- import UIKit                # Import framework in LLDB
(lldb) e -l swift -- self.view.backgroundColor = .red  # Modify state at runtime
(lldb) e -l objc -- (void)[CATransaction flush]  # Force UI update after changes

After modifying a view property in the debugger, call CATransaction.flush() to see the change immediately without resuming execution.

Watchpoints

(lldb) w set v self.score                        # Break when score changes
(lldb) w set v self.score -w read               # Break when score is read
(lldb) w modify 1 -c "self.score > 100"         # Conditional watchpoint
(lldb) w list                                    # Show active watchpoints
(lldb) w delete 1                                # Remove watchpoint

Watchpoints are hardware-backed (limited to ~4 on ARM). Use them to find unexpected mutations — the debugger stops at the exact line that changes the value.

Symbolic Breakpoints

Set breakpoints on methods without knowing the file. Useful for framework or system code:

(lldb) br set -n "UIViewController.viewDidLoad"
(lldb) br set -r ".*networkError.*"              # Regex on symbol name
(lldb) br set -n malloc_error_break              # Catch malloc corruption
(lldb) br set -n UIViewAlertForUnsatisfiableConstraints  # Auto Layout issues

In Xcode, use the Breakpoint Navigator (+) to add symbolic breakpoints for common diagnostics like -[UIApplication main] or swift_willThrow.

Memory Debugging

Memory Graph Debugger Workflow

  1. Run the app in Debug configuration.
  2. Reproduce the suspected leak (navigate to a screen, then back).
  3. Tap the Memory Graph button in Xcode's debug bar.
  4. Look for purple warning icons — these indicate leaked objects.
  5. Select a leaked object to see its reference graph and backtrace.

Enable Malloc Stack Logging (Scheme > Diagnostics) before running so the Memory Graph shows allocation backtraces.

Common Retain Cycle Patterns

Closure capturing self strongly:

// LEAK — closure holds strong reference to self
class ProfileViewModel {
    var onUpdate: (() -> Void)?

    func startObserving() {
        onUpdate = {
            self.refresh()  // strong capture of self
        }
    }
}

// FIXED — use [weak self]
func startObserving() {
    onUpdate = { [weak self] in
        self?.refresh()
    }
}

Strong delegate reference:

// LEAK — strong delegate creates a cycle
protocol DataDelegate: AnyObject {
    func didUpdate()
}

class DataManager {
    var delegate: DataDelegate?  // should be weak
}

// FIXED — weak delegate
class DataManager {
    weak var delegate: DataDelegate?
}

Timer retaining target:

// LEAK — Timer.scheduledTimer retains its target
timer = Timer.scheduledTimer(
    timeInterval: 1.0, target: self,
    selector: #selector(tick), userInfo: nil, repeats: true
)

// FIXED — use closure-based API with [weak self]
timer = Timer.scheduledTimer(withTimeInterval: 1.0, repeats: true) { [weak self] _ in
    self?.tick()
}

Instruments: Allocations and Leaks

  • Allocations template: Track memory growth over time. Use the "Mark Generation" feature to isolate allocations created between user actions (e.g., open/close a screen).
  • Leaks template: Automatically detects reference cycles at runtime. Run alongside Allocations for a complete picture.
  • Filter by your app's module name to exclude system allocations.

Malloc Stack Logging

Enable in Scheme > Run > Diagnostics > Malloc Stack Logging (All Allocations). This records the call stack for every allocation, letting the Memory Graph Debugger and leaks CLI show where objects were created.

# CLI leak detection
leaks --atExit -- ./MyApp.app/MyApp
# Symbolicate with dSYMs for readable stacks

Hang Diagnostics

Identifying Main Thread Hangs

A hang occurs when the main thread is blocked for > 250ms (noticeable) or

1s (severe). Common detection tools:
  • Thread Checker (Xcode Diagnostics): warns about non-main-thread UI calls
  • os_signpost and OSSignposter: mark intervals for Instruments
  • MetricKit hang diagnostics: production hang detection (see metrickit skill for MXHangDiagnostic)
import os

let signposter = OSSignposter(subsystem: "com.example.app", category: "DataLoad")

func loadData() async {
    let state = signposter.beginInterval("loadData")
    let result = await fetchFromNetwork()
    signposter.endInterval("loadData", state)
    process(result)
}

Using the Time Profiler

  1. Product > Profile (Cmd+I) to launch Instruments.
  2. Select the Time Profiler template.
  3. Record while reproducing the slow interaction.
  4. Focus on the main thread — sort by "Weight" to find hot paths.
  5. Check "Hide System Libraries" to see only your code.
  6. Double-click a heavy frame to jump to source.

Common Hang Causes

CauseSymptomFix
Synchronous I/O on main threadNetwork/file reads block UIMove to Task {} or background actor
Lock contentionMain thread waiting on a lock held by background workUse actors or reduce lock scope
Layout thrashingRepeated layoutSubviews callsBatch layout changes, avoid forced layout
JSON parsing large payloadsUI freezes during data loadParse on a background thread
Synchronous image decodingScroll jank on image-heavy listsUse AsyncImage or decode off main thread

Build Failure Triage

Reading Compiler Diagnostics

  • Start from the first error — subsequent errors are often cascading.
  • Search for the error code (e.g., error: cannot convert) in the build log.
  • Use Report Navigator (Cmd+9) for the full build log with timestamps.

SPM Dependency Resolution

# Common: version conflict
error: Dependencies could not be resolved because root depends on 'Package' 1.0.0..<2.0.0

# Fix: check Package.resolved and update version ranges
# Reset package caches if needed:
rm -rf ~/Library/Caches/org.swift.swiftpm
rm -rf .build
swift package resolve

Module Not Found / Linker Errors

ErrorCheck
No such module 'Foo'Target membership, import paths, framework search paths
Undefined symbolLinking phase missing framework, wrong architecture
duplicate symbolTwo targets define same symbol; check for ObjC naming collisions

Build settings to inspect first:

  • FRAMEWORK_SEARCH_PATHS
  • OTHER_LDFLAGS
  • SWIFT_INCLUDE_PATHS
  • BUILD_LIBRARY_FOR_DISTRIBUTION (for XCFrameworks)

Instruments Overview

Template Selection Guide

TemplateUse When
Time ProfilerCPU is high, UI feels slow, need to find hot code paths
AllocationsMemory grows over time, need to track object lifetimes
LeaksSuspect retain cycles or abandoned objects
NetworkInspecting HTTP request/response timing and payloads
SwiftUIProfiling view body evaluations and update frequency
Core AnimationFrame drops, off-screen rendering, blending issues
Energy LogBattery drain, background energy impact
File ActivityExcessive disk I/O, slow file operations
System TraceThread scheduling, syscalls, virtual memory faults

xctrace CLI for CI Profiling

# Record a trace from the command line
xcrun xctrace record --device "My iPhone" \
    --template "Time Profiler" \
    --output profile.trace \
    --launch MyApp.app

# Export trace data as XML for automated analysis
xcrun xctrace export --input profile.trace --xpath '/trace-toc/run/data/table'

# List available templates
xcrun xctrace list templates

# List connected devices
xcrun xctrace list devices

Use xctrace in CI pipelines to catch performance regressions automatically. Compare exported metrics between builds.

Common Mistakes

DON'T: Use print() for debugging instead of os.Logger

print() output is not filterable, has no log levels, and is not automatically stripped from release builds. It pollutes the console and makes it impossible to isolate relevant output.

// WRONG — unstructured, not filterable, stays in release builds
print("user tapped button, state: \(viewModel.state)")
print("network response: \(data)")

// CORRECT — structured logging with Logger
import os

let logger = Logger(subsystem: "com.example.app", category: "UI")

logger.debug("Button tapped, state: \(viewModel.state, privacy: .public)")
logger.info("Network response received, bytes: \(data.count)")

Logger messages appear in Console.app with filtering by subsystem and category, and .debug messages are written to the in-memory log store only (not persisted to disk in release builds).

DON'T: Forget to enable Malloc Stack Logging before memory debugging

Without Malloc Stack Logging, the Memory Graph Debugger shows leaked objects but cannot display allocation backtraces, making it difficult to find the code that created them.

// WRONG — open Memory Graph without enabling Malloc Stack Logging
// Result: leaked objects visible but no allocation backtrace

// CORRECT — enable BEFORE running:
// Scheme > Run > Diagnostics > check "Malloc Stack Logging: All Allocations"
// Then run, reproduce the leak, and open Memory Graph

DON'T: Debug optimized code expecting full variable visibility

In Release (optimized) builds, the compiler may inline functions, eliminate variables, and reorder code. LLDB cannot display optimized-away values.

// WRONG — profiling with Debug build, debugging with Release build
// Debug builds: extra runtime checks distort perf measurements
// Release builds: variables show as "<optimized out>" in debugger

// CORRECT approach:
// Debugging: use Debug configuration (full symbols, no optimization)
// Profiling: use Release configuration (realistic performance)

DON'T: Stop on every loop iteration without conditional breakpoints

Breaking on every iteration wastes time and makes it hard to find the specific case you care about.

// WRONG — breakpoint on line inside loop, stops 10,000 times
for item in items {
    process(item)  // breakpoint here stops on EVERY item
}

// CORRECT — use a conditional breakpoint:
// (lldb) br set -f MyFile.swift -l 42 -c "item.id == targetID"
// Or in Xcode: right-click breakpoint > Edit > add Condition

DON'T: Ignore Thread Sanitizer warnings

Thread Sanitizer (TSan) warnings indicate data races that may only crash intermittently. They are real bugs, not false positives.

// WRONG — ignoring TSan warning about concurrent access
var cache: [String: Data] = [:]  // accessed from multiple threads

// CORRECT — protect shared mutable state
actor CacheActor {
    var cache: [String: Data] = [:]

    func get(_ key: String) -> Data? { cache[key] }
    func set(_ key: String, _ value: Data) { cache[key] = value }
}

Enable TSan: Scheme > Run > Diagnostics > Thread Sanitizer. Note: TSan cannot run simultaneously with Address Sanitizer.

Review Checklist

  • Using os.Logger instead of print() for diagnostic output
  • Malloc Stack Logging enabled before memory debugging sessions
  • Memory Graph Debugger checked after dismiss/dealloc flows
  • Delegates declared as weak var to prevent retain cycles
  • Closures stored as properties use [weak self] capture lists
  • Timers use closure-based API with [weak self]
  • Thread Sanitizer enabled in test schemes
  • No synchronous I/O or heavy computation on the main thread
  • Time Profiler run on Release build for performance baselines
  • Build failures triaged from the first error in the build log
  • OSSignposter used for custom performance intervals
  • Conditional breakpoints used for loop/collection debugging

References

平台分布

Codex

36.09%
按下载量换算3,144

Claude

31%
按下载量换算2,701

Cursor

19.53%
按下载量换算1,701

Gemini CLI

9.28%
按下载量换算808

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

通过

权限和风险

需要联网

该 Skill 可能需要联网访问来源站点、仓库或外部 API;具体网络访问范围需要结合源码和 README 复核。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。目前只有一个公开来源,建议同时核对源仓库。

继续浏览同类 Skills