Regular Expression Commands

本文介绍如何在LLDB中使用正则表达式命令,包括定义和使用自定义命令,如通过f命令选择帧,以及如何通过正则表达式匹配和替换来简化复杂的命令输入。

Friday, April 22, 2011

Regular Expression Commands

Greetings LLDB users. I want to start writing regular blog posts for the new and cool features and things you can do in LLDB. Today I will start with one that was just added: regular expression commands.

What is a regular expression command? It is a smart alias to other commands that you can define using the “command regex” command. You define a regular expression command by giving it a command name followed by a series of regular expression and substitution pairs. The regular expression and substitution pairs are supplied in a standard stream editor search and replace format:

s///

When a command in later entered, it will strip off the regular expression command name and any spaces that follow, it and pass the raw argument string to be matched against your regular expression list in the order in which they were entered. The first to match the raw argument string will then be allowed substitute in the command defined by .

Lets supposed we want to use the "f" as a command to select a frame by frame index. The command to select a frame by the frame index is the "frame select " command which you might not always want to type out. We can make this a bit easier this using a regular expression command:

(lldb) command regex f 's/([0-9]+)/frame select %1/' 

"command regex f" tells the interpreter to create a new regex command named "f", and when a command is entered on the command line that starts with "f", it will match the remaining command text against the regular expression "([0-9]+)", and it if matches, it will substitute any parenthesized subexpressions. Here we enclosed the number regular expression "[0-9]+" in parentheses which will save the results in the first match and allow the matching string to be substituted into the match substitution text "frame select %1". When we use our new regular expression command from the LLDB command line, it will show us what command resulted from our regular expression substitution:

(lldb) f 12
frame select 12

Any leading spaces that follow the regular expression command “f” will always be stripped prior to matching the regular expression, but there may be trailing spaces since we are processing the remaining raw command string that follows the initial "f" command name. The regular expression is also just looking for any sequence of one or more digits. Our current regular expression will actually match:

(lldb) f 11 22 33 frame select 11

Since this isn’t desired, we should make the regular expression more complete by checking for the start of the line (^) and the end of the line ($) and also allow for zero or more spaces ([[:space:]]*) to come after the number. Our newer and safer regular expression command line looks like:

 (lldb) command regex f 's/^([0-9]+)[[:space:]]*$/frame select %1/'

Now we can type in a command as "f 12 " (note the trailing spaces), and still get correct substitutions, while our previous example of "f 11 22 33" will no longer match:

(lldb) f 11 22 33 error: Command contents '11 22 33' failed to match any regular expression in the 'f' regex command.

Lets take this a bit further by also using the f command to emulate GDB’s finish command when it is typed without any arguments. We will also modify this command to watch for a single “+” or “-” followed by a digit to signify a relative frame change using the frame select command with the --relative option:

(lldb) frame select --relative 

Multiple regular expressions can be entered in on the command line, or using the multi-line mode when typing in a live LLDB debug session. Below the text in bold is user entered:

(lldb) commands regex f
Enter regular expressions in the form 's///' and terminate with an empty line:
s/^([0-9]+)[[:space:]]*$/frame select %1/
s/^([+-][0-9]+)[[:space:]]*$/frame select --relative=%1/
s/^[[:space:]]*$/finish/

(lldb) f
finish
...
(lldb) f -1
frame select --relative=-1
...
(lldb) f +1
frame select --relative=+1
...
(lldb) f 12
frame select 12

I hope you can see the possilbities in how you can customize your command line experience in LLDB using these commands. You can add any regular expression commands to your ~/.lldbinit file to always have your regular expression commands defined in your debug sessions.

Posted by Greg Clayton at 10:19 AM

Labels: LLDB

内容概要:本文档介绍了基于3D FDTD(时域有限差分)方法在MATLAB平台上对微带线馈电的矩形天线进行仿真分析的技术方案,重点在于模拟超MATLAB基于3D FDTD的微带线馈矩形天线分析[用于模拟超宽带脉冲通过线馈矩形天线的传播,以计算微带结构的回波损耗参数]宽带脉冲信号通过天线结构的传播过程,并计算微带结构的回波损耗参数(S11),以评估天线的匹配性能和辐射特性。该方法通过建立三维电磁场模型,精确求解麦克斯韦方程组,适用于高频电磁仿真,能够有效分析天线在宽频带内的响应特性。文档还提及该资源属于一个涵盖多个科研方向的综合性MATLAB仿真资源包,涉及通信、信号处理、电力系统、机器学习等多个领域。; 适合人群:具备电磁场与微波技术基础知识,熟悉MATLAB编程及数值仿真的高校研究生、科研人员及通信工程领域技术人员。; 使用场景及目标:① 掌握3D FDTD方法在天线仿真中的具体实现流程;② 分析微带天线的回波损耗特性,优化天线设计参数以提升宽带匹配性能;③ 学习复杂电磁问题的数值建模与仿真技巧,拓展在射频与无线通信领域的研究能力。; 阅读建议:建议读者结合电磁理论基础,仔细理解FDTD算法的离散化过程和边界条件设置,运行并调试提供的MATLAB代码,通过调整天线几何尺寸和材料参数观察回波损耗曲线的变化,从而深入掌握仿真原理与工程应用方法。
内容概要:本文系统介绍了无人机测绘在多个领域的广泛应用,重点阐述了其在基础地理信息测绘、工程建设、自然资源与生态环境监测、农业与农村管理、应急救灾以及城市管理等方面的实践价值。无人机凭借灵活作业、低成本、高精度和快速响应的优势,结合航测相机、LiDAR、多光谱、热成像等多种传感器,能够高效获取DOM、DSM、DEM、DLG等关键地理数据,并生成三维模型,显著提升测绘效率与精度,尤其适用于复杂地形和紧急场景。文章还强调了无人机在不同时期工程项目中的动态监测能力及在生态环保、土地确权、灾害应急等方面的数据支撑作用。; 适合人群:从事测绘、地理信息系统(GIS)、城乡规划、自然资源管理、农业信息化、应急管理等相关工作的技术人员与管理人员;具备一定地理信息基础知识的专业人员;无人机应用从业者或爱好者。; 使用场景及目标:①了解无人机测绘的技术优势及其在各行业中的具体应用场景;②为实际项目中选择合适的无人机测绘方案提供参考依据;③支持政府部门、企事业单位在土地管理、工程建设、灾害应对等领域实现数字化、智能化决策。; 阅读建议:此资源以应用为导向,涵盖了技术原理与实践案例,建议结合具体业务需求深入研读,并可进一步索取“无人机测绘设备选型与作业流程清单”以指导实际操作。
(D:\ruanjian\anaconda3) C:\Windows\System32>conda usage: conda [-h] [-V] command ... conda is a tool for managing and deploying applications, environments and packages. Options: positional arguments: command info Display information about current conda install. help Displays a list of available conda commands and their help strings. list List linked packages in a conda environment. search Search for packages and display their information. The input is a Python regular expression. To perform a search with a search string that starts with a -, separate the search from the options with --, like 'conda search -- -h'. A * in the results means that package is installed in the current environment. A . means that package is not installed but is cached in the pkgs directory. create Create a new conda environment from a list of specified packages. install Installs a list of packages into a specified conda environment. update Updates conda packages to the latest compatible version. This command accepts a list of package names and updates them to the latest versions that are compatible with all other packages in the environment. Conda attempts to install the newest versions of the requested packages. To accomplish this, it may update some packages that are already installed, or install additional packages. To prevent existing packages from updating, use the --no-update-deps option. This may force conda to install older versions of the requested packages, and it does not prevent additional dependency packages from being installed. If you wish to skip dependency checking altogether, use the '--force' option. This may result in an environment with incompatible packages, so this option must be used with great caution. upgrade Alias for conda update. See conda update --help. remove Remove a list of packages from a specified conda environment. uninstall Alias for conda remove. See conda remove --help. config Modify configuration values in .condarc. This is modeled after the git config command. Writes to the user .condarc file (C:\Users\60925\.condarc) by default. clean Remove unused packages and caches. package Low-level conda package utility. (EXPERIMENTAL) optional arguments: -h, --help Show this help message and exit. -V, --version Show the conda version number and exit. other commands, such as "conda build", are available when additional conda packages (e.g. conda-build) are installed (D:\ruanjian\anaconda3) C:\Windows\System32>conda update conda Fetching package metadata ..... Solving package specifications: . # All requested packages already installed. # packages in environment at D:\ruanjian\anaconda3: # conda 4.3.30 py36h7e176b0_0 http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free (D:\ruanjian\anaconda3) C:\Windows\System32>
06-27
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值