Basic information on Chrome's Debugger

本文介绍如何使用Chrome浏览器内置的调试器进行网页调试。包括设置断点、查看参数及局部变量等基本操作。适用于初学者快速上手。

Forwarded from: http://www.pascarello.com/lessons/browsers/ChromeDebugHelp.html


Tags: Chrome Debug


I have been seeing a bunch of questions on how to use chrome's debugger so this is my quick and dirty instruction/tutorial/help page. Hopefully when I get some sleep I can make it better! For right now I tried to get the basics down with a quick walk through example. This is not edited, spell checked, grammer checked, verified, fully completed, fully documented, etc. I wrote it at 2AM! I will edit it!

Initial Findings - Bugs - Quirks

I am finding the debugger to be a little buggy, especially when the JavaScript Console is open with the Debugger. My Chrome Browser has disappeared from the screen like magic. The stepping can lock up and leave you hanging. I am using this on a VERY simple page and having issues. I have not tried this on anything major.

If you close the debugger after you set debug points, the debug points remain. BUT there is a problem with it. When you try to read their info, clear them, or run the code it errors. Looks like they are removed from some sort of memory, but the references are left in the code itself.

I am running this on a Vista Home Premium on a MacBook with Boot Camp with 2 gigs of RAM. I use this set-up daily for some .NET development. If I can track down the errors, I will see if I can log them. For now I am just learning about this thing!

The Commands

These are the commands that you enter in the textbox at the bottom of the debugger. After you enter them, the debugger shows the command with a $ in fornt of it. The follow line(s) will be the output of the command that you enter. There are two command sets depending on the state that the debugger is in: running and paused. NOTE: [] is optional - <> is required

Commands while page is running (no breakpoints hit)

break [condition]
Set a break point where the location is <function> or <script:function> or <script:line> or <script:line:pos>
break_info [breakpoint #]
List the current breakpoints [or the details of the breakpoint that is specified]
clear <breakpoint #>
Remove a specified breakpoint
help [command]
Display the help information for the current status [or the specified command]
print <expression>
Output the expression specified which can be string, object, function, variable, etc.
scripts
List all of the scripts attached to the page.

Commands while page is paused in debugging mode (Break point is hit)

args
Summerize the arguments to the current function. Does not display anything if there are no arguments.
break [condition]
See Running Description
break_info [breakpoint #]
See Running Description
backtrace [<from frame #> <to frame #>]
Look at all the current frames [or look at the frames specified in the range.]* Looks like you need to specify both. Changed notation here compared to the help in the debugger *
clear
See Running Description
continue
Continues the execution of the script.
frame [frame #]
Shows the current frame [or shows the specified frame]
help
See Running Description
locals
Summarize the local variables for current frame. Displays the variables and their values.
next
Moves to the next line in the code. Seems to be like step.
print
See Running Description
scripts
See Running Description
source [from line] | [<from line> <num lines>]
Show the current functions source code [or see a specified line or range of lines]
step
Step through the code line by line when paused in debug mode. * Not sure what is different between step and next *
stepout
* Seems to not work! Should step out of the current debugging step. It should work like continue! *

Basic Walk Through

This should show you how to do some basic steps of adding 2 break points, looking at the arguments, and looking at the variables. It is very basic

The code

The code is a simple html page with an external JavaScript file. There are two functions and two buttons that have hard coded event handlers that call the functions.

The HTML Page
<html>
<head>

<title>TEST</title>

<script type="text/javascript">
function hello1(){
var d = new Date();
var str = "Hello World - One./n/nIt is ";
alert( str + d.toString() );
}
</script>

<script type="text/javascript" src="hello2.js"></script>


</head>
<body>
<input type="button" onclick="hello1()" value="Hello 1" />
<input type="button" onclick="hello2('hey hey')" value="Hello 2" />
</body>
</html>
hello2.js
function hello2( foo ){
var d = new Date();
var str = foo + "/n/nHello World - Two./n/nIt is ";
alert( str + d.toString() );
}

Do the walking!

Save the code to your system or use your own project and open it up in Chrome. If you have not opened up the debugger yet it is located at the Page Icon --> Developer --> JavaScript Debugger or use the short cut ALT+`. You should see a large scrollable area and a textbox. You will be entering in the commands at the textbox at the bottom.

If you type in help and hit enter, it will bring up a list of the commands you can use right now. We will strat off with using scripts. Type scripts into the command line, hit enter, and you should see references to the scripts attached to the html page. Notice if you have the JavaScript console, there are tons of other JS files attached.

We can not add our breakpoints. The simpliest way is to use the function name to specify the location. In the example code we have two functions hello1() and hello2(). To verify that the functions are there we can use print. Type print hello1 into the command line and you should see the functions code. Since we know the function is there, we can than type in break hello1 and hit enter. That sets breakpoint 0 to the hello0 function. We than type in break hello2 and we get breakpoint 1 attached to the hello2 function.

To verify that the breakpoints are added, we use break_info in the command line and it should show us our two break points. To just see the info for our second break point we can specify the number such as break_info 1. The details for the break point is shown.

After we set the break points, we should try to hit them. If you are using the provided code, click the first button. This button has no arguments passed in. When you hit the button, the debugger should said it is paused. Type in args into the debugger's commandline and it should not show anything. Type in next and the next line should appear and execute. To view the local variables, you can type in locals into the commandline. It will show you the name/value pairs of all the local variables in the hello0 function. You can now either keep typing the next command to step through the rest of the functions lines or you can type in the command continue.

This time click the second button to start the debugger again. Type in the args command and this time you should see the name value pairs of the passed in arguments since hello2 has arguments. You can use the print command to output the variables at this time to debug if you wish. You can also use source to view the current functions source code. Instead of using next to step through the lines of code, you can also use step. I would not advise using stepall since it hangs my debugger. Run through the rest of the steps to show the alert.

Finally if we want to remove a break point, we can use the clear command. To remove the second break point, type in clear 1. Now the breakpoint should not be hit when we click the second button on our page.

Well that was a quick walk-through with the debugger. Hopefully it will be as pretty as Firebug's one day. I also hope to get this article in better shape when I am actually awake enough to edit this blabbling.

Hope this helps,
Eric Pascarello

内容概要:本文聚焦2026年高教社杯全国大学生数学建模竞赛B题“无线电干扰源的快速自动定位与清除”,提供涵盖数学建模、算法实现与论文撰写的全套技术支持,并扩展分享多个科研方向的Matlab/Simulink仿真项目,如无人机协同路径规划、电力系统无功优化、信号处理、图像处理、车间调度、新能源预测与优化调度等。资源内容不仅服务于竞赛备赛,还覆盖智能优化、通信定位、边缘计算、雷达追踪、深度学习等多个前沿科研领域,旨在为参赛学生与初级科研人员提供系统化、高质量的技术参考与资源共享。文中强调科研需逻辑严密、善于借力,并倡导按目录系统学习以提升建模能力与科研素养,所有资料可通过指定网盘链接或微信公众号免费获取。; 适合人群:全国大学生数学建模竞赛参赛者,具备Matlab编程与数学建模基础的本科及研究生,以及从事智能优化、信号处理、电力系统、路径规划、机器学习等方向的初级科研人员。; 使用场景及目标:①备战数学建模竞赛,快速掌握赛题解题思路、算法模型与论文写作模板;②开展科研项目时复现经典算法、借鉴成熟仿真方法,提升研究效率;③系统学习多领域(如无人机路径规划、微电网优化、光伏/风电预测、图像处理)的Matlab/Simulink实现技术。; 阅读建议:建议读者按照资源目录顺序系统浏览,结合网盘中的代码与文档进行实践操作,重点关注建模逻辑、算法实现细节与仿真结果分析,同时关注公众号与共享链接以获取完整资料,全面提升竞赛竞争力与科研实践能力。
下载代码方式:https://pan.quark.cn/s/0636d5a2cd63 爱普生1390型宽幅照片打印机是一款备受摄影发烧友及小型设计机构欢迎的经典设备。经过一段时间的持续运作,其供纸辊可能会遭遇磨损或积聚灰尘,进而干扰打印机的正常运作,例如在打印过程中出现纸张移动或卡住等情况。本指南将系统性地阐述对爱普生1390进行拆解并更换供纸辊的具体操作方法。 1. **前期准备** 在着手拆解之前,务必要将打印机关闭并切断电源供应。需要准备一套适配的小型螺丝刀及辅助工具,同时备齐全新的供纸辊。采购供纸辊时,必须核实其与爱普生1390型号完全兼容。 2. **外部拆解** 开始移除打印机的外壳部件。通常情况下,这涉及到松开底部和背面的固定螺栓。在分离外壳时需格外谨慎,以免拉扯到机内部署的电线或线缆。 3. **曝露供纸部件** 继续对内部结构进行拆解,直至定位到供纸辊组件。这个过程可能需要取下墨盒托架、进纸模块等零件。务必记住各个部件的原始位置和朝向,以便后续顺利复原。 4. **拆卸供纸辊** 供纸辊一般通过轴心固定于打印机内部。借助螺丝刀或其他适宜工具松开固定轴,随后轻轻转动或抽离供纸辊。操作过程中需留意避免损伤周边的塑料构件。 5. **清洁或调换供纸辊** 若供纸辊仅因污损,可用柔软布料蘸取少量酒精进行轻柔擦拭,以去除附着物和尘埃。倘若供纸辊已出现损耗,则必须更换为新的。新供纸辊应依照原样安装,确保轴心与齿轮系统精确对接。 6. **重新组装** 依照与拆解相反的顺序,小心地将各个部件逐一装回,确保每部分都准确对齐并牢固固定。特别要注意连接线缆,防止其发生扭曲或过度弯曲。 7. **功能测试** 组装完毕后,重新接入电源,启动打印机,检验其是否能正常...
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值