GEP (GDB Enhanced Prompt) - a GDB plug-in for GDB command prompt with fzf history search, fish-like autosuggestions, auto-completion with floating window, partial string matching in history, and more!

Overview

GEP (GDB Enhanced Prompt)

asciicast

GEP (GDB Enhanced Prompt) is a GDB plug-in which make your GDB command prompt more convenient and flexibility.

Why I need this plug-in?

GDB's original prompt is using hardcoded built-in GNU readline library, we can't add our custom function and key binding easily. The old way to implement them is by patching the GDB's C source code and compiling it again.

But now, you can write your function in Python and use arbitrary key binding easily with GEP without any patching!

And also, GEP has some awesome features already, you can directly use it!

Features

  • Ctrl+R for fzf history reverse search
  • up-arrow for partial string matching in history
  • TAB for auto-completion with floating window
  • fish-like autosuggestions
  • has the ability to build custom key binding and its callback function by modifying geprc.py

How to install it?

Make sure you have GDB 8.0 or higher compiled with Python3.6+ bindings, then:

  1. Install fzf: Installation

  2. Download this plug-in and install it:

git clone https://github.com/lebr0nli/GEP.git && \
cd GEP && \
sh install.sh

Note: This plug-in is using prompt-toolkit 2.0.10 (because IDK why prompt-toolkit 3 is not working with GDB Python API), so the install.sh will download prompt_toolkit==2.0.10 to ~/GEP/. Maybe we can build our prompt toolkit just for this plug-in in the future.

  1. Add source ~/GEP/.gdbinit-gep to the last line of your ~/.gdbinit

You can run:

echo 'source ~/GEP/.gdbinit-gep' >> ~/.gdbinit
  1. Enjoy!

For more configuration

You can modify configuration about history and auto-completion in ~/GEP/.gdbinit-gep.

You can also add your custom key bindings by modifying ~/GEP/geprc.py.

The trade-offs

Since GDB doesn't have a good Python API to fully control and emulate its prompt, this plug-in has some side effects.

However, the side effects are avoidable, here are the guides to avoid them:

gdb.event.before_prompt

The GDB Python API event: gdb.event.before_prompt may be called only once.

So if you are using a GDB plug-in that is listening on this event, this plug-in will cause some bugs.

As far as I know, pwndbg and gef won't be bothered by this side effect now.

To avoid this, you can change the callback function by adding them to gdb.prompt_hook, gdb.prompt_hook has almost the same effects with event.before_prompt, but gdb.prompt_hook can be directed invoke, so this plug-in still can emulate that callback for you!

dont-repeat

When your input is empty and directly press ENTER, GDB will execute the previous command from history if that command doesn't have the property: dont-repeat.

As far as I know, there is no GDB API for checking a command's property.

So, I added some commonly used commands (for original GDB API and GEF) which have that property in a list to avoid repeatedly executing them.

If you have some user-defined function that has dont-repeat property, add your command into the list manually, too.

Note: The list is in .gdbinit-gep.py and the variable name is DONT_REPEAT.

If you found some commands which should or shouldn't be added in that list, let me know on the issue page, thanks!

Bugs, suggestions, and ideas

If you found any bug, or you have any suggestions/ideas about this plug-in, feel free to leave your feedback on the GitHub issue page or send me a pull request!

Thanks!

You might also like...
Code for C2-Matching (CVPR2021). Paper: Robust Reference-based Super-Resolution via C2-Matching.
Code for C2-Matching (CVPR2021). Paper: Robust Reference-based Super-Resolution via C2-Matching.

C2-Matching (CVPR2021) This repository contains the implementation of the following paper: Robust Reference-based Super-Resolution via C2-Matching Yum

A Python implementation of the Locality Preserving Matching (LPM) method for pruning outliers in image matching.

LPM_Python A Python implementation of the Locality Preserving Matching (LPM) method for pruning outliers in image matching. The code is established ac

Stock-history-display - something like a easy yearly review for your stock performance
Stock-history-display - something like a easy yearly review for your stock performance

Stock History Display Available on Heroku: https://stock-history-display.herokua

A fast, dataset-agnostic, deep visual search engine for digital art history

imgs.ai imgs.ai is a fast, dataset-agnostic, deep visual search engine for digital art history based on neural network embeddings. It utilizes modern

Supplementary code for TISMIR paper "Sliding-Window Pitch-Class Histograms as a Means of Modeling Musical Form"

Sliding-Window Pitch-Class Histograms as a Means of Modeling Musical Form This is supplementary code for the TISMIR paper Sliding-Window Pitch-Class H

Alfred-Restore-Iterm-Arrangement - An Alfred workflow to restore iTerm2 window Arrangements
Alfred-Restore-Iterm-Arrangement - An Alfred workflow to restore iTerm2 window Arrangements

Alfred-Restore-Iterm-Arrangement This alfred workflow will list avaliable iTerm2

Supervised Sliding Window Smoothing Loss Function Based on MS-TCN for Video Segmentation

SSWS-loss_function_based_on_MS-TCN Supervised Sliding Window Smoothing Loss Function Based on MS-TCN for Video Segmentation Supervised Sliding Window

Plug and play transformer you can find network structure and official complete code by clicking List

Plug-and-play Module Plug and play transformer you can find network structure and official complete code by clicking List The following is to quickly

An integration of several popular automatic augmentation methods, including OHL (Online Hyper-Parameter Learning for Auto-Augmentation Strategy) and AWS (Improving Auto Augment via Augmentation Wise Weight Sharing) by Sensetime Research.

An integration of several popular automatic augmentation methods, including OHL (Online Hyper-Parameter Learning for Auto-Augmentation Strategy) and AWS (Improving Auto Augment via Augmentation Wise Weight Sharing) by Sensetime Research.

Comments
  • Error when starting gdb

    Error when starting gdb

    When I installed as instructed in README,

    $ bash -c "$(curl -fsSL https://raw.githubusercontent.com/lebr0nli/GEP/main/install.sh)"
    

    I've got this error when starting GDB.

    File "~/GEP/.gdbinit-gep.py", line 77
        fzf_cmd = [f"awk '!seen[$0]++' {shlex.quote(HISTORY_FILENAME)}"]
                                                                      ^
    SyntaxError: invalid syntax
    
    opened by diohabara 6
  • gdb doesn't import prompt_toolkit from $HOME/GEP/

    gdb doesn't import prompt_toolkit from $HOME/GEP/

    This is a really cool plugin and I'm eager to use its features. However, when I try to load it with source ~/GEP/.gdbinit-gep.py, I get an error about "'_GdbOutputFile' object has no attribute 'fileno'". It looks like there's some issue with prompt_toolkit. To get a full backtrace, I did the following:

    (gdb) python
    >from prompt_toolkit import PromptSession
    >p = PromptSession()
    >end
    Traceback (most recent call last):
      File "<string>", line 2, in <module>
      File "/home/dp12/.local/lib/python3.8/site-packages/prompt_toolkit/shortcuts/prompt.py", line 468, in __init__
        self.app = self._create_application(editing_mode, erase_when_done)
      File "/home/dp12/.local/lib/python3.8/site-packages/prompt_toolkit/shortcuts/prompt.py", line 719, in _create_application
        application: Application[_T] = Application(
      File "/home/dp12/.local/lib/python3.8/site-packages/prompt_toolkit/application/application.py", line 277, in __init__
        self.output = output or session.output
      File "/home/dp12/.local/lib/python3.8/site-packages/prompt_toolkit/application/current.py", line 70, in output
        self._output = create_output()
      File "/home/dp12/.local/lib/python3.8/site-packages/prompt_toolkit/output/defaults.py", line 77, in create_output
        return Vt100_Output.from_pty(
      File "/home/dp12/.local/lib/python3.8/site-packages/prompt_toolkit/output/vt100.py", line 466, in from_pty
        fd = stdout.fileno()
    AttributeError: '_GdbOutputFile' object has no attribute 'fileno'
    Error while executing Python code.
    

    Any ideas about what might be happening?

    bug 
    opened by dp12 3
Owner
Alan Li
Stay hungry, stay foolish. Keep hacking!
Alan Li
Robust Partial Matching for Person Search in the Wild

APNet for Person Search Introduction This is the code of Robust Partial Matching for Person Search in the Wild accepted in CVPR2020. The Align-to-Part

Yingji Zhong 36 Dec 18, 2022
MVP Benchmark for Multi-View Partial Point Cloud Completion and Registration

MVP Benchmark: Multi-View Partial Point Clouds for Completion and Registration [NEWS] 2021-07-12 [NEW ?? ] The submission on Codalab starts! 2021-07-1

PL 93 Dec 21, 2022
A script written in Python that returns a consensus string and profile matrix of a given DNA string(s) in FASTA format.

A script written in Python that returns a consensus string and profile matrix of a given DNA string(s) in FASTA format.

Zain 1 Feb 1, 2022
Puzzle-CAM: Improved localization via matching partial and full features.

Puzzle-CAM The official implementation of "Puzzle-CAM: Improved localization via matching partial and full features".

Sanghyun Jo 150 Nov 14, 2022
An exploration of log domain "alternative floating point" for hardware ML/AI accelerators.

This repository contains the SystemVerilog RTL, C++, HLS (Intel FPGA OpenCL to wrap RTL code) and Python needed to reproduce the numerical results in

Facebook Research 373 Dec 31, 2022
Genetic Algorithm, Particle Swarm Optimization, Simulated Annealing, Ant Colony Optimization Algorithm,Immune Algorithm, Artificial Fish Swarm Algorithm, Differential Evolution and TSP(Traveling salesman)

scikit-opt Swarm Intelligence in Python (Genetic Algorithm, Particle Swarm Optimization, Simulated Annealing, Ant Colony Algorithm, Immune Algorithm,A

郭飞 3.7k Jan 3, 2023
Python implementation of MULTIseq barcode alignment using fuzzy string matching and GMM barcode assignment

Python implementation of MULTIseq barcode alignment using fuzzy string matching and GMM barcode assignment.

MT Schmitz 2 Feb 11, 2022
Deep Image Search is an AI-based image search engine that includes deep transfor learning features Extraction and tree-based vectorized search.

Deep Image Search - AI-Based Image Search Engine Deep Image Search is an AI-based image search engine that includes deep transfer learning features Ex

null 139 Jan 1, 2023
Densely Connected Search Space for More Flexible Neural Architecture Search (CVPR2020)

DenseNAS The code of the CVPR2020 paper Densely Connected Search Space for More Flexible Neural Architecture Search. Neural architecture search (NAS)

Jamin Fong 291 Nov 18, 2022