PowerShe 命令行调试指引(转)

How to manage a debugging session

Before you start debugging, you must set one or more breakpoints. You cannot set a breakpoint unless the script that you want to debug is saved. For directions on of how to set a breakpoint, see How to manage breakpoints or Set-PSBreakpoint. After you start debugging, you cannot edit a script until you stop debugging. A script that has one or more breakpoints set is automatically saved before it is run.

To start debugging

Press F5 or, on the toolbar, click the Run Script icon, or on the Debug menu click Run/Continue. The script runs until it encounters the first breakpoint. It pauses operation there and highlights the line on which it paused.

To continue debugging

Press F5 or, on the toolbar, click the Run Script icon, or on the Debug menu, click Run/Continue or, in the Console Pane, type C and then press ENTER. This causes the script to continue running to the next breakpoint or to the end of the script if no further breakpoints are encountered.

To view the call stack

The call stack displays the current run location in the script. If the script is running in a function that was called by a different function, then that is represented in the display by additional rows in the output. The bottom-most row displays the original script and the line in it in which a function was called. The next line up shows that function and the line in it in which another function might have been called. The top-most row shows the current context of the current line on which the breakpoint is set.

While paused, to see the current call stack, press CTRL+SHIFT+D or, on the Debug menu, click Display Call Stack or, in the Console Pane, type K and then press ENTER.

To stop debugging

Press SHIFT-F5 or, on the Debug menu, click Stop Debugger, or, in the Console Pane, type Q and then press ENTER.

How to step over, step into, and step out while debugging

Stepping is the process of running one statement at a time. You can stop on a line of code, and examine the values of variables and the state of the system. The following table describes common debugging tasks such as stepping over, stepping into, and stepping out.

Debugging Task Description How to accomplish it in PowerShell ISE
Step Into Executes the current statement and then stops at the next statement. If the current statement is a function or script call, then the debugger steps into that function or script, otherwise it stops at the next statement. Press F11 or, on the Debug menu, click Step Into, or in the Console Pane, type S and press ENTER.
Step Over Executes the current statement and then stops at the next statement. If the current statement is a function or script call then the debugger executes the whole function or script, and it stops at the next statement after the function call. Press F10 or, on the Debug menu, click Step Over, or in the Console Pane, type V and press ENTER.
Step Out Steps out of the current function and up one level if the function is nested. If in the main body, the script is executed to the end, or to the next breakpoint. The skipped statements are executed, but not stepped through. Press SHIFT+F11, or on the Debug menu, click Step Out, or in the Console Pane, type O and press ENTER.
Continue Continues execution to the end, or to the next breakpoint. The skipped functions and invocations are executed, but not stepped through. Press F5 or, on the Debug menu, click Run/Continue, or in the Console Pane, type C and press ENTER.

How to display the values of variables while debugging

You can display the current values of variables in the script as you step through the code.

To display the values of standard variables

Use one of the following methods:

  • In the Script Pane, hover over the variable to display its value as a tool tip.
  • In the Console Pane, type the variable name and press ENTER.

All panes in ISE are always in the same scope. Therefore, while you are debugging a script, the commands that you type in the Console Pane run in script scope. This allows you to use the Console Pane to find the values of variables and call functions that are defined only in the script.

To display the values of automatic variables

You can use the preceding method to display the value of almost all variables while you are debugging a script. However, these methods do not work for the following automatic variables.

  • $_
  • $Input
  • $MyInvocation
  • $PSBoundParameters
  • $Args

If you try to display the value of any of these variables, you get the value of that variable for in an internal pipeline the debugger uses, not the value of the variable in the script. You can work around this for a few variables ($_, $Input, $MyInvocation, $PSBoundParameters, and $Args) by using the following method:

  1. In the script, assign the value of the automatic variable to a new variable.
  2. Display the value of the new variable, either by hovering over the new variable in the Script Pane, or by typing the new variable in the Console Pane.

转自:How to Debug Scripts in Windows PowerShell ISE

时间: 2024-11-10 02:09:11

PowerShe 命令行调试指引(转)的相关文章

u-boot命令行调试LCD简单记录

一般来说,调试uboot最好的方式是使用openjtag,因为uboot说到底就是一段裸机程序,只不过比较复杂.但是受实际环境限制,实际工作中使用较多的调试技巧主要有两种:打印和直接在命令行测试,打印比较常见也比较简单,直接使用printf即可,这里就以最近这段时间调试uboot下面lcd为例,简单说说命令行调试. 平台: am335x,u-boot 2010.09,linux 3.10 问题: 由于此版本u-boot比较旧,没有整套framebuffer子系统框架,所以采取的是移植好官方裸机驱

perl-cgi命令行调试

来源: http://www.cnblogs.com/itech/archive/2012/09/23/2698838.html 参考: http://docstore.mik.ua/orelly/linux/cgi/ch15_03.htm http://stackoverflow.com/questions/2224158/how-can-i-send-post-and-get-data-to-a-perl-cgi-script-via-the-command-line http://sear

使用GDB命令行调试器调试C/C++程序【转】

转自:https://linux.cn/article-4302-1.html 编译自:http://xmodulo.com/gdb-command-line-debugger.html作者: Adrien Brochard原创:LCTT https://linux.cn/article-4302-1.html译者: SPccman本文地址:https://linux.cn/article-4302-1.html 2014-11-25 21:48    评论: 31 收藏: 19 分享: 43

使用GDB命令行调试器调试C/C++程序

没有调试器的情况下编写程序时最糟糕的状况是什么?编译时跪着祈祷不要出错?用血祭召唤恶魔帮你运行程序?或者在每一行代码间添加printf("test")语句来定位错误点?如你所知,编写程序时不使用调试器的话是不方便的.幸好,linux下调试还是很方便的.大多数人使用的IDE都集成了调试器,但 linux 最著名的调试器是命令行形式的C/C++调试器GDB.然而,与其他命令行工具一致,DGB需要一定的练习才能完全掌握.这里,我会告诉你GDB的基本情况及使用方法. 安装GDB 大多数的发行版

ubuntu下命令行调试Python程序

Python提供类似于C++ gdb的调试工具pdb,我们可以在Linux下使用pdb在命令行下进行Python程序的调试. 官方参考网站: Python2: https://docs.python.org/2/library/pdb.html Python3: https://docs.python.org/3/library/pdb.html 一般地,我们可以使用如下的方式进入调试(比如我们要调试的源文件为hello.py): 1. 在命令行启动目标程序,加上-m参数. python -m

基于DEV的命令行调试

这个在main函数参数使用挺有用的. 在电脑里面找到Dev-Cpp安装位置(或许在C:\Program Files(x86)) 戳进去,在Dev-Cpp目录里面搜索bin文件夹地址,并记着(或不记也行,等下要用再找=.=) 右键我的电脑,选择属性 选择高级系统设置 选环境变量(在弹出框较下部分) 点Path后点编辑 把一开始那些地址和加上\bin的地址都新建加入这个框内 各种确定 保存~ 菜单键+R 输入cmd打开命令行 输入 g++ -o exeName CppFileAddress地址可以拖

使用GDB命令行调试C/C++程序

#include <stdio.h> #include <stdlib.h> int main(int argc, char **argv) { int i; int a=0, b=0, c=0; double d; for (i=0; i<100; i++) { a++; if (i>97) d = i / 2.0; b++; } return 0; } GDB的使用 首先最重要的,你需要使用编译器的 "-g"选项来编译程序,这样可执行程序才能通过

一幅图告诉你所有的NodeJS命令行调试语句

NodeJS提供脚本调试. 输入node debug xx.js即可进入调试模式.

一张地图,告诉你NodeJS命令行调试器语句

NodeJS提供脚本调试. 进入node debug xx.js您可以进入调试模式. 版权声明:本文博客原创文章,博客,未经同意,不得转载.