question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Add support of source code scroll

See original GitHub issue

recently started to use gdb and found this awesome tool however, i have to switch between this and tui when need to read code around

so i tried to add this feature myself, and finally made it (although just a walkaround solution) problem of my try is that it requires more config in .inputrc and .gdbinit.d/init can anyone help me improve it and make config as less as possible?

below is my changes: .gdbinit

246a247

    Dashboard.SrcScrollCommand(self)

510a512,532

@staticmethod
def source_scroll_up(dashboard):
    for module in dashboard.modules:
        if module.name == 'source':
            module.instance.scrl_up()
    dashboard.redisplay()

@staticmethod
def source_scroll_down(dashboard):
    for module in dashboard.modules:
        if module.name == 'source':
            module.instance.scrl_down()
    dashboard.redisplay()

@staticmethod
def source_scroll_reset(dashboard):
    for module in dashboard.modules:
        if module.name == 'source':
            module.instance.scrl_rst()
    dashboard.redisplay()

684a707,730

class SrcScrollCommand(gdb.Command):

    def __init__(self, dashboard):
        gdb.Command.__init__(self, 'dashboard -srcscroll', gdb.COMMAND_USER)
        self.dashboard = dashboard

    def invoke(self, arg, from_tty):
        arg = Dashboard.parse_arg(arg)
        if arg == 'rst':
            self.dashboard.source_scroll_reset(self.dashboard)
        elif arg == 'up':
            self.dashboard.source_scroll_up(self.dashboard)
            #self.dashboard.redisplay()
        elif arg == 'down':
            self.dashboard.source_scroll_down(self.dashboard)
        else:
            msg = 'Wrong argument "{}"; expecting "up" or "down"'
            Dashboard.err(msg.format(arg))

    def complete(self, text, word):
        return Dashboard.complete(word, ['up', 'down'])

869a916

    self.src_offset = 0

894a942

        self.src_offset = 0

905,906c953,954

    start = max(current_line - 1 - self.context + self.src_offset, 0)
    end = min(current_line - 1 + self.context + 1 + self.src_offset, len(self.source_lines))

928a977,985

def scrl_up(self):
    self.src_offset = self.src_offset - 1

def scrl_down(self):
    self.src_offset = self.src_offset + 1

def scrl_rst(self):
    self.src_offset = 0

=========================== .gdbinit.d/init

define scrollup dashboard -srcscroll up end

define scrolldown dashboard -srcscroll down end

define scrollreset dashboard -srcscroll rst end

define hookpost-next scrollreset end

================== .inputrc $if gdb "\C-p": "scrollup\n" "\C-n": "scrolldown\n" $endif

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:2
  • Comments:8 (3 by maintainers)

github_iconTop GitHub Comments

4reactions
cyrus-andcommented, Aug 23, 2019

Implemented in c671fddb455d85f23631742159084aae2bed991d. To implement the readline trick do something like this:

$if gdb
    "\C-p": "\C-a\C-kserver dashboard source scroll 1\n\C-y"
    "\C-n": "\C-a\C-kserver dashboard source scroll -1\n\C-y"
    "\C-\M-p": "\C-a\C-kserver dashboard assembly scroll 1\n\C-y"
    "\C-\M-n": "\C-a\C-kserver dashboard assembly scroll -1\n\C-y"
$endif
1reaction
cyrus-andcommented, Jun 22, 2020

@yankee14 yes, see help dashboard source scroll.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Enabling custom Source Code Highlighting - K15t Help Center
Enabling custom Source Code Highlighting. This recipe explains how to add source code highlighting to a Scroll Viewport theme.
Read more >
Scroll bar map mode and bar mode - Visual Studio (Windows)
Map mode displays lines of code, in miniature, on the scroll bar. You can choose how wide the map column is by selecting...
Read more >
How to universally enable scrolling on website that disabled ...
In a browser like Chrome etc.: Inspect the code (for e.g. in Chrome press ctrl + shift + c );; Set overflow: visible...
Read more >
scroll-behavior - CSS: Cascading Style Sheets - MDN Web Docs
The scroll-behavior CSS property sets the behavior for a scrolling box when scrolling is triggered by the navigation or CSSOM scrolling APIs.
Read more >
How to Use Scroll Panes - Oracle Help Center
Here's the code that creates the text area, makes it the scroll pane's client, and adds the scroll pane to a container: //In...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found