STM32开发学习——使用 Cortex-M3M4M7 故障异常原因与定位(三)

STM32开发学习——使用 Cortex-M3M4M7 故障异常原因与定位(三)

文章目录

  • STM32开发学习——使用 Cortex-M3M4M7 故障异常原因与定位(三)
    • 文档说明:
    • 官方参考文档线上链接(可在线阅读与下载):
    • 使用MDK调试功能查看故障类型与定位
      • 故障寄存器的查看
      • 确定异常发生的位置
    • 代码嵌入方式:

文档说明:

分享一下在Stm32学习过程收集到的一些值得记录的好资料,以便自己保留印象和尽可能的应用到工作中,达到事半功倍的效果。

这是一篇关于如何使用MDK或者代码嵌入的方式来定位故障发生大概地址。
之前的参考文档:
STM32开发学习——使用 Cortex-M3M4M7 故障异常原因与定位
STM32开发学习——使用 Cortex-M3M4M7 故障异常原因与定位(二)

官方参考文档线上链接(可在线阅读与下载):

  • MDK:AN209

  • SEGGER:AN00016_AnalyzingHardFaultsOnCortexM.book

  • Cortex-M故障 - SEGGER Wiki

使用MDK调试功能查看故障类型与定位

故障寄存器的查看

在进入调试界面后使用PeripheralsCore Peripherals:即可查看到已发生的异常的详细信息。

在这里插入图片描述

在这里插入图片描述

确定异常发生的位置

右键单击“调用堆栈 + 局部变量”窗口中的“HardFault Handler”,然后选择“显示调用方代码”以突出显示发生点的执行上下文:

在这里插入图片描述

根据异常的类型,调试器将突出显示导致异常的指令或紧随导致错误的指令之后的指令。这取决于导致异常的指令是否实际完成执行。

代码嵌入方式:

将下列SEGGER关于Hardfault的代码嵌入到你的软件工程当中

;
;----------------------------------------------------------------------
;File    : HardFaultHandler.S
;Purpose : HardFault exception handler for IAR, Keil and GNU assembler.
;          Evaluates used stack (MSP, PSP) and passes appropiate stack
;          pointer to the HardFaultHandler "C"-routine.
;------------- END-OF-HEADER ------------------------------------------;
;/*********************************************************************
;*
;*     Forward declarations of segments used
;*
;**********************************************************************
;*/
AREA    OSKERNEL, CODE, READONLY, ALIGN=2
PRESERVE8EXPORT  HardFault_HandlerIMPORT  HardFaultHandlerTHUMB;/*********************************************************************
;*
;*       Global functions
;*
;**********************************************************************
;*/;/*********************************************************************
;*
;*      HardFault_Handler()
;*
;*  Function description
;*    Evaluates the used stack (MSP, PSP) and passes the appropiate
;*    stack pointer to the HardFaultHandler "C"-routine.
;*
;*  Notes
;*    (1) Ensure that HardFault_Handler is part of the exception table
;*/HardFault_Handler;// This version is for Cortex M3, Cortex M4 and Cortex M4F
tst    LR, #4            ;// Check EXC_RETURN in Link register bit 2.
ite    EQ
mrseq  R0, MSP           ;// Stacking was using MSP.
mrsne  R0, PSP           ;// Stacking was using PSP.
b      HardFaultHandler  ;// Stack pointer passed through R0.END;/****** End Of File *************************************************/
/**********************************************************************                     SEGGER Microcontroller GmbH                    **                        The Embedded Experts                        ************************************************************************                                                                    **            (c) 2014 - 2023 SEGGER Microcontroller GmbH             **                                                                    **           www.segger.com     Support: support@segger.com           **                                                                    ************************************************************************                                                                    ** All rights reserved.                                               **                                                                    ** Redistribution and use in source and binary forms, with or         ** without modification, are permitted provided that the following    ** conditions are met:                                                **                                                                    ** - Redistributions of source code must retain the above copyright   **   notice, this list of conditions and the following disclaimer.    **                                                                    ** - Neither the name of SEGGER Microcontroller GmbH                  **   nor the names of its contributors may be used to endorse or      **   promote products derived from this software without specific     **   prior written permission.                                        **                                                                    ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND             ** CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,        ** INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF           ** MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE           ** DISCLAIMED.                                                        ** IN NO EVENT SHALL SEGGER Microcontroller GmbH BE LIABLE FOR        ** ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR           ** CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT  ** OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;    ** OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF      ** LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT          ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE  ** USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH   ** DAMAGE.                                                            **                                                                    ***********************************************************************-------------------------- END-OF-HEADER -----------------------------File    : SEGGER_HardFaultHandler.cPurpose : Generic SEGGER HardFault handler for Cortex-MLiterature:[1]  Analyzing HardFaults on Cortex-M CPUs (https://www.segger.com/downloads/appnotes/AN00016_AnalyzingHardFaultsOnCortexM.pdf)Additional information:This HardFault handler enables user-friendly analysis of hard faultsin debug configurations.If a release configuration requires a HardFault handler,a specific HardFault handler should be included instead,which for example issues a reset or turns on an error LED.--------  END-OF-HEADER  ---------------------------------------------*//***********************************************************************       Defines************************************************************************/#define SCB_SHCSR  (*(volatile unsigned int*)  (0xE000ED24u))  // System Handler Control and State Register#define SCB_MMFSR  (*(volatile unsigned char*) (0xE000ED28u))  // MemManage Fault Status Register#define SCB_BFSR   (*(volatile unsigned char*) (0xE000ED29u))  // Bus Fault Status Register#define SCB_UFSR   (*(volatile unsigned short*)(0xE000ED2Au))  // Usage Fault Status Register#define SCB_HFSR   (*(volatile unsigned int*)  (0xE000ED2Cu))  // Hard Fault Status Register#define SCB_DFSR   (*(volatile unsigned int*)  (0xE000ED30u))  // Debug Fault Status Register#define SCB_MMFAR  (*(volatile unsigned int*)  (0xE000ED34u))  // MemManage Fault Manage Address Register#define SCB_BFAR   (*(volatile unsigned int*)  (0xE000ED38u))  // Bus Fault Address Register#define SCB_AFSR   (*(volatile unsigned int*)  (0xE000ED3Cu))  // Auxiliary Fault Status Register#ifndef   DEBUG         // Should be overwritten by project settings#define DEBUG   (0)   // in debug builds#endif/***********************************************************************       Prototypes************************************************************************/#ifdef __cplusplusextern "C" {#endifvoid HardFaultHandler(unsigned int* pStack);#ifdef __cplusplus}#endif/***********************************************************************       Static data************************************************************************/#if DEBUGstatic volatile unsigned int _Continue;  // Set this variable to 1 to run furtherstatic struct {struct {volatile unsigned int r0;            // Register R0volatile unsigned int r1;            // Register R1volatile unsigned int r2;            // Register R2volatile unsigned int r3;            // Register R3volatile unsigned int r12;           // Register R12volatile unsigned int lr;            // Link registervolatile unsigned int pc;            // Program counterunion {volatile unsigned int word;struct {unsigned int IPSR :  8;          // Interrupt Program Status register (IPSR)unsigned int EPSR : 19;          // Execution Program Status register (EPSR)unsigned int APSR :  5;          // Application Program Status register (APSR)} bits;} psr;                               // Program status register.} SavedRegs;union {volatile unsigned int word;struct {unsigned int MEMFAULTACT       :  1;   // [0]  Read as 1 if memory management fault is activeunsigned int BUSFAULTACT       :  1;   // [1]  Read as 1 if bus fault exception is activeunsigned int HARDFAULTACT      :  1;   // [2]  Read as 1 if hard fault exception is active (ARMv8-M)unsigned int USGFAULTACT       :  1;   // [3]  Read as 1 if usage fault exception is activeunsigned int SECUREFAULTACT    :  1;   // [4]  Read as 1 if secure fault exception is active (ARMv8-M)unsigned int NMIACT            :  1;   // [5]  Read as 1 if NMI exception is active (ARMv8-M)unsigned int                   :  1;unsigned int SVCALLACT         :  1;   // [7]  Read as 1 if SVC exception is activeunsigned int MONITORACT        :  1;   // [8]  Read as 1 if debug monitor exception is activeunsigned int                   :  1;unsigned int PENDSVACT         :  1;   // [10] Read as 1 if PendSV exception is activeunsigned int SYSTICKACT        :  1;   // [11] Read as 1 if SYSTICK exception is activeunsigned int USGFAULTPENDED    :  1;   // [12] Usage fault pending; higher priority exception activeunsigned int MEMFAULTPENDED    :  1;   // [13] Memory management fault pending; higher priority exception activeunsigned int BUSFAULTPENDED    :  1;   // [14] Bus fault pending; higher priority exception activeunsigned int SVCALLPENDED      :  1;   // [15] SVC pending; higher priority exception activeunsigned int MEMFAULTENA       :  1;   // [16] Memory management fault exception enableunsigned int BUSFAULTENA       :  1;   // [17] Bus fault exception enableunsigned int USGFAULTENA       :  1;   // [18] Usage fault exception enableunsigned int SECUREFAULTENA    :  1;   // [19] Secure fault exception enable (ARMv8-M)unsigned int SECUREFAULTPENDED :  1;   // [20] Secure fault exception pending; higher priority exception active (ARMv8-M)unsigned int HARDFAULTPENDED   :  1;   // [21] Hard fault exception pending (ARMv8-M)unsigned int                   : 10;} bits;} shcsr;                                   // System Handler Control and State Register (0xE000ED24)union {volatile unsigned char byte;struct {unsigned int IACCVIOL    :  1;     // [0] Instruction access violationunsigned int DACCVIOL    :  1;     // [1] Data access violationunsigned int             :  1;unsigned int MUNSTKERR   :  1;     // [3] Unstacking errorunsigned int MSTKERR     :  1;     // [4] Stacking errorunsigned int MLSPERR     :  1;     // [5] MemManage fault during FP lazy state preservationunsigned int             :  1;unsigned int MMARVALID   :  1;     // [7] Indicates the MMAR is validunsigned int             : 24;} bits;} mmfsr;                               // MemManage Fault Status Register  (0xE000ED28)volatile unsigned int mmfar;           // MemManage Fault Address Register (0xE000ED34)union {volatile unsigned char byte;struct {unsigned int IBUSERR      :  1;      // [0] Instruction access violationunsigned int PRECISERR    :  1;      // [1] Precise data access violationunsigned int IMPRECISERR  :  1;      // [2] Imprecise data access violationunsigned int UNSTKERR     :  1;      // [3] Unstacking errorunsigned int STKERR       :  1;      // [4] Stacking errorunsigned int LSPERR       :  1;      // [5] Bus fault during FP lazy state preservationunsigned int              :  1;unsigned int BFARVALID    :  1;      // [7] Indicates BFAR is validunsigned int              : 24;} bits;} bfsr;                                // Bus Fault Status Register  (0xE000ED29)volatile unsigned int bfar;            // Bus Fault Address Register (0xE000ED38)union {volatile unsigned short halfword;struct {unsigned int UNDEFINSTR :  1;      // [0] Attempts to execute an undefined instructionunsigned int INVSTATE   :  1;      // [1] Attempts to switch to an invalid state (e.g., ARM)unsigned int INVPC      :  1;      // [2] Attempts to do an exception with a bad value in the EXC_RETURN numberunsigned int NOCP       :  1;      // [3] Attempts to execute a coprocessor instructionunsigned int STKOF      :  1;      // [4] Indicates whether a stack overflow error has occurred (ARMv8-M)unsigned int            :  3;unsigned int UNALIGNED  :  1;      // [8] Indicates that an unaligned access fault has taken placeunsigned int DIVBYZERO  :  1;      // [9] Indicates a divide by zero has taken place (can be set only if DIV_0_TRP is set)unsigned int            : 22;} bits;} ufsr;                                // Usage Fault Status Register (0xE000ED2A)union {volatile unsigned int word;struct {unsigned int             :  1;unsigned int VECTTBL     :  1;     // [1] Indicates hard fault is caused by failed vector fetchunsigned int             : 28;unsigned int FORCED      :  1;     // [30] Indicates hard fault is taken because of bus fault/memory management fault/usage faultunsigned int DEBUGEVT    :  1;     // [31] Indicates hard fault is triggered by debug event} bits;} hfsr;                                // Hard Fault Status Register (0xE000ED2C)union {volatile unsigned int word;struct {unsigned int HALTED   :  1;        // [0] Halt requested in NVICunsigned int BKPT     :  1;        // [1] BKPT instruction executedunsigned int DWTTRAP  :  1;        // [2] DWT match occurredunsigned int VCATCH   :  1;        // [3] Vector fetch occurredunsigned int EXTERNAL :  1;        // [4] EDBGRQ signal assertedunsigned int PMU      :  1;        // [5] PMU counter overflow event has occurredunsigned int          : 26;} bits;} dfsr;                                // Debug Fault Status Register (0xE000ED30)volatile unsigned int afsr;            // Auxiliary Fault Status Register (0xE000ED3C), Vendor controlled (optional)} HardFaultRegs;#endif/***********************************************************************       Global functions************************************************************************//***********************************************************************       HardFaultHandler()**  Function description*    C part of the hard fault handler which is called by the assembler*    function HardFault_Handler*/void HardFaultHandler(unsigned int* pStack) {//// In case we received a hard fault because of a breakpoint instruction, we return.// This may happen when using semihosting for printf outputs and no debugger is connected,// i.e. when running a "Debug" configuration in release mode.//if (SCB_HFSR & (1u << 31)) {SCB_HFSR |=  (1u << 31);      // Reset Hard Fault status*(pStack + 6u) += 2u;         // PC is located on stack at SP + 24 bytes. Increment PC by 2 to skip break instruction.return;                       // Return to interrupted application}#if DEBUG//// Read NVIC registers//HardFaultRegs.shcsr.word    = SCB_SHCSR;  // System Handler Control and State RegisterHardFaultRegs.mmfsr.byte    = SCB_MMFSR;  // MemManage Fault Status RegisterHardFaultRegs.mmfar         = SCB_MMFAR;  // MemManage Fault Address RegisterHardFaultRegs.bfsr.byte     = SCB_BFSR;   // Bus Fault Status RegisterHardFaultRegs.bfar          = SCB_BFAR;   // Bus Fault Manage Address RegisterHardFaultRegs.ufsr.halfword = SCB_UFSR;   // Usage Fault Status RegisterHardFaultRegs.hfsr.word     = SCB_HFSR;   // Hard Fault Status RegisterHardFaultRegs.dfsr.word     = SCB_DFSR;   // Debug Fault Status RegisterHardFaultRegs.afsr          = SCB_AFSR;   // Auxiliary Fault Status Register//// Halt execution// If NVIC registers indicate readable memory, change the variable value to != 0 to continue execution.//_Continue = 0u;while (_Continue == 0u) {}//// Read saved registers from the stack.//HardFaultRegs.SavedRegs.r0       = pStack[0];  // Register R0HardFaultRegs.SavedRegs.r1       = pStack[1];  // Register R1HardFaultRegs.SavedRegs.r2       = pStack[2];  // Register R2HardFaultRegs.SavedRegs.r3       = pStack[3];  // Register R3HardFaultRegs.SavedRegs.r12      = pStack[4];  // Register R12HardFaultRegs.SavedRegs.lr       = pStack[5];  // Link register LRHardFaultRegs.SavedRegs.pc       = pStack[6];  // Program counter PCHardFaultRegs.SavedRegs.psr.word = pStack[7];  // Program status word PSR//// Halt execution// To step out of the HardFaultHandler, change the variable value to != 0.//_Continue = 0u;while (_Continue == 0u) {}#else//// If this module is included in a release configuration, simply stay in the HardFault handler//(void)pStack;do {} while (1);#endif}/*************************** End of file ****************************/

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

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

【Python脚本随手笔记】-- 将 “庆余年2” 等信息写入 Txt 文件中

&#x1f48c; 所属专栏&#xff1a;【Python脚本随手笔记】 &#x1f600; 作  者&#xff1a;我是夜阑的狗&#x1f436; &#x1f680; 个人简介&#xff1a;一个正在努力学技术的CV工程师&#xff0c;专注基础和实战分享 &#xff0c;欢迎咨询&#xff01; &#…

《Effective Objective-C 2.0》读书笔记——接口与API设计

目录 第三章&#xff1a;接口与API设计第15条&#xff1a;用前缀避免命名空间冲突第16条&#xff1a;提供“全能初始化方法”第17条&#xff1a;实现description方法第18条&#xff1a;尽量使用不可变对象第19条&#xff1a;使用清晰而协调的命名方式第20条&#xff1a;为私有方…

Altair® Squeak and Rattle Director™ 品质认知度解决方案

Altair Squeak and Rattle Director™ 品质认知度解决方案 借助 Altair 的 Squeak and Rattle Director&#xff0c;计算机辅助工程 (CAE) 的工程专业人士和初学者都能在早期设计阶段快速识别并消除产品中的异响。通过在简化的半自动化流程&#xff08;已完全集成到 Altair Hy…

【ELK日志收集过程】

文章目录 为什么要使用ELK收集日志ELK具体应用场景ELK日志收集的流程 为什么要使用ELK收集日志 使用 ELK&#xff08;Elasticsearch, Logstash, Kibana&#xff09;进行日志收集和分析有多种原因。ELK 堆栈提供了强大、灵活且可扩展的工具集&#xff0c;能够满足现代 IT 系统对…

VMware ESXI 7.0安装部署

1、为什么要虚拟化&#xff1f; 目前&#xff0c;物理服务器存在以下几个问题&#xff1a; 1&#xff09;硬件资源利用率低&#xff1b; 2&#xff09;可靠性不足&#xff0c;物理服务器宕机即可造成整体业务停摆&#xff1b; 3&#xff09;维护量大&#xff0c;无法实现统…

人工智能的明天:机器学习与自动化的演进之旅

方向一&#xff1a;技术革新与行业应用 现状分析&#xff1a; 当前的IT行业正处于一个技术革新的高峰期。量子计算虽然还处于研究和开发阶段&#xff0c;但其潜力巨大&#xff0c;未来可能在药物发现、材料科学和复杂系统模拟等领域带来突破。虚拟现实&#xff08;VR&#xff…

JAVA面试题大全(九)

1、为什么要使用 spring&#xff1f; 方便解耦&#xff0c;便于开发支持aop编程声明式事务的支持方便程序的测试方便集成各种优秀的框架降低JavaEE API的使用难度 2、解释一下什么是 aop&#xff1f; AOP 是 Aspect-Oriented Programming 的缩写&#xff0c;中文翻译为“面向…

argparse.ArgumentParser()用法举例

1. 应用场景 我们在玩深度学习&#xff0c;训练模型的时候&#xff0c;会涉及到很多的参数&#xff0c;这个时候就需要用到argparse.ArgumentParser()方法&#xff0c;它的优点是方便在命令行调用的时候修改参数&#xff0c;为了快速了解该方法的应用&#xff0c;这里举例说明…

深度学习之Tensorflow卷积神经网络手势识别

欢迎大家点赞、收藏、关注、评论啦 &#xff0c;由于篇幅有限&#xff0c;只展示了部分核心代码。 文章目录 一项目简介 二、功能三、系统四. 总结 一项目简介 一、项目背景与意义 手势识别是计算机视觉和人工智能领域的重要应用之一&#xff0c;具有广泛的应用前景&#xff…

编曲软件FL Studio如何为自己制作的歌曲编写工程信息 flstudio自带工程在哪

FL Studio有着很多的功能&#xff0c;覆盖面非常广&#xff0c;不管是音色调整、界面个性化还是为工程编写信息&#xff0c;都可以在FL Studio中使用。每个工程文件都有它的各种信息&#xff0c;比如标题名称、作者、音乐类型、工程介绍、创建时间等&#xff0c;编写工程信息能…

Vue前端项目打包,并部署Vue项目到Linux云服务器上

一. vue前端项目打包 1.使用vscode开发项目 2.在config目录下的prod.env.js文件当中配置我们后端服务器的IP地址和端口号&#xff0c;因为这是在实际的部署当中所以必须要在生成环境下进行项目的部署。 如图所示&#xff1a; 3.在config目录下的index.js文件当中要改assetsPu…

Linux配置nginx代理功能

ywtool运维工具下载链接及介绍: 工具下载/介绍/安装页面 目录 一.nginx proxy功能介绍二.配置nginx proxy功能2.1 新增nginx代理配置2.1.1 反向代理(当前只举例https转https)2.1.2 负载均衡(当前只举例https转https) 2.2 修改nginx代理配置2.2.1 手动修改配置文件2.2.2 通过此脚…

U盘文件神秘失踪?别担心,恢复与预防攻略在此!

一、遭遇困境&#xff1a;U盘文件突然不见 在数字时代&#xff0c;U盘已成为我们日常工作中不可或缺的数据存储工具。然而&#xff0c;有时我们可能会遭遇一个令人头疼的问题——U盘中的文件突然不见了。这种情况往往让人措手不及&#xff0c;尤其是对于那些没有备份重要文件的…

Gitlab OpenSSL::Cipher::CipherError(gitlab修改项目500错误)

问题描述 在对 gitlab 进行项目修改保存时候&#xff0c;出现了 500 错误&#xff0c;经查看日志&#xff0c;发现 OpenSSL::Cipher::CipherError 异常&#xff0c;如下图所示&#xff1a; > /var/log/gitlab/gitlab-rails/production.log <OpenSSL::Cipher::CipherErro…

“深度解析:等级保护测评的核心要素与实施流程“

等级保护测评的核心要素与实施流程是确保信息系统安全的重要环节。以下是对等级保护测评的核心要素和实施流程的深度解析&#xff1a; 核心要素 等级测评概述 1 等级测评是依据国家信息安全等级保护制度规定&#xff0c;对信息系统的安全状况进行检测评估&#xff0c;判定系统…

【Hive SQL 每日一题】行列转换

文章目录 行转列列传行 行转列 测试数据&#xff1a; DROP TABLE IF EXISTS student_scores;CREATE TABLE student_scores (student_id INT,subject STRING,score INT );INSERT INTO student_scores (student_id, subject, score) VALUES (1, Math, 85), (1, English, 78), (…

5月23日学习记录

[CSAWQual 2019]Unagi 涉及&#xff1a;xxe漏洞&#xff0c;外来编码xml绕过 打开环境&#xff0c;发现存在文件上传 简单上传一个php 毫无疑问上传失败&#xff0c;说是存在waf&#xff0c;绕过waf才能上传&#xff0c;点击here看看 xml编码&#xff0c;可能存在xxe漏洞&…

【计算机毕业设计】基于SSM++jsp的网上服装销售系统【源码+lw+部署文档】

目录 第一章 绪 论 第二章 关键技术的研究 2.1 JSP技术介绍 2.2 JAVA简介 2.3 ECLIPSE 开发环境 2.4 Tomcat服务器 2.5 MySQL数据库 第三章 系统分析 3.1 系统设计目标 3.2 系统可行性分析 3.3 系统功能分析和描述 3.4系统UML用例分析 3.4.1管理员用例 3.4.2用户用例 3.5系统流…

LeetCode刷题之HOT100之找到数组中消失的数字

2024/5/24 今天早上没有下雨&#xff0c;太好了。下周就要搬到二楼会议室开发了&#xff0c;很多计划都要被打破了。事已至此&#xff0c;先做题吧! 2、逻辑分析 题目的要求是&#xff1a;给定一个长度为n的整数数组nums&#xff0c;要输出在[1&#xff0c;n]范围内但没有出现…

JS 实现鼠标框选(页面选择)时返回对应的 HTML 或文案内容

JS 实现鼠标框选&#xff08;页面选择&#xff09;时返回对应的 HTML 或文案内容 一、需求背景 1、项目需求 当用户进行鼠标框选选择了页面上的内容时&#xff0c;把选择的内容进行上报。 2、需求解析 虽然这需求就一句话的事&#xff0c;但是很显然&#xff0c;没那么简单…