diff --git a/IAR/iar.md b/IAR/iar.md index e84abf6..56440c3 100644 --- a/IAR/iar.md +++ b/IAR/iar.md @@ -2,6 +2,22 @@ ## 1.1 各类文件含义 +| 文件 | 作用功能 | +| ------------------- | ------------------------------------------------------------ | +| `.eww`工作空间文件 | 顶层容器,管理**多个相关联的工程** | +| `.ewp`工程文件 | 存储单个工程的**完整配置** | +| `.cspy`工程配置文件 | 保存调试会话的**具体硬件配置**(仅调试相关)。 | +| `.ewd`调试会话文件 | | +| `.dep`依赖文件 | | +| `.icf`链接脚本 | 代码数据在芯片芯片内存中的物理布局,设置栈和堆其实地址及大小 | +| `.ewt`模板文件 | | +| .s汇编源文件 | 经汇编器生成.o文件**1. 芯片启动初始化** **2. 硬件底层操作****中断服务函数 | +| .a二进制静态库 | | +| .map | 看内存存储地址, | +| | | + + + ## 1.2 新建项目 * 新建项目 @@ -32,51 +48,156 @@ ![](pictures\图片8.png) -## 工程配置 +# 工程配置 -### 2.1设备配置 +## 2.1设备配置 > ![](pictures\图片10.png) -### 2.2 编译配置 +## 2.2 编译配置 -> 优化等级 +### 2.2.1优化等级 ​ ![](pictures\图片9.png) -> 硬件浮点 -> +| 等级 | 行为 | 场景 | +| -------------------- | ------------------------------------------------------------ | ------------------------------------------------------------ | +| **None(无优化)** | 完全不优化,代码按原始顺序逐行编译。 | 初级调试阶段(变量未被优化,便于观察) 排查编译器行为异常问题 | +| **Low(低优化)** | 基础优化:删除无操作指令、合并重复加载操**保持函数栈帧完整** | 日常调试开发,对执行速度要求不高的模块 | +| **Medium(中优化)** | 开启函数内联(小函数直接展开)循环展开,寄存器复用加强 | 需要兼顾速度和体积的应用,发布版本的预备测试阶段,**影响调试**时局部变量观察 | +| **High(高优化)** | 激进策略:向量化指令、分支预测优化,**大幅调整代码结构**(如重排指令流水线) | 对实时性要求高的场景(电机控制、信号处理)资源宽裕但性能吃紧的模块; **可能暴露隐藏的时序BUG 调试时变量可能(被优化掉)** | + + + + + +### 2.2.2 硬件浮点 + > ![](pictures\图片12.png) -> 文件路径 +### 2.2.3 文件路径 + +> - **设置位置**: +> `Project > Options > C/C++ Compiler > Preprocessor`(相对路径) +> - `Additional include directories`头文件 +> - `Defined symbols`(预定义全局宏) > -> 预处理 +> 预编译处理 +> +> * 定义STM32F401xx,预编译宏识别芯片型号 +> * .h中寄存器映射结构被激活 > > ![](pictures\图片8.png) +### 2.3.4 库文件路径 + +> `Project > Options > Linker > Library` +> +> ![](pictures\图片20.png) +### 2.2.5 输出. -> 输出.Hex +1. 编译输出 + + `Project > Options > General Output` + + **Output directory**生成 .o/.d 文件的目录 + + **Intermediate files directory**临时文件目录 + +2. 可执行文件 + + ![](pictures\图片21.png) + +3. 输出hex文件 * ![](pictures\图片11.png) -### 2.3 调试器配置 +## 2.3 调试器配置 ![](pictures\图片17.png) -### 2.4 库相关配置 +## 2.4 库相关配置 + +### 2.4.1 库类型 -![](pictures\图片13.png) +| **库类型** | **文件格式** | **使用场景** | **配置入口** | +| :--------------: | :----------: | :---------------: | :------------------------------: | +| **静态库** | `.a` | 核心算法/驱动封装 | Linker > Library | +| **运行时库** | 内置 | 标准C/C++函数支持 | General Options > Library Config | +| **第三方源码库** | `.c`/`.h` | 开源组件集成 | C/C++ Compiler > Preprocessor | +| **系统库** | `.lib` | 操作系统接口 | Linker > Extra Library Search | -### 2.5 静态库封装 +![](pictures\图片22.png) + +## 2.5 静态库封装 + +### 创建库工程 + +1. 建项目`Project > Create New Project...` → 选择 **Library** 模板 → 输入库名称(如 `MyLib`)→ 指定芯片型号。 +2. 右键工程名 → `Add` → 添加库功能的源文件(`.c`/`.cpp`)和头文件(`.h`)。 + +* 排除不要生成的库文件 + +![](pictures\图片23.png) ![](pictures\图片14.png) -## 工程调试 +--- + +## 2.6 调用 -### 3.1断点 +1. 将静态库头文件(.h)复制到inc目录 + +2. **添加头文件路径** + `Project > Options > C/C++ Compiler > Preprocessor` → 填写头文件路径(如 `$PROJ_DIR$\inc`)。 + +3. 链接库文件 + + * `Project > Options > Linker > Library` → 添加库搜索路径(如 `$PROJ_DIR$\..\MyLib\Output\Release`)。 + * 在 **Additional libraries** 中填写库名(如 `MyLib`,**不带扩展名**)。 + * 若有多个库,用空格分隔(`MyLib1 MyLib2`)。 + +4. 代码调用 + + ~~~ c + #include "mylib_functions.h" // 静态库头文件 + + int main() { + lib_init(); // 调用库的初始化函数 + int result = calculate(3, 5); // 调用库的计算函数 + while(1); + return 0; + } + ~~~ + + + +# iar功能 + +## 图标 + +![](pictures\图片29.png) + +> 1. 搜索功能 +> 2. 替换内容 +> 3. 跳转到指定行 +> 4. 书签(在光标所指处,进行书签添加删除) +> 5. 进行书签跳转 + +![](pictures\图片30.png) + +> 1. 编译当前文件 +> 2. 编译所有文件 +> 3. 在光标出添加断点 +> 4. 下载并进入调试 +> 5. 直接进行调试 + +# 工程调试 + +## 断点 ![](pictures\图片15.png) @@ -92,14 +213,205 @@ ![](pictures\图片16.png) + + +### 数据断点 + +全局变量可以打数据断点,局部变量不可以. + +![](pictures\图片32.png) + +| **特性** | 数据断点 | 条件断点 | +| :----------: | :--------------: | :-------------------: | +| **触发条件** | 内存访问 | 代码位置 + 自定义条件 | +| **硬件依赖** | 是(DWT单元) | 否 | +| **数量限制** | 4个(Cortex-M) | 无 | +| **性能影响** | 零开销 | 条件计算引入延迟 | +| **典型场景** | 全局变量篡改监控 | 循环内定点检查 | + +1. **数据断点** → 用于捕获 **不可预测** 的内存篡改 +2. **条件断点** → 用于 **可预测逻辑错误** 的定位 +3. **性能敏感时**:用 `if(cond){bkpt;}` 替代复杂条件断点 +4. **多地址监控**:采用分组轮换策略 + * 监控信息 + `查看变量值,和存储所在的寄存器值` + + ![](pictures\图片28.png) + + | **工具类型** | 数据刷新机制 | 显示格式控制 | 适用场景 | + | :-------------: | :--------------------: | :----------: | :------------------: | + | **Watch** | 手动刷新(暂停时) | ✅ 支持 | 分析暂停时的变量快照 | + | **Live Watch** | 自动实时刷新(运行中) | ❌ 不支持 | 监控运行时动态变化 | + | **Quick Watch** | 单次快照 | ✅ 支持 | 快速查看复杂表达式 | + | **Locals** | 局部变量窗口 | | | + | .Auto | 自动显示表达式/变量窗 | | | + | static | 静态变量窗口 | | | + * 寄存器信息 + + ![](pictures\图片26.png) + +​ + * 内存信息 + + ![](pictures\图片25.png) + + ![](pictures\图片31.png) + + | 普通内存 | 简单内存 | + | ------------ | ------------ | + | 使用地址索引 | 变量名称索引 | + + ___ + + +* 汇编窗口 + + ​ ![](pictures\图片27.png) * 栈信息汇编信息 - * ![](pictures\图片18.png) + + ![](pictures\图片24.png) + * 单步调试 - * ![](pictures\图片19.png) -编译-下载调试---开始-跳出--复位 + ![](pictures\图片19.png) + +* 编译 + +* 全编译(make) + + * | **编译 (Compile)** | Ctrl+F7 | **当前文件**((`.c/.cpp/.s`)) | 生成 `.o` 对象文件 | + | ---------------------- | ------- | -------------------------------- | --------------------------- | + | **全编译 (Make)** | F7 | 全部文件 | 增量编译+链接 → 生成 `.out` | + | **重建 (Rebuild All)** | - | **所有文件** | 全量编译+链接 → 完整输出 | + +编译-下载调试 + +* 在光标处添加断点 +* 下载调试 +* 调试 +* 停止调试 + + + +| 图标 | 作用 | +| -------------- | ------------------------------------------------------------ | +| step over | 不进入内部直接得到结果 | +| step into | 执行下一条语句,若遇到函数调用则进入该函数内部 | +| step out | 立即执行完当前函数,并返回到调用该函数的位置 | +| Run to Cursor | 全速执行到光标所在行暂停临时断点 | +| Next Statement | **强制修改程序计数器(PC)**,将下条执行语句重定向到光标位置,程序暂停时执行 | + +# 拓展 + +## 调试器 + +stlink启动三种模式 + +| **复位模式** | **操作原理** | **适用场景** | **IAR 配置路径** | +| :---------------------: | :---------------------------------: | :------------------------------: | :----------------------------------: | +| **硬件复位 (Hardware)** | 拉低目标芯片的 **NRST 引脚** | 1. 芯片完全卡死 2. Flash锁死 | `Debugger > Setup > Reset: Hardware` | +| **内核复位 (Core)** | 通过 **Cortex-M 调试端口** 复位内核 | 1. 保留外设状态 2. 快速重启调试 | `Debugger > Setup > Reset: Core` | +| **系统复位 (System)** | 触发 **SYSRESETREQ 信号** | 1. 复位内核+外设 2. 模拟上电复位 | `Debugger > Setup > Reset: System` | +| **软件复位 (Software)** | 写 **AIRCR 寄存器** | 1. 无NRST引脚设计 2. 远程复位 | `Debugger > Setup > Reset: Software` | + +| ST-link | j-link | I-Jet Trace | +| -------- | ------------ | ----------- | +| 低速5M | 较高 | 高速50M | +| 便宜 | | 贵 | +| | | iar深度绑定 | +| SWD/JTAG | JTAG/SWD/SWO | 多ETM | + + + +## 上电启动 + +* 硬件启动,启动 + +## 寄存器相关 + +| **寄存器** | **别名** | **位宽** | **核心作用** | **是否可自由使用** | +| :--------: | :------------------: | :------: | :----------------------------: | :----------------: | +| **R0-R12** | 通用寄存器 | 32-bit | 数据存储与运算 | ✅ 是 | +| **R13** | SP (Stack Pointer) | 32-bit | 栈指针(管理函数调用栈) | ⚠️ 受限 | +| **R14** | LR (Link Register) | 32-bit | 保存函数返回地址 | ⚠️ 受限 | +| **R15** | PC (Program Counter) | 32-bit | 程序计数器(指向下条指令地址) | ❌ 不可直接修改 | +| **xPSR** | 程序状态寄存器 | 32-bit | 记录运算状态(零/负/进位等) | ⚠️ 受限 | + +单片机启动项 + +## **Debugger和Download** + +| **特性** | **Debugger(调试器)** | **Download(下载)** | +| :----------: | :------------------------: | :------------------------: | +| **核心目标** | **实时监控与分析**程序行为 | **单向传输**固件到目标芯片 | +| | 需支持调试协议的接口 | 只需物理连接 | +| | 开发/测试 | 量产/维护 | + +## 栈使用空间大小分析 + +### 1.静态分析 + +`project-->options-->linker-->list-->Generate linker map file-->stack usage analysis` + +```yaml +A[Project > Options] --> B[Linker] +B --> C[List] +C --> D[勾选 Generate linker map file] +D --> E[勾选 Generate stack usage analysis] +``` + +![](pictures\图片33.png) + +| **选项名称** | **作用** | **推荐场景** | +| :-------------------------------: | :----------------------------------------: | :----------------------: | +| **✓ Generate linker map file** | 生成 `.map` 文件(内存布局详情+符号地址) | **必选**(内存分析必备) | +| **✓ Generate log file** | 生成链接日志(库引用/段合并记录) | 调试链接问题时启用 | +| **▢ Automatic library selection** | 自动选择依赖库(跳过未使用的库) | 启用可减小固件体积 | +| **▢ Initialization decisions** | 记录全局变量初始化顺序(C++中关键) | C++多模块初始化调试 | +| **▢ Module selections** | 列出所有被链接的 `.o/.a` 文件 | 检查冗余模块/库依赖 | +| **▢ Redirected symbols** | 显示重定向符号(如 `printf` 重定向到串口) | 自定义库函数调试 | +| **▢ Section selections** | 输出每个段(section)的详细地址分配 | 手动优化内存布局时 | +| **▢ Stack usage call graph** | **栈使用调用图**(函数调用链+最大栈消耗) | **栈溢出分析必备** | +| **▢ Unused section fragments** | 标记被丢弃的未使用段(如未调用的函数) | 清理死代码优化 Flash | +| **▢ Veneer statistics** | 统计中断桥接(veneer)数量(跨域调用开销) | 长跳转指令优化 | + +> 编译生成静态文件然后进行分析 + + + +### 2.动态分析 + +## .icf文件分析 + +### 2.为变量分配固定内存块 + +#### 1. **定义内存块** + +```c +define block MY_DATA_BLOCK with size = 256, alignment = 4 { }; +``` + +#### 2. **分配区域** + +```c +place in RAM_region { block MY_DATA_BLOCK }; +``` + +#### 3. **C 代码中使用** + +```c +#pragma location = "MY_DATA_BLOCK" +__no_init uint8_t sensorBuffer[256]; // 分配到自定义块 +``` + +#### 4. **高级用法:绝对地址分配** +```c +// 强制变量到0x20001000 +#pragma location = 0x20001000 +__no_init volatile uint32_t systemFlags; +``` diff --git a/IAR/pictures/图片20.png b/IAR/pictures/图片20.png new file mode 100644 index 0000000..880bd80 Binary files /dev/null and b/IAR/pictures/图片20.png differ diff --git a/IAR/pictures/图片21.png b/IAR/pictures/图片21.png new file mode 100644 index 0000000..47b2c42 Binary files /dev/null and b/IAR/pictures/图片21.png differ diff --git a/IAR/pictures/图片22.png b/IAR/pictures/图片22.png new file mode 100644 index 0000000..f5d3261 Binary files /dev/null and b/IAR/pictures/图片22.png differ diff --git a/IAR/pictures/图片23.png b/IAR/pictures/图片23.png new file mode 100644 index 0000000..a8c180e Binary files /dev/null and b/IAR/pictures/图片23.png differ diff --git a/IAR/pictures/图片24.png b/IAR/pictures/图片24.png new file mode 100644 index 0000000..56a5ae9 Binary files /dev/null and b/IAR/pictures/图片24.png differ diff --git a/IAR/pictures/图片25.png b/IAR/pictures/图片25.png new file mode 100644 index 0000000..85ec27b Binary files /dev/null and b/IAR/pictures/图片25.png differ diff --git a/IAR/pictures/图片26.png b/IAR/pictures/图片26.png new file mode 100644 index 0000000..ae851a9 Binary files /dev/null and b/IAR/pictures/图片26.png differ diff --git a/IAR/pictures/图片27.png b/IAR/pictures/图片27.png new file mode 100644 index 0000000..5b51361 Binary files /dev/null and b/IAR/pictures/图片27.png differ diff --git a/IAR/pictures/图片28.png b/IAR/pictures/图片28.png new file mode 100644 index 0000000..19b8fca Binary files /dev/null and b/IAR/pictures/图片28.png differ diff --git a/IAR/pictures/图片29.png b/IAR/pictures/图片29.png new file mode 100644 index 0000000..a84f7fd Binary files /dev/null and b/IAR/pictures/图片29.png differ diff --git a/IAR/pictures/图片30.png b/IAR/pictures/图片30.png new file mode 100644 index 0000000..fbb5c41 Binary files /dev/null and b/IAR/pictures/图片30.png differ diff --git a/IAR/pictures/图片31.png b/IAR/pictures/图片31.png new file mode 100644 index 0000000..7d02f13 Binary files /dev/null and b/IAR/pictures/图片31.png differ diff --git a/IAR/pictures/图片32.png b/IAR/pictures/图片32.png new file mode 100644 index 0000000..668a8c3 Binary files /dev/null and b/IAR/pictures/图片32.png differ diff --git a/IAR/pictures/图片33.png b/IAR/pictures/图片33.png new file mode 100644 index 0000000..06ef184 Binary files /dev/null and b/IAR/pictures/图片33.png differ diff --git a/Library/Library.md b/Library/Library.md index 16ae3eb..4a477a9 100644 --- a/Library/Library.md +++ b/Library/Library.md @@ -31,20 +31,16 @@ 1. 新建项目---选择控制台应用---配置创建 -2. 右键项目--添加--添加引用 - - ![](pictures\图片8.png) - -3. 引用.h文件--所有配置--所有平台--配置c/c++常规----附加包含添加目录 +2. 引用.h文件--所有配置--所有平台--配置c/c++常规----附加包含添加目录 ![](pictures\图片9.png) +3. 在链接器----常规----附加库目录----添加`.lib`文件路径 + 4. 就可以使用引入的库了 ![](pictures\图片10.png) - · 在代码中语句加载lib调用 - #### 链接使用静态库(都可以在附加目录中添加路径) 1. 需要将.lib链接到主程序 @@ -58,12 +54,61 @@ #include "externalUse.h" //必须包含头文件 ~~~ - + * 使用试例 - **项目依赖**作用是确保在构建主项目时先构建依赖项目(控制编译顺序), + ![](pictures\图片17.png) + + + **项目依赖**作用是确保在构建主项目时先构建依赖项目(控制编译顺序), + **项目引用**主项目不仅知道依赖,还会自动链接 `.lib` 文件(控制链接阶段) - + + ~~~ cpp + #include "pch.h" + #include "use_static_lib.h" + + int Add(int a, int b) + { + return a + b; + } + + int Tools::Get_Tools_Sum() + { + return Sum; + } + + int Tools::sub(int a, int b) + { + return a - b; + } + + int main() + { + cout << "Sdsd" << endl; + Tools tool; + } + ~~~ + + ~~~ cpp + #pragma once + #include + + using namespace std; + int Add(int, int); + + class Tools + { + public: + int sub(int, int); + int Get_Tools_Sum(); + private: + int Sum; + }; + ~~~ + + + ## 动态库 @@ -139,7 +184,18 @@ ![](pictures\图片3.png) +#### 使用模块使用 + +1. 创建项目,添加.c .h文件 + +2. 在源中添加模块.def文件 + 1. ~~~~ + EXPORT + add + ~~~~ + +3. 修改输出文件为.dll ### 2.3调用 @@ -174,11 +230,15 @@ -1. **头文件引用**:包含`.h`(复制到调用方项目)可将.h放到lib中 +1. .dll放在项目可执行文件.exe相同路径 + +2. 创建控制台项目 + +3. **头文件引用**:包含`.h`(复制到调用方项目)可将.h放到lib中 ![](pictures\图片11.png) -2. 库文件配置 +4. 库文件配置 - 链接`.lib`(项目属性 → 链接器 → 输入 → 附加依赖项) @@ -194,9 +254,7 @@ | 链接器输入 | 添加.dll所在路径 | | 链接器常规 | 附加路径添加.lib | - - - +> 将.dll文件放到程序**.exe文件相同路径**下 diff --git a/Library/pictures/图片16.png b/Library/pictures/图片16.png new file mode 100644 index 0000000..efaf59b Binary files /dev/null and b/Library/pictures/图片16.png differ diff --git a/Library/pictures/图片17.png b/Library/pictures/图片17.png new file mode 100644 index 0000000..22a606c Binary files /dev/null and b/Library/pictures/图片17.png differ diff --git a/Markdown/Markdown.md b/Markdown/Markdown.md index ef7106e..af4c2af 100644 --- a/Markdown/Markdown.md +++ b/Markdown/Markdown.md @@ -2,37 +2,52 @@ ``` # +"ctrl 1" ``` ## 二级标题 ~~~ ## +"ctrl 2" ~~~ ### 三级标题 ~~~ ### +"ctrl 3" ~~~ ## 页内跳转 - +~~~ +[111](# 页内跳转) +~~~ # 2. 标号 -## 2.1 无序标号“*”或“-”或“+” +## 2.1 无序标号 + +~~~ bash +“*”或“-”或“+” +无序 ctrl shift ] +有序 ctrl shift [ +~~~ * 123 * 123 -## 2.2 有序标号“1.” +## 2.2 有序标号 + +`1. ` + + 1. 123 2. 123 -## 2.3 嵌套标号 +## 2.3 嵌套标号s * 123 @@ -58,9 +73,17 @@ ***加粗斜体*** 或___加粗斜体___ ~~删除文字~~ - +* _ ~~ ~~~ +**加粗** _斜体_ + +__加粗__ + +*xieti* + +~~删除~~ + ~~文字~~ # 4. 代码段 @@ -99,30 +122,28 @@ int main() [驱动器](https://www.xinje.com) - +[![]()](url) ~~~ 跳转 [描述](# 标题) ~~~ - - [跳转到标号](# 页内跳转) +# 6.其他 +## 大纲 +`ctrl shift l` +## 分割线 -# 6.其他 - -* 分割线 - - ``` - *** - --- - ___ - ``` +``` +*** +--- +___ +``` *** @@ -130,13 +151,17 @@ int main() ___ -* 图片 +*** + + + +## 图片 ​ `![](url)` ​ ![](pictures/图片2.png) -+ 表格 +## 表格 ~~~ bash | 表头1 | 表头2 | 表头3 | @@ -150,14 +175,12 @@ ___ | | | | | | -+ 引用 +## 引用 ``` > ``` - - > 引用文本 > > 引用文本 @@ -166,9 +189,14 @@ ___ > > > >> 三级引用 > >> -> >> -+ 路径 +## 跳转 + +`[](# 命名标题)` + +[业内跳转](## 业内跳转) + +## 路径 ~~~ bash #相对路径使用正斜杠(/) diff --git a/SourceTree/Sourcetree.md b/SourceTree/Sourcetree.md index d368224..2e72b59 100644 --- a/SourceTree/Sourcetree.md +++ b/SourceTree/Sourcetree.md @@ -1,10 +1,10 @@ # GIT -### Git的概念 +## 1.1 Git的概念 开源的分布式版本控制系统管理 -### 三个区域的概念 +## 1.2 三个区域的概念 ​ **工作区**:在电脑中可以看到的目录 @@ -19,15 +19,24 @@ git commit -m "name" ​ **版本库**:每次提交都会保存新的快照,不可变。存放 在.git目录下index文件 -### 仓库的概念 +## 1.3 仓库的概念 * 存放所有文件和历史记录 -### 节点的概念 +### 21.4 节点的概念 + +每次提交产生一个节点 - (提交commit)是仓库中项目某个事件点快照,生成40位哈希值 +- 暂存文件 + +![](pictures\图片9.png) + +* 软合并 +* 混合合并,新建分支 +* 强行合并 -### 分支的概念 +## 1.5 分支的概念 - 开发过程中独立的分流线,本质是一个指向某个可提交的移动指针 - 通过创建分支实现功能开发,然后进行合并 @@ -44,13 +53,13 @@ git merge new_name #合并分支 git rebase new_name #衍合并分支 ~~~ -#### marge +### marge 1. 将目标分支的所有提交**打包为单个新的合并**提交 2. 保留原始分支的完整历史记录 3. 创建**新的合并节点**(commit),这个节点有两个父节点 -#### rebase +### rebase 1. 将当前分支的所有提交**按顺序重演**到目标分支的最新提交之后 2. **修改提交历史**:创建全新的提交序列 @@ -61,7 +70,7 @@ git rebase new_name #衍合并分支 出现冲突选择保留与剔除 -#### 分支操作 +### 分支操作 ~~~ bash #相关操作 @@ -81,13 +90,18 @@ git push git stash ~~~ +删除分支 +```bash +git branch -d 分支名 安全删除(已合并) +git branch -D 分支名 强制删除(未合并) +``` -### 其他 -#### 回退版本 -##### +## 1.6 其他 + +### 回退版本 ~~~ bash git status @@ -95,7 +109,9 @@ git status git status 哈希值 #回退节点 ~~~ -#### 贮藏(Stash)更改(拉取更新时使用) +### 贮藏(Stash) + +更改(拉取更新时使用) ~~~ bash # 贮藏所有修改(包括未跟踪文件) @@ -109,14 +125,15 @@ git stash apply # 应用指定贮藏 git stash apply stash@{1} -# 应用并删除贮藏(常用) +# 应用并删除贮藏(常用 git stash pop # 删除贮藏 -git stash drop "stash@{0} +git stash drop "stash@{0}" +git stash drop 0 ~~~ -#### 编写忽略文件(.gitignore) +### 编写忽略文件(.gitignore) ~~~ bash # 忽略单个文件 @@ -134,7 +151,22 @@ node_modules/ !important.log ~~~ -#### 标签 +### 停止追踪 + +```bash +# 停止跟踪文件,但保留本地文件 +git rm --cached + +# 停止跟踪目录(保留本地目录) +git rm -r --cached + +# 然后提交 +git commit -m "停止跟踪" +``` + + + +### 标签 ~~~ bash # 创建轻量标签(无注释) @@ -152,21 +184,346 @@ git tag -a v0.9.0 commit_hash -m "历史版本" git push origin --tags ~~~ -### 命令表 +### 补丁 + +创建补丁 + +应用补丁 + +## 1.7 命令表 ![命令表](pictures/图片1.png) -## sourceTree +# sourceTree 概念:图形化操作显示 +图示 +## 2.1 仓库操作 -图示 +> 创建本地仓库 +> +> ![](pictures\图片5.png) +> +> 选择本地文件夹创建新仓库 + + + +> 克隆远程 +> +> ![](pictures\图片6.png) +> +> 2. 选择远程url +> +> ![](pictures\图片26.png) + + + +> 关联远程仓库 +> +> ![](pictures\图片27.png) + +## 2.2 节点 + +### 提交 + +![](pictures\图片28.png) + +![](pictures\图片29.png) + +未暂存的文件无法提交 + + + +### 重置 + +> 撤销本地未推送的提交或回退版本**最少选择重置两个节点** +> +> 双击移动到要重置的节点-->选择重置-->强行重置--->解决冲突-->提交到新的分支上 +> +> 左边蓝色为新提交分支 +> +> * 重置之后,需要将以前的分支合并到当前的分支----->并解决冲突就可以了 + +![](pictures/图片10.png) + +![](pictures/图片30.png) + +重置三种模式 + +| 模式 | 行为 | 1 | +| ------------ | ------------------------------------------------------------ | ------------------------------------------------------------ | +| **混合合并** | **保留工作目录中的文件改动**(即本地修改),但重置暂存区到合并前的状态 | 手动控制哪些变更进入暂存区需要仔细审查冲突文件后再决定如何合并
**等效命令**:`git merge --no-commit` + 手动解决 | +| **软合并** | **保持所有本地改动** | 保留工作目录和暂存区的所有修改
不自动创建合并提交 | +| **强行合并** | **丢弃所有改动过的工作副本** | 彻底丢弃所有未提交的本地修改
强制使用远程分支版本覆盖
**等效命令**:`git reset --hard HEAD` + `git merge` | + +1. 混合合并 + + ![](pictures\图片31.png) + +2. 软合并 + + ![](pictures\图片32.png) + + ![](pictures\图片33.png) + + 解决冲突 + + ![](pictures\图片34.png) + +3. 强行合并 + + ![](pictures\图片35.png) + +### 回滚提交 + +> 撤销某个提交引起的更改 +> +> 1. 安全撤销 +> 2. 精准撤销 +> +> 它会自己**创建一个节点**,将上次提交的撤销--然后提交 + +1. 选择分支 +2. 右键单击需要撤销的提交 +3. 选择回滚提交 + +![](pictures\图片11.png) + +**回滚提交一次只能回滚一个节点**,一次回滚多个节点属于错误操作,会导致出现冲突。 + +![](pictures\图片36.png) + +``` +# 1. 回滚指定提交(生成新节点) +git revert 2f3a1b # 2f3a1b 为需要撤销的提交ID + +# 2. 解决可能的冲突(手动编辑后继续) +git add . +git revert --continue + +# 3. 推送到远程仓库 +git push origin main +``` + +## 2.3 分支操作 + +### 新建分支 + +切换到节点点击图标操作 + +![](pictures\图片12.png) + +![](pictures\图片37.png) + +![](pictures\图片38.png) + +### **合并分支** + +切换到要合并的主分支,右键索要合并次分支`-->`选择合并 + +![](pictures\图片40.png) + +![](pictures\图片41.png) + +### 删除分支 + +右键选择删除分支 + +![](pictures\图片13.png) + +#### **删除条件分支** + +1. 分支上传到远程分支 +2. 分支已经合并 +3. 或强行删除分支 + +否则出现**失败**如下 + +![](pictures\图片39.png) + +### 切换分支 + +双击选择要切换的分支 + +### 制造冲突 + +提交合并制造冲突---->出现冲突 + +![](pictures\图片14.png) + +![](pictures\图片15.png) + +### 解决冲突 + +选择保留内容 + +![](pictures\图片16.png) + +处理冲突后进行提交 + +![](pictures\图片17.png) + +### 拉取推送 + + + +![](pictures\图片18.png) + +| 命令 | 作用本质 | 影响范围 | 典型工作场景 | +| :-------------: | :-------------------------------------------------: | :----------------------------------------------------------: | :--------------------------------: | +| **`git fetch`** | **单向同步**:从远程下载元数据和对象 | 仅更新 `.git` 中的远程引用 | 安全地检查远程变更而不改变本地代码 | +| **`git pull`** | **双向操作**:`fetch` + 自动合并 (`merge`/`rebase`) | 改变工作目录文件和本地分支指针
**自动合并冲突中断工作** | 快速将远程更新整合到本地开发环境 | +| **`git push`** | **上传共享**:将本地提交传输到远程仓库 | 更新远程分支指针和提交历史
覆盖他人提交/破坏历史 | 将本地完成的变更发布到中央仓库 | + + + +## 其他 + +### 书写忽略文件 + +* 先停止追踪在忽略意义 + * `.gitignore` 文件**只能阻止未追踪文件被添加**,但对**已纳入版本控制的文件完全无效**。 + +> 假设一个文件已经被追踪,然后你仅仅在.gitignore中添加规则: +> +> - 该文件会继续存在于Git索引中(即继续被追踪) +> - 后续对该文件的修改仍然会被Git检测到 +> - 新克隆的仓库仍然会得到这个文件(因为它已在版本历史中) +> + +```bash +# 忽略单个文件 +config.ini + +# 忽略整个目录 +.vscode/ +node_modules/ + +# 忽略特定类型文件 +*.log +*.tmp + +# 忽略特定文件但包含例外 +!important.log +``` + +![](pictures\图片42.png) + +### 停止跟踪 + +> ### **核心目的:从版本控制中移除文件** +> +> 1. **保留本地文件**:文件保留在工作区,但不再被 Git 追踪 +> 2. **清理索引区**:从 `.git/index` 中移除文件的跟踪记录 +> 3. **激活忽略规则**:让 `.gitignore` 对**已追踪文件**生效 +> 4. **优化仓库性能**:减少无效文件占用历史记录 + +暂存或未暂存都可实现停止追踪 + +![](pictures\图片19.png) + +### 创建补丁 + +多选文件创建补丁 + +![](pictures\图片25.png) + +### 引用补丁 + +1. **应用分支的1.txt内容与补丁内容完全一致** + - **表现**:文件已有"+1"行 + - **结果**:补丁应用**成功**(无冲突),文件内容不变(因为补丁要求的变化已存在) +2. **应用分支的1.txt是空的** + - **表现**:文件为空(0字节) + - **结果**:补丁应用**成功**,文件变为只包含"+1"一行(从空文件追加) +3. **应用分支的1.txt内容与补丁内容部分一致** + - **表现**:文件已有其他内容(如"abc"),但**没有**"+1"行 + - **结果**:补丁应用**成功**,文件在原有内容末尾追加"+1"行 +4. **应用分支没有1.txt这个文件** + - **表现**:文件不存在 + - **结果**:补丁应用**失败**(因找不到目标文件),需要先创建该文件 + +### 贮藏 + +对已暂存的内容进行贮藏 + +![](pictures\图片23.png) + +![](pictures\图片43.png) + +右键贮藏内容可实现应用和删除 + +| 使用场景 | 简介 | +| ------------------ | ------------------------------------------------------------ | +| 紧急切换分支 | 需紧急修复生产环境 bug
当前功能开发未完成无法提交 | +| **同步远程更新** | 拉取远程更新前存在未提交修改
需保持工作目录清洁 | +| **跨分支重用代码** | 避免重复编码,实现代码跨分支复用
在**A分支**贮藏修改,**切换到B分支**应用分支 | + + + +### 丢弃 + +**放弃未提交的更改** + +| 操作 | 效果 | 场景 | +| ------------------ | -------------------------------- | ----------------------------------------------------- | +| **丢弃工作区修改** | 文件恢复到最近一次提交的状态 | 实验性代码失败后快速回退
误修改重要文件需要还原 | +| **丢弃暂存区修改** | 文件保留在工作区但变为未暂存状态 | 误添加了不应提交的文件
需要拆分提交内容时 | +| **丢弃未跟踪文件** | 永久删除未被 Git 管理的文件 | 清理编译生成的临时文件
移除错误创建的垃圾文件 | + +![](pictures\图片46.png) + + + +### 移除 + +| 操作 | 内容 | 场景 | +| ---------------------- | ------------------ | ------------------------------------------------------------ | +| **从版本控制移除文件** | 保留本地 | 误提交敏感文件(`.env`, `*.key`)
无需版本控制的配置文件 | +| **彻底删除文件** | **删除 本地+版本** | 清理编译产物或临时文件
移除已废弃的组件 | +| 清除未追踪文件 | | 操作不可逆!会永久删除文件系统文件 | + +![](pictures\图片47.png) + ++++ + +![](pictures\图片48.png) + ++++ + +![](pictures\图片49.png) + + + +### 创建标签 + +> 标签(Tag)是 Git 中用于**永久标记重要历史节点**的核心功能,常用于版本发布、里程碑记录等场景。 +> +> 1. **版本快照锚点**:为特定提交(如 `v1.0.0`)创建不可变引用 +> 2. **生产部署基准**:标记已通过测试的稳定版本 +> 3. **历史节点保护**:防止关键提交被重置操作丢失 +> 4. **文档关联媒介**:链接代码与版本说明文档 + + + +跳转到目标节点 + + + + + +然后实现**相应节点**添加标签 + +![](pictures\图片20.png) + ++++ -#### 标签 +![](pictures\图片50.png) -可以进行版本发布,压缩下载 +### 删除标签 -![](pictures/图片4.png)) +![](pictures\图片53.png) +![](pictures\图片54.png)![](pictures\图片55.png) diff --git a/SourceTree/pictures/图片10.png b/SourceTree/pictures/图片10.png new file mode 100644 index 0000000..fd491b0 Binary files /dev/null and b/SourceTree/pictures/图片10.png differ diff --git a/SourceTree/pictures/图片11.png b/SourceTree/pictures/图片11.png new file mode 100644 index 0000000..5de76c6 Binary files /dev/null and b/SourceTree/pictures/图片11.png differ diff --git a/SourceTree/pictures/图片12.png b/SourceTree/pictures/图片12.png new file mode 100644 index 0000000..8f63f7c Binary files /dev/null and b/SourceTree/pictures/图片12.png differ diff --git a/SourceTree/pictures/图片13.png b/SourceTree/pictures/图片13.png new file mode 100644 index 0000000..6da2a3e Binary files /dev/null and b/SourceTree/pictures/图片13.png differ diff --git a/SourceTree/pictures/图片14.png b/SourceTree/pictures/图片14.png new file mode 100644 index 0000000..4a79324 Binary files /dev/null and b/SourceTree/pictures/图片14.png differ diff --git a/SourceTree/pictures/图片15.png b/SourceTree/pictures/图片15.png new file mode 100644 index 0000000..fba2940 Binary files /dev/null and b/SourceTree/pictures/图片15.png differ diff --git a/SourceTree/pictures/图片16.png b/SourceTree/pictures/图片16.png new file mode 100644 index 0000000..e3474d7 Binary files /dev/null and b/SourceTree/pictures/图片16.png differ diff --git a/SourceTree/pictures/图片17.png b/SourceTree/pictures/图片17.png new file mode 100644 index 0000000..cce429c Binary files /dev/null and b/SourceTree/pictures/图片17.png differ diff --git a/SourceTree/pictures/图片18.png b/SourceTree/pictures/图片18.png new file mode 100644 index 0000000..802bb05 Binary files /dev/null and b/SourceTree/pictures/图片18.png differ diff --git a/SourceTree/pictures/图片19.png b/SourceTree/pictures/图片19.png new file mode 100644 index 0000000..af81a17 Binary files /dev/null and b/SourceTree/pictures/图片19.png differ diff --git a/SourceTree/pictures/图片20.png b/SourceTree/pictures/图片20.png new file mode 100644 index 0000000..b1af94a Binary files /dev/null and b/SourceTree/pictures/图片20.png differ diff --git a/SourceTree/pictures/图片21.png b/SourceTree/pictures/图片21.png new file mode 100644 index 0000000..a201577 Binary files /dev/null and b/SourceTree/pictures/图片21.png differ diff --git a/SourceTree/pictures/图片22.png b/SourceTree/pictures/图片22.png new file mode 100644 index 0000000..26ecb6b Binary files /dev/null and b/SourceTree/pictures/图片22.png differ diff --git a/SourceTree/pictures/图片23.png b/SourceTree/pictures/图片23.png new file mode 100644 index 0000000..1bbf444 Binary files /dev/null and b/SourceTree/pictures/图片23.png differ diff --git a/SourceTree/pictures/图片24.png b/SourceTree/pictures/图片24.png new file mode 100644 index 0000000..6944ef3 Binary files /dev/null and b/SourceTree/pictures/图片24.png differ diff --git a/SourceTree/pictures/图片25.png b/SourceTree/pictures/图片25.png new file mode 100644 index 0000000..40dbd64 Binary files /dev/null and b/SourceTree/pictures/图片25.png differ diff --git a/SourceTree/pictures/图片26.png b/SourceTree/pictures/图片26.png new file mode 100644 index 0000000..4d80d8f Binary files /dev/null and b/SourceTree/pictures/图片26.png differ diff --git a/SourceTree/pictures/图片27.png b/SourceTree/pictures/图片27.png new file mode 100644 index 0000000..49c51b1 Binary files /dev/null and b/SourceTree/pictures/图片27.png differ diff --git a/SourceTree/pictures/图片28.png b/SourceTree/pictures/图片28.png new file mode 100644 index 0000000..0bfd061 Binary files /dev/null and b/SourceTree/pictures/图片28.png differ diff --git a/SourceTree/pictures/图片29.png b/SourceTree/pictures/图片29.png new file mode 100644 index 0000000..9b8fd9e Binary files /dev/null and b/SourceTree/pictures/图片29.png differ diff --git a/SourceTree/pictures/图片30.png b/SourceTree/pictures/图片30.png new file mode 100644 index 0000000..281bdc3 Binary files /dev/null and b/SourceTree/pictures/图片30.png differ diff --git a/SourceTree/pictures/图片31.png b/SourceTree/pictures/图片31.png new file mode 100644 index 0000000..d990a87 Binary files /dev/null and b/SourceTree/pictures/图片31.png differ diff --git a/SourceTree/pictures/图片32.png b/SourceTree/pictures/图片32.png new file mode 100644 index 0000000..ef1098d Binary files /dev/null and b/SourceTree/pictures/图片32.png differ diff --git a/SourceTree/pictures/图片33.png b/SourceTree/pictures/图片33.png new file mode 100644 index 0000000..25a0dad Binary files /dev/null and b/SourceTree/pictures/图片33.png differ diff --git a/SourceTree/pictures/图片34.png b/SourceTree/pictures/图片34.png new file mode 100644 index 0000000..538a90a Binary files /dev/null and b/SourceTree/pictures/图片34.png differ diff --git a/SourceTree/pictures/图片35.png b/SourceTree/pictures/图片35.png new file mode 100644 index 0000000..cb1e65d Binary files /dev/null and b/SourceTree/pictures/图片35.png differ diff --git a/SourceTree/pictures/图片36.png b/SourceTree/pictures/图片36.png new file mode 100644 index 0000000..10aab12 Binary files /dev/null and b/SourceTree/pictures/图片36.png differ diff --git a/SourceTree/pictures/图片37.png b/SourceTree/pictures/图片37.png new file mode 100644 index 0000000..9bf9110 Binary files /dev/null and b/SourceTree/pictures/图片37.png differ diff --git a/SourceTree/pictures/图片38.png b/SourceTree/pictures/图片38.png new file mode 100644 index 0000000..c8ad6b8 Binary files /dev/null and b/SourceTree/pictures/图片38.png differ diff --git a/SourceTree/pictures/图片39.png b/SourceTree/pictures/图片39.png new file mode 100644 index 0000000..86c8288 Binary files /dev/null and b/SourceTree/pictures/图片39.png differ diff --git a/SourceTree/pictures/图片40.png b/SourceTree/pictures/图片40.png new file mode 100644 index 0000000..4f2528d Binary files /dev/null and b/SourceTree/pictures/图片40.png differ diff --git a/SourceTree/pictures/图片41.png b/SourceTree/pictures/图片41.png new file mode 100644 index 0000000..e52b8aa Binary files /dev/null and b/SourceTree/pictures/图片41.png differ diff --git a/SourceTree/pictures/图片42.png b/SourceTree/pictures/图片42.png new file mode 100644 index 0000000..3f4e1ca Binary files /dev/null and b/SourceTree/pictures/图片42.png differ diff --git a/SourceTree/pictures/图片43.png b/SourceTree/pictures/图片43.png new file mode 100644 index 0000000..54d22aa Binary files /dev/null and b/SourceTree/pictures/图片43.png differ diff --git a/SourceTree/pictures/图片44.png b/SourceTree/pictures/图片44.png new file mode 100644 index 0000000..1a3cce6 Binary files /dev/null and b/SourceTree/pictures/图片44.png differ diff --git a/SourceTree/pictures/图片45.png b/SourceTree/pictures/图片45.png new file mode 100644 index 0000000..0c2c989 Binary files /dev/null and b/SourceTree/pictures/图片45.png differ diff --git a/SourceTree/pictures/图片46.png b/SourceTree/pictures/图片46.png new file mode 100644 index 0000000..d7b8b7b Binary files /dev/null and b/SourceTree/pictures/图片46.png differ diff --git a/SourceTree/pictures/图片47.png b/SourceTree/pictures/图片47.png new file mode 100644 index 0000000..46479f0 Binary files /dev/null and b/SourceTree/pictures/图片47.png differ diff --git a/SourceTree/pictures/图片48.png b/SourceTree/pictures/图片48.png new file mode 100644 index 0000000..28423df Binary files /dev/null and b/SourceTree/pictures/图片48.png differ diff --git a/SourceTree/pictures/图片49.png b/SourceTree/pictures/图片49.png new file mode 100644 index 0000000..067d50e Binary files /dev/null and b/SourceTree/pictures/图片49.png differ diff --git a/SourceTree/pictures/图片5.png b/SourceTree/pictures/图片5.png new file mode 100644 index 0000000..cadcf7b Binary files /dev/null and b/SourceTree/pictures/图片5.png differ diff --git a/SourceTree/pictures/图片50.png b/SourceTree/pictures/图片50.png new file mode 100644 index 0000000..8ac8b08 Binary files /dev/null and b/SourceTree/pictures/图片50.png differ diff --git a/SourceTree/pictures/图片51.png b/SourceTree/pictures/图片51.png new file mode 100644 index 0000000..d2d3157 Binary files /dev/null and b/SourceTree/pictures/图片51.png differ diff --git a/SourceTree/pictures/图片52.png b/SourceTree/pictures/图片52.png new file mode 100644 index 0000000..4e194bc Binary files /dev/null and b/SourceTree/pictures/图片52.png differ diff --git a/SourceTree/pictures/图片53.png b/SourceTree/pictures/图片53.png new file mode 100644 index 0000000..1bd69d0 Binary files /dev/null and b/SourceTree/pictures/图片53.png differ diff --git a/SourceTree/pictures/图片54.png b/SourceTree/pictures/图片54.png new file mode 100644 index 0000000..1e71afd Binary files /dev/null and b/SourceTree/pictures/图片54.png differ diff --git a/SourceTree/pictures/图片55.png b/SourceTree/pictures/图片55.png new file mode 100644 index 0000000..3200b05 Binary files /dev/null and b/SourceTree/pictures/图片55.png differ diff --git a/SourceTree/pictures/图片56.png b/SourceTree/pictures/图片56.png new file mode 100644 index 0000000..ada642e Binary files /dev/null and b/SourceTree/pictures/图片56.png differ diff --git a/SourceTree/pictures/图片57.png b/SourceTree/pictures/图片57.png new file mode 100644 index 0000000..840be11 Binary files /dev/null and b/SourceTree/pictures/图片57.png differ diff --git a/SourceTree/pictures/图片6.png b/SourceTree/pictures/图片6.png new file mode 100644 index 0000000..7586f6c Binary files /dev/null and b/SourceTree/pictures/图片6.png differ diff --git a/SourceTree/pictures/图片7.png b/SourceTree/pictures/图片7.png new file mode 100644 index 0000000..911660b Binary files /dev/null and b/SourceTree/pictures/图片7.png differ diff --git a/SourceTree/pictures/图片8.png b/SourceTree/pictures/图片8.png new file mode 100644 index 0000000..90e390c Binary files /dev/null and b/SourceTree/pictures/图片8.png differ diff --git a/SourceTree/pictures/图片9.png b/SourceTree/pictures/图片9.png new file mode 100644 index 0000000..21df2b6 Binary files /dev/null and b/SourceTree/pictures/图片9.png differ diff --git a/Sourcelnsight/Sourcelnsight.md b/Sourcelnsight/Sourcelnsight.md index 65013c5..eacf95c 100644 --- a/Sourcelnsight/Sourcelnsight.md +++ b/Sourcelnsight/Sourcelnsight.md @@ -7,50 +7,150 @@ - 常用窗口打开/关闭 - 搜索引用 -### 创建工程 +## 1 创建工程 + +`选择Project--->创建新工程-->修改项目名称-->修改保存路径` ![](pictures/图片4.png) -* 选择源文件路径 -* ![](pictures/图片5.png) +`下一步设置-->源代码路径-->` -![](pictures/图片6.png) +![](pictures/图片15.png) -**Add**:基本的文件添加操作; +`添加关联项目` -**Add All**:添加整个工程所有的源文件(然后再选择是否递归添加子目录中的源文件,见上图对话框); +![](pictures/图片6.png) -**Add Tree**:添加指定的文件夹以及其子目录下的源代码文件; +* 添加其他磁盘文件 -**Remove Tree**:和Add Tree的功能相反; + -File Name可以不用填写,完成点击close。 +| 选项 | 作用 | +| ----------- | ------------------------------------------------------------ | +| add | 基本的文件添加操作; | +| Add All | 添加整个工程所有的源文件(然后再选择是否递归添加子目录中的源文件,见上图对话框 | +| Add Tree | 添加指定的文件夹以及其子目录下的源代码文件; | +| Remove Tree | 和Add Tree的功能相反 | * 添加代码同步 -![](pictures/图片7.png) + ![](pictures/图片7.png) * 强制重解析 ![](pictures/图片8.png) * 选择语言和后缀名文件 - * ![](pictures/图片9.png) + + ![](pictures/图片9.png) + +## 2 符号表同步 + +![](pictures/图片8.png) + +## 3 视图切换 + +![](pictures\图片21.png) + +1. 平铺窗口-->同时显示多个文件 +2. 突出显示 +3. 平铺两个 +4. 层叠窗口 + + + +## 4常用窗口打开和关闭 -### 中文乱码处理 +![](pictures/图片14.png) -![](pictures/图片11.png) +实现常用布局窗口快速切换和保存 -![](pictures/图片10.png) +## 5 搜索引用 + +![](pictures/图片13.png) + +## 中文乱码处理 + +* Options > Preferences->设置全局编码方式 + + + + + + ## 全局搜索 -![](pictures/图片2.png) +![](pictures/图片22.png) + +| **选项** | **作用** | **使用场景** | +| :---------------------------------------: | :--------------: | :----------------------------: | +| **Project Wide** (项目范围) | 在整个工程内搜索 | 跨文件全局搜索(默认当前文件) | +| **Include Subdirectories** (包含子目录) | 递归搜索子文件夹 | 确保嵌套目录文件不被遗漏 | + +| **Case Sensitive** (区分大小写) | 严格匹配大小写 | 搜索 `malloc` 时忽略 `Malloc` | +| ------------------------------------------ | -------------------------------- | ------------------------------------------ | +| **Whole Words Only** (全词匹配) | 仅匹配完整单词 | 避免 `int` 匹配到 `print` | +| **Use Regular Expressions** (正则表达式) | 启用正则语法 | 复杂模式如 `[A-Za-z]+_t`(匹配类型名) | +| **Find Non-Matching** (查找不匹配项) | **反向搜索**:显示不符合条件的行 | 排查非规范命名的变量(如不用下划线的变量) | + +![](pictures/图片23.png) + +| **Skip Inactive Code** (跳过非活动代码) | 忽略 `#if 0` / `#ifdef DEBUG` 等未启用的代码块 | 避免搜索到废弃代码 | +| ----------------------------------------- | ---------------------------------------------- | --------------------------- | +| **Skip Comments** (跳过注释) | 排除注释内容 | 精准匹配实际代码 | +| **Search Only Comments** (仅搜索注释) | **限定**在注释中搜索 | 与 `Skip Comments` **互斥** | +| **Include in Results..**(结果包含项) | 弹窗配置搜索结果 | | [网络详细教程](https://blog.csdn.net/Ang_ie/article/details/114993440?ops_request_misc=%257B%2522request%255Fid%2522%253A%2522f8ab43e2e898e776e0b4435731a78550%2522%252C%2522scm%2522%253A%252220140713.130102334..%2522%257D&request_id=f8ab43e2e898e776e0b4435731a78550&biz_id=0&utm_medium=distribute.pc_search_result.none-task-blog-2~all~baidu_landing_v2~default-4-114993440-null-null.142^v102^pc_search_result_base1&utm_term=SourceInSight%E4%BD%BF%E7%94%A8%E6%95%99%E7%A8%8B&spm=1018.2226.3001.4187) -## 视图 +## 查找引用工具 + +![](pictures/图片17.png) + +1. 跳转定义 +2. 查看符号信息 +3. 跳转到调用处 +4. 查找引用 + +![](pictures/图片20.png) + +![](pictures\图片24.png) + +`简单字符匹配` + +`正则表达式` + +`关键词表达式` + +`查找引用` + +### 查找替换 + +![](pictures/图片18.png) + +* 查找 + +![](pictures/图片25.png) + +* 替换 `X->Y` + +## 对比 + +![](pictures/图片26.png) + +1. 文件夹对比 + + ![](pictures/图片28.png) + +2. 文件项目对比 + + ![](pictures/图片27.png) + +## 备份文件使用 + +`选择tools-->对比备份文件-->选择变动文件进行对比` -![](pictures/图片3.png) +![](pictures/图片30.png) -保存布局和切换布局 \ No newline at end of file +![](pictures/图片31.png) diff --git a/Sourcelnsight/pictures/图片10-1752480357628-4.png b/Sourcelnsight/pictures/图片10-1752480357628-4.png new file mode 100644 index 0000000..fd491b0 Binary files /dev/null and b/Sourcelnsight/pictures/图片10-1752480357628-4.png differ diff --git a/Sourcelnsight/pictures/图片10-1752480372743-6.png b/Sourcelnsight/pictures/图片10-1752480372743-6.png new file mode 100644 index 0000000..fd491b0 Binary files /dev/null and b/Sourcelnsight/pictures/图片10-1752480372743-6.png differ diff --git a/Sourcelnsight/pictures/图片11-1752542193181-1.png b/Sourcelnsight/pictures/图片11-1752542193181-1.png new file mode 100644 index 0000000..ca8b43e Binary files /dev/null and b/Sourcelnsight/pictures/图片11-1752542193181-1.png differ diff --git a/Sourcelnsight/pictures/图片12.png b/Sourcelnsight/pictures/图片12.png new file mode 100644 index 0000000..b1d078f Binary files /dev/null and b/Sourcelnsight/pictures/图片12.png differ diff --git a/Sourcelnsight/pictures/图片13-1752486274357-8.png b/Sourcelnsight/pictures/图片13-1752486274357-8.png new file mode 100644 index 0000000..6da2a3e Binary files /dev/null and b/Sourcelnsight/pictures/图片13-1752486274357-8.png differ diff --git a/Sourcelnsight/pictures/图片13-1752544512675-1.png b/Sourcelnsight/pictures/图片13-1752544512675-1.png new file mode 100644 index 0000000..c5f9548 Binary files /dev/null and b/Sourcelnsight/pictures/图片13-1752544512675-1.png differ diff --git a/Sourcelnsight/pictures/图片13.png b/Sourcelnsight/pictures/图片13.png new file mode 100644 index 0000000..47fef16 Binary files /dev/null and b/Sourcelnsight/pictures/图片13.png differ diff --git a/Sourcelnsight/pictures/图片14-1752486331859-10.png b/Sourcelnsight/pictures/图片14-1752486331859-10.png new file mode 100644 index 0000000..4a79324 Binary files /dev/null and b/Sourcelnsight/pictures/图片14-1752486331859-10.png differ diff --git a/Sourcelnsight/pictures/图片14.png b/Sourcelnsight/pictures/图片14.png new file mode 100644 index 0000000..de2a8b6 Binary files /dev/null and b/Sourcelnsight/pictures/图片14.png differ diff --git a/Sourcelnsight/pictures/图片15.png b/Sourcelnsight/pictures/图片15.png new file mode 100644 index 0000000..bca6569 Binary files /dev/null and b/Sourcelnsight/pictures/图片15.png differ diff --git a/Sourcelnsight/pictures/图片16-1752486659236-12.png b/Sourcelnsight/pictures/图片16-1752486659236-12.png new file mode 100644 index 0000000..e3474d7 Binary files /dev/null and b/Sourcelnsight/pictures/图片16-1752486659236-12.png differ diff --git a/Sourcelnsight/pictures/图片16.png b/Sourcelnsight/pictures/图片16.png new file mode 100644 index 0000000..efaf59b Binary files /dev/null and b/Sourcelnsight/pictures/图片16.png differ diff --git a/Sourcelnsight/pictures/图片17-1752487165224-14.png b/Sourcelnsight/pictures/图片17-1752487165224-14.png new file mode 100644 index 0000000..cce429c Binary files /dev/null and b/Sourcelnsight/pictures/图片17-1752487165224-14.png differ diff --git a/Sourcelnsight/pictures/图片17.png b/Sourcelnsight/pictures/图片17.png new file mode 100644 index 0000000..cfd12ca Binary files /dev/null and b/Sourcelnsight/pictures/图片17.png differ diff --git a/Sourcelnsight/pictures/图片18.png b/Sourcelnsight/pictures/图片18.png new file mode 100644 index 0000000..b97cee6 Binary files /dev/null and b/Sourcelnsight/pictures/图片18.png differ diff --git a/Sourcelnsight/pictures/图片19.png b/Sourcelnsight/pictures/图片19.png new file mode 100644 index 0000000..436e68c Binary files /dev/null and b/Sourcelnsight/pictures/图片19.png differ diff --git a/Sourcelnsight/pictures/图片20.png b/Sourcelnsight/pictures/图片20.png new file mode 100644 index 0000000..f77b456 Binary files /dev/null and b/Sourcelnsight/pictures/图片20.png differ diff --git a/Sourcelnsight/pictures/图片21.png b/Sourcelnsight/pictures/图片21.png new file mode 100644 index 0000000..5f286f5 Binary files /dev/null and b/Sourcelnsight/pictures/图片21.png differ diff --git a/Sourcelnsight/pictures/图片22.png b/Sourcelnsight/pictures/图片22.png new file mode 100644 index 0000000..1d68d9e Binary files /dev/null and b/Sourcelnsight/pictures/图片22.png differ diff --git a/Sourcelnsight/pictures/图片23.png b/Sourcelnsight/pictures/图片23.png new file mode 100644 index 0000000..5977bd0 Binary files /dev/null and b/Sourcelnsight/pictures/图片23.png differ diff --git a/Sourcelnsight/pictures/图片24.png b/Sourcelnsight/pictures/图片24.png new file mode 100644 index 0000000..d56bedd Binary files /dev/null and b/Sourcelnsight/pictures/图片24.png differ diff --git a/Sourcelnsight/pictures/图片25.png b/Sourcelnsight/pictures/图片25.png new file mode 100644 index 0000000..afae190 Binary files /dev/null and b/Sourcelnsight/pictures/图片25.png differ diff --git a/Sourcelnsight/pictures/图片26.png b/Sourcelnsight/pictures/图片26.png new file mode 100644 index 0000000..059c1b1 Binary files /dev/null and b/Sourcelnsight/pictures/图片26.png differ diff --git a/Sourcelnsight/pictures/图片27.png b/Sourcelnsight/pictures/图片27.png new file mode 100644 index 0000000..8ba8166 Binary files /dev/null and b/Sourcelnsight/pictures/图片27.png differ diff --git a/Sourcelnsight/pictures/图片28.png b/Sourcelnsight/pictures/图片28.png new file mode 100644 index 0000000..c6649a8 Binary files /dev/null and b/Sourcelnsight/pictures/图片28.png differ diff --git a/Sourcelnsight/pictures/图片29.png b/Sourcelnsight/pictures/图片29.png new file mode 100644 index 0000000..3c0fae3 Binary files /dev/null and b/Sourcelnsight/pictures/图片29.png differ diff --git a/Sourcelnsight/pictures/图片30.png b/Sourcelnsight/pictures/图片30.png new file mode 100644 index 0000000..ffca1eb Binary files /dev/null and b/Sourcelnsight/pictures/图片30.png differ diff --git a/Sourcelnsight/pictures/图片31.png b/Sourcelnsight/pictures/图片31.png new file mode 100644 index 0000000..0b61346 Binary files /dev/null and b/Sourcelnsight/pictures/图片31.png differ diff --git a/Sourcelnsight/pictures/图片4.png b/Sourcelnsight/pictures/图片4.png index fffbda8..c3fcdc4 100644 Binary files a/Sourcelnsight/pictures/图片4.png and b/Sourcelnsight/pictures/图片4.png differ diff --git a/Sourcelnsight/pictures/图片5.png b/Sourcelnsight/pictures/图片5.png index 4d55279..464b0d3 100644 Binary files a/Sourcelnsight/pictures/图片5.png and b/Sourcelnsight/pictures/图片5.png differ diff --git a/Sourcelnsight/pictures/图片8.png b/Sourcelnsight/pictures/图片8.png index bc2ce27..c989179 100644 Binary files a/Sourcelnsight/pictures/图片8.png and b/Sourcelnsight/pictures/图片8.png differ diff --git a/UnitTest/UnitTest.md b/UnitTest/UnitTest.md index 64f1e4b..84e5f22 100644 --- a/UnitTest/UnitTest.md +++ b/UnitTest/UnitTest.md @@ -11,13 +11,15 @@ ![](pictures\图片1.png) -2. 创建测试程序 +2. 添加.h文件,包含所有函数 + +3. 创建测试程序 创建项目----选择本机单元测试---配置创建 ![](pictures\图片2.png) -3. 添加要测试项目 +4. 添加要测试项目 右键项目---添加--现有项----添加.obj文件。 @@ -28,7 +30,7 @@ - **C/C++ → 常规 → 附加包含目录**:添加主项目的头文件路径 - **链接器 → 输入 → 附加依赖项**:添加主项目生成的 `.lib` 文件 -4. 添加被测项目头文件 +5. 添加被测项目头文件 实现一个简单的测试 ![](pictures\图片4.png) @@ -45,7 +47,26 @@ TEST_METHOD(TestMethod1) } ~~~ +~~~ cpp +TEST_METHOD(TestMethodPerformance) +{ + // 记录开始时间 + auto start = std::chrono::high_resolution_clock::now(); + + // 执行被测函数 + int result = add_multiplied(8, 90); + // 记录结束时间 + auto end = std::chrono::high_resolution_clock::now(); + + // 计算时间差(以毫秒为单位) + std::chrono::duration elapsed = end - start; + + // 输出执行时间(在VS的输出窗口中可见) + Logger::WriteMessage(("Execution time: " + std::to_string(elapsed.count()) + " ms").c_str()); +} +/*循环1000次*/ +~~~ ### 1.3代码覆盖度 @@ -102,6 +123,39 @@ TEST_METHOD(TestMethod1) ### 1.5测试单元样例书写 +~~~ cpp + +TEST_METHOD(TestMethod1) +{ + int a = 2; + int b = 8; + int sum = 10; + //断言判断结果是否未为20 + Assert::AreEqual(sum, add(a, b)); +} +#include +TEST_METHOD(TestMethodPerformance) +{ + int a = 2; + int b = 8; + // 记录开始时间 + auto start = std::chrono::high_resolution_clock::now(); + + // 执行被测函数 + int result = add_multiplied(a, b); + + // 记录结束时间 + auto end = std::chrono::high_resolution_clock::now(); + + // 计算时间差(以毫秒为单位) + std::chrono::duration elapsed = end - start; + + // 输出执行时间(在VS的输出窗口中可见) + Logger::WriteMessage(("Execution time: " + std::to_string(elapsed.count()) + " ms").c_str()); + +} +~~~ + ### 1.6 单元测试 1. 设置断点 diff --git a/VisualStudio/pictures/图片11.png b/VisualStudio/pictures/图片11.png new file mode 100644 index 0000000..ca8b43e Binary files /dev/null and b/VisualStudio/pictures/图片11.png differ diff --git a/VisualStudio/pictures/图片12.png b/VisualStudio/pictures/图片12.png new file mode 100644 index 0000000..162810f Binary files /dev/null and b/VisualStudio/pictures/图片12.png differ diff --git a/VisualStudio/pictures/图片13.png b/VisualStudio/pictures/图片13.png new file mode 100644 index 0000000..c5f9548 Binary files /dev/null and b/VisualStudio/pictures/图片13.png differ diff --git a/VisualStudio/pictures/图片14.png b/VisualStudio/pictures/图片14.png new file mode 100644 index 0000000..42404a7 Binary files /dev/null and b/VisualStudio/pictures/图片14.png differ diff --git a/VisualStudio/pictures/图片15.png b/VisualStudio/pictures/图片15.png new file mode 100644 index 0000000..8a6289a Binary files /dev/null and b/VisualStudio/pictures/图片15.png differ diff --git a/VisualStudio/pictures/图片16.png b/VisualStudio/pictures/图片16.png new file mode 100644 index 0000000..d76b0b0 Binary files /dev/null and b/VisualStudio/pictures/图片16.png differ diff --git a/VisualStudio/visualStudio.md b/VisualStudio/visualStudio.md index 3a12c7b..53c673f 100644 --- a/VisualStudio/visualStudio.md +++ b/VisualStudio/visualStudio.md @@ -30,9 +30,20 @@ ### 1.5 创建/打开文件 +上述操作均可通过右键目标文件---选择目标操作 + ### 1.6 包括/排除项目 -上述操作均可通过右键目标文件---选择目标操作 +移除项目--->包含项目 + +1. 右键要排除的项目 +2. 选择从项目中排除 +3. **包含项目**选择显示所有文件 +4. 将被排除的项目重新包含到项目 + +![](pictures\图片11.png) + +![](pictures\图片12.png) ## 工程配置 @@ -60,7 +71,26 @@ * 右键项目----属性---常规----输出目录 * 项目属性 --C/C++---- 常规 ---- 附加包含目录 +#### 源文件路径修改 + +1. 选择显示所有文件 +2. 将要修改路径的源文件,**拖动**到目标路径就可以 + +![](pictures\图片13.png) +#### 库文件配置 + +* 附加文件保函库 + +![](pictures\图片15.png) + +* 库文件地址 + +![](pictures\图片14.png) + +* 加载库 + +![](pictures\图片16.png) ### 2.3 宏定义 @@ -86,6 +116,8 @@ | 链接器 | | 链接器 → 常规 → 附加库目录 → 添加 `lib\x64\` 等路径 | - 安全检查 + - 代码生成---安全检查 + 1. 编译器检查 2. 链接器检查