Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Backtrace Screen #1270

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions Action.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ in the source distribution for its full text.
#include "ListItem.h"
#include "Macros.h"
#include "MainPanel.h"
#include "Object.h"
#include "OpenFilesScreen.h"
#include "Panel.h"
#include "Process.h"
#include "ProcessLocksScreen.h"
#include "ProvideCurses.h"
Expand All @@ -47,6 +49,10 @@ in the source distribution for its full text.
#include "AffinityPanel.h"
#endif

#if defined(HAVE_BACKTRACE)
#include "BacktraceScreen.h"
#endif


Object* Action_pickFromVector(State* st, Panel* list, int x, bool follow) {
MainPanel* mainPanel = st->mainPanel;
Expand Down Expand Up @@ -595,6 +601,24 @@ static Htop_Reaction actionShowLocks(State* st) {
return HTOP_REFRESH | HTOP_REDRAW_BAR;
}

#if defined(HAVE_BACKTRACE)
static Htop_Reaction actionBacktrace(State *st) {
const Process* process = (Process*) Panel_getSelected((Panel*)st->mainPanel);
if (!process)
return HTOP_OK;

BacktracePanel *panel = BacktracePanel_new(process, st->host->settings);
ScreenManager *screenManager = ScreenManager_new(NULL, st->host, st, false);
ScreenManager_add(screenManager, (Panel *)panel, 0);

ScreenManager_run(screenManager, NULL, NULL, NULL);
BacktracePanel_delete((Object *)panel);
ScreenManager_delete(screenManager);

return HTOP_REFRESH | HTOP_REDRAW_BAR | HTOP_UPDATE_PANELHDR;
}
#endif

static Htop_Reaction actionStrace(State* st) {
if (!Action_writeableProcess(st))
return HTOP_OK;
Expand Down Expand Up @@ -678,6 +702,9 @@ static const struct {
{ .key = " F8 [: ", .roInactive = true, .info = "lower priority (+ nice)" },
#if (defined(HAVE_LIBHWLOC) || defined(HAVE_AFFINITY))
{ .key = " a: ", .roInactive = true, .info = "set CPU affinity" },
#endif
#if defined(HAVE_BACKTRACE)
{ .key = " b: ", .roInactive = false, .info = "show process backtrace" },
#endif
{ .key = " e: ", .roInactive = false, .info = "show process environment" },
{ .key = " i: ", .roInactive = true, .info = "set IO priority" },
Expand Down Expand Up @@ -918,6 +945,9 @@ void Action_setBindings(Htop_Action* keys) {
keys['\\'] = actionIncFilter;
keys[']'] = actionHigherPriority;
keys['a'] = actionSetAffinity;
#if defined(HAVE_BACKTRACE)
keys['b'] = actionBacktrace;
#endif
keys['c'] = actionTagAllChildren;
keys['e'] = actionShowEnvScreen;
keys['h'] = actionHelp;
Expand Down
Loading