如何搜索在GDB的TUI模式下打开的文件

时间:2016-07-20 23:59:38

标签: debugging gdb gnu tui

我有一个在gdb的TUI模式下打开几千行的文件。我想在文件中搜索变量,这可能吗?因为文件很长,我真的试图避免手动搜索这个词。

1 个答案:

答案 0 :(得分:1)

手动中没有定义TUI特定的搜索命令。 gdb是调试器,而不是代码导航工具(使用ctags / cscope / lxr / source navigator;或者使用IDE调试器和代码导航器)。

尝试使用gdb(非TUI)命令,但它只适用于下一个位置(我看不到"下一个搜索"这里):

https://sourceware.org/gdb/onlinedocs/gdb/Search.html#Search

  

有两个命令可以在当前源文件中搜索正则表达式。

package lawn;

import java.util.Scanner;
import java.util.List;
import java.util.ArrayList;

/**
 *
 * @author norbe
 */
public class Lawn {

    private double lenght, width;
    private double totalArea;
    private double structureArea;
    private double tot;
    List<Double> list = new ArrayList<Double>();
    public Lawn (){
    return;}

    public Lawn(double Lenght, double Width) {
        this.lenght = Lenght;
        this.width = Width;

    }

    public double getWidth() {
        return width;
    }

    public void setWidth(double Width) {
        this.width = Width;
    }

    public double getLenght() {
        return lenght;
    }

    public void setHeight(double Lenght) {
        this.lenght = Lenght;
    }

    public void getTotalArea() {
        Scanner sc = new Scanner(System.in);
        double lenght;
        double width;
        System.out.println("please enter Total lenght :\t ");
        lenght = sc.nextDouble();
        if (lenght >= 0.0) {
            System.out.println("Please enter width :\t ");
            width = sc.nextDouble();
            if (width > 0.0) {
                totalArea = lenght * width;
                System.out.println("Your total area is :\t " + totalArea);
            } else {
                System.out.println("Invalid entry");
            }
        } else {
            System.out.println("Invalid entry");
        }

    }

    public void getStructureArea() {
        Scanner sc = new Scanner(System.in);
        /*double lenght;
        double width;*/
        System.out.println("please enter Structure lenght :\t ");
        lenght = sc.nextDouble();
        if (lenght >= 0.0) {
            System.out.println("Please enter  Structure width :\t ");
            width = sc.nextDouble();
            if (width > 0.0) {
                structureArea = lenght * width;
                list.add(structureArea);
                System.out.println("Your Structure area is :\t " + structureArea);
            } else {
                System.out.println("Invalid entry");
            }
        } else {
            System.out.println("Invalid entry");
        }

        System.out.println(list);
    }

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        double tot = 0;
        Lawn lawn = new Lawn();
        lawn.getTotalArea();
        System.out.println("Please enter number of structures : ");
        Scanner sc = new Scanner(System.in);
        int structures = sc.nextInt();
        for (int count = 1; count <= structures; count++) {
            lawn.getStructureArea();
        }

        double sum = 0;
       /* for (Double item : list) {
            tot += item.structureArea;

        }*/

    }
}
     

命令“forward-search regexp search regexp ”检查每一行,从列出的最后一行后面的一行开始,检查forward-search regexp的匹配项。它列出了找到的行。您可以使用同义词“regexp”或将命令名称缩写为search regexp

fo
     

命令“reverse-search regexp ”检查每一行,从列出的最后一行之前的那一行开始,然后向后查找reverse-search regexp的匹配项。它列出了找到的行。您可以将此命令缩写为regexp

您还可以使用rev命令更改TUI源窗口中显示的行 - https://sourceware.org/gdb/onlinedocs/gdb/List.html#List