如何使用Android Studio调试器退回一行代码 [英] How to step back a line of code with Android Studio debugger

查看:223
本文介绍了如何使用Android Studio调试器退回一行代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是调试器的新手.当我浏览一行代码时,我想知道如何退后一步.现在我意识到代码不能向后执行?如果要退回到旧行,是否必须在调试中重新启动活动?

I am new to the debugger. When I step over a line of code, I was wondering how to step back. Now I'm realizing that the code can't be executed backwards? Do I have to restart the activity in debug if I want to step back to old lines?

此外,如果您不介意的话,force-step-into命令是什么?

Also, if you don't mind, what is the force-step-into command?

推荐答案

不要认为这是可能的. Android像所有其他调试器一样工作,它们或多或少是代码上的瀑布.您不能真正地向后退,但是那是断点所在的地方.在您想向后退的行之前放置一个断点,然后重新运行您的应用程序,它将一直继续下去,直到到达该行为止.

Don't think that is possible. Android works like all other debuggers, which are more or less waterfalls over the code. You can't really step backwards, but thats where breakpoints come in. Place a break point before the line you wanted to step backward on and rerun your app, it'll keep going until it hits that line.

为了解释强制进入,我将首先解释逐步进入/结束. Step-Over会看到您想要的行,然后越过它,在进行函数调用之后,在同一文件中的该行处停止.另一方面,Step Into进入函数调用并在该函数调用的第一行停止,可能位于新文件或新位置.在Android中,有很多功能被认为是黑匣子",您实际上并不在乎它们的作用,因为它们很可能不会影响代码(例如Log.d函数).如果需要,可以强制进入.

To explain Force-Step-Into I'm going to explain Step-Into/Over first. Step-Over sees the line you want, and steps over it, stopping at the line in the same file after the function call was made. Step Into on the other hand steps into the function call and stops on the first line of that function call, could be in a new file or a new location. In Android, there are a lot of functions that are considered "Black Boxes" where you don't really care what they do since they most probably don't affect the code (Like the Log.d function). Force Step Into allows you to step into those if you'd want to.

来源: 查看全文

登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆