Skip to content

Commit

Permalink
debugger: add path_options argument to debugger stop/trace entry points
Browse files Browse the repository at this point in the history
Signed-off-by: Balazs Scheidler <balazs.scheidler@axoflow.com>
  • Loading branch information
bazsi committed Dec 10, 2024
1 parent 6598d98 commit 186334d
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 6 deletions.
4 changes: 2 additions & 2 deletions lib/debugger/debugger-main.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ static gboolean
_pipe_hook(LogPipe *s, LogMessage *msg, const LogPathOptions *path_options)
{
if (debugger_is_to_stop(current_debugger, s, msg))
return debugger_stop_at_breakpoint(current_debugger, s, msg);
return debugger_stop_at_breakpoint(current_debugger, s, msg, path_options);
else if (debugger_is_to_trace(current_debugger, s, msg))
return debugger_perform_tracing(current_debugger, s, msg);
return debugger_perform_tracing(current_debugger, s, msg, path_options);
return TRUE;
}

Expand Down
11 changes: 9 additions & 2 deletions lib/debugger/debugger.c
Original file line number Diff line number Diff line change
Expand Up @@ -578,22 +578,29 @@ debugger_start_console(Debugger *self)
}

gboolean
debugger_stop_at_breakpoint(Debugger *self, LogPipe *pipe_, LogMessage *msg)
debugger_stop_at_breakpoint(Debugger *self,
LogPipe *pipe_,
LogMessage *msg,
const LogPathOptions *path_options)
{
BreakpointSite breakpoint_site = {0};
msg_trace("Debugger: stopping at breakpoint",
log_pipe_location_tag(pipe_));

breakpoint_site.msg = log_msg_ref(msg);
breakpoint_site.pipe = log_pipe_ref(pipe_);
breakpoint_site.path_options = path_options;
tracer_stop_on_breakpoint(self->tracer, &breakpoint_site);
log_msg_unref(breakpoint_site.msg);
log_pipe_unref(breakpoint_site.pipe);
return !breakpoint_site.drop;
}

gboolean
debugger_perform_tracing(Debugger *self, LogPipe *pipe_, LogMessage *msg)
debugger_perform_tracing(Debugger *self,
LogPipe *pipe_,
LogMessage *msg,
const LogPathOptions *path_options)
{
struct timespec ts, *prev_ts = &self->last_trace_event;
gchar buf[1024];
Expand Down
6 changes: 4 additions & 2 deletions lib/debugger/debugger.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,10 @@ gchar *debugger_builtin_fetch_command(void);
void debugger_register_command_fetcher(FetchCommandFunc fetcher);
void debugger_exit(Debugger *self);
void debugger_start_console(Debugger *self);
gboolean debugger_perform_tracing(Debugger *self, LogPipe *pipe, LogMessage *msg);
gboolean debugger_stop_at_breakpoint(Debugger *self, LogPipe *pipe, LogMessage *msg);
gboolean debugger_perform_tracing(Debugger *self, LogPipe *pipe, LogMessage *msg,
const LogPathOptions *path_options);
gboolean debugger_stop_at_breakpoint(Debugger *self, LogPipe *pipe, LogMessage *msg,
const LogPathOptions *path_options);

Debugger *debugger_new(MainLoop *main_loop, GlobalConfig *cfg);
void debugger_free(Debugger *self);
Expand Down
2 changes: 2 additions & 0 deletions lib/debugger/tracer.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#define DEBUGGER_TRACER_H_INCLUDED 1

#include "syslog-ng.h"
#include "logpipe.h"

typedef struct _Tracer Tracer;

Expand All @@ -34,6 +35,7 @@ typedef struct _BreakpointSite
gboolean resume_requested;
LogMessage *msg;
LogPipe *pipe;
const LogPathOptions *path_options;
gboolean drop;
} BreakpointSite;

Expand Down

0 comments on commit 186334d

Please sign in to comment.