Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
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
1 change: 1 addition & 0 deletions lib/cfg-grammar-internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
#include "filter/filter-pipe.h"
#include "filterx/filterx-parser.h"
#include "filterx/filterx-expr.h"
#include "filterx/expr-compound.h"
#include "filterx/filterx-pipe.h"
#include "parser/parser-expr-parser.h"
#include "rewrite/rewrite-expr-parser.h"
Expand Down
12 changes: 8 additions & 4 deletions lib/cfg-grammar.y
Original file line number Diff line number Diff line change
Expand Up @@ -719,16 +719,20 @@ filter_content
;

filterx_content
: _filterx_context_push <ptr>{
FilterXExpr *filterx_block = NULL;
: '{' _filterx_context_push <ptr>{
GList *filterx_expr_list = NULL;
FilterXEvalContext compile_context;

filterx_eval_begin_compile(&compile_context, configuration);
CHECK_ERROR_WITHOUT_MESSAGE(cfg_parser_parse(&filterx_parser, lexer, (gpointer *) &filterx_block, NULL), @$);
CHECK_ERROR_WITHOUT_MESSAGE(cfg_parser_parse(&filterx_parser, lexer, (gpointer *) &filterx_expr_list, NULL), @$);
filterx_eval_end_compile(&compile_context);

FilterXExpr *filterx_block = filterx_compound_expr_new(FALSE);
filterx_compound_expr_add_list(filterx_block, filterx_expr_list);
filterx_expr_set_location_with_text(filterx_block, &@$, "{ ... }");

$$ = log_expr_node_new_pipe(log_filterx_pipe_new(filterx_block, configuration), &@$);
} _filterx_context_pop { $$ = $2; }
} _filterx_context_pop '}' { $$ = $3; }
;

parser_content
Expand Down
6 changes: 6 additions & 0 deletions lib/cfg.c
Original file line number Diff line number Diff line change
Expand Up @@ -542,6 +542,12 @@ cfg_run_parser(GlobalConfig *self, CfgLexer *lexer, CfgParser *parser, gpointer
return res;
}

gboolean
cfg_parsing_in_progress(void)
{
return configuration != NULL;
}

gboolean
cfg_run_parser_with_main_context(GlobalConfig *self, CfgLexer *lexer, CfgParser *parser, gpointer *result, gpointer arg,
const gchar *desc)
Expand Down
1 change: 1 addition & 0 deletions lib/cfg.h
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ GlobalConfig *cfg_new_subordinate(GlobalConfig *master);
gboolean cfg_run_parser(GlobalConfig *self, CfgLexer *lexer, CfgParser *parser, gpointer *result, gpointer arg);
gboolean cfg_run_parser_with_main_context(GlobalConfig *self, CfgLexer *lexer, CfgParser *parser, gpointer *result,
gpointer arg, const gchar *desc);
gboolean cfg_parsing_in_progress(void);
gboolean cfg_read_config(GlobalConfig *cfg, const gchar *fname, gchar *preprocess_into);
void cfg_shutdown(GlobalConfig *self);
gboolean cfg_is_shutting_down(GlobalConfig *cfg);
Expand Down
14 changes: 13 additions & 1 deletion lib/debugger/Makefile.am
Original file line number Diff line number Diff line change
@@ -1,6 +1,18 @@
debuggerincludedir = ${pkgincludedir}/debugger

EXTRA_DIST += lib/debugger/CMakeLists.txt
EXTRA_DIST += lib/debugger/CMakeLists.txt \
cmd-continue.c \
cmd-display.c \
cmd-drop.c \
cmd-follow.c \
cmd-help.c \
cmd-info.c \
cmd-list.c \
cmd-print.c \
cmd-printx.c \
cmd-quit.c \
cmd-step.c \
cmd-trace.c

debuggerinclude_HEADERS = \
lib/debugger/debugger.h \
Expand Down
32 changes: 32 additions & 0 deletions lib/debugger/cmd-continue.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*
* Copyright (c) 2015 Balabit
* Copyright (c) 2015 Balázs Scheidler
* Copyright (c) 2024 Balázs Scheidler <balazs.scheidler@axoflow.com>
* Copyright (c) 2024 Axoflow
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
* As an additional exemption you are allowed to compile & link against the
* OpenSSL libraries as published by the OpenSSL project. See the file
* COPYING for details.
*
*/

static gboolean
_cmd_continue(Debugger *self, gint argc, gchar *argv[])
{
_set_mode(self, DBG_WAITING_FOR_BREAKPOINT, FALSE);
return FALSE;
}
42 changes: 42 additions & 0 deletions lib/debugger/cmd-display.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/*
* Copyright (c) 2015 Balabit
* Copyright (c) 2015 Balázs Scheidler
* Copyright (c) 2024 Balázs Scheidler <balazs.scheidler@axoflow.com>
* Copyright (c) 2024 Axoflow
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
* As an additional exemption you are allowed to compile & link against the
* OpenSSL libraries as published by the OpenSSL project. See the file
* COPYING for details.
*
*/

static gboolean
_cmd_display(Debugger *self, gint argc, gchar *argv[])
{
if (argc == 2)
{
GError *error = NULL;
if (!log_template_compile(self->display_template, argv[1], &error))
{
printf("display: Error compiling template: %s\n", error->message);
g_clear_error(&error);
return TRUE;
}
}
printf("display: The template is set to: \"%s\"\n", self->display_template->template_str);
return TRUE;
}
32 changes: 32 additions & 0 deletions lib/debugger/cmd-drop.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*
* Copyright (c) 2015 Balabit
* Copyright (c) 2015 Balázs Scheidler
* Copyright (c) 2024 Balázs Scheidler <balazs.scheidler@axoflow.com>
* Copyright (c) 2024 Axoflow
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
* As an additional exemption you are allowed to compile & link against the
* OpenSSL libraries as published by the OpenSSL project. See the file
* COPYING for details.
*
*/

static gboolean
_cmd_drop(Debugger *self, gint argc, gchar *argv[])
{
self->breakpoint_site->drop = TRUE;
return FALSE;
}
32 changes: 32 additions & 0 deletions lib/debugger/cmd-follow.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*
* Copyright (c) 2015 Balabit
* Copyright (c) 2015 Balázs Scheidler
* Copyright (c) 2024 Balázs Scheidler <balazs.scheidler@axoflow.com>
* Copyright (c) 2024 Axoflow
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
* As an additional exemption you are allowed to compile & link against the
* OpenSSL libraries as published by the OpenSSL project. See the file
* COPYING for details.
*
*/

static gboolean
_cmd_follow(Debugger *self, gint argc, gchar *argv[])
{
_set_mode(self, DBG_FOLLOW_AND_BREAK, TRUE);
return FALSE;
}
61 changes: 61 additions & 0 deletions lib/debugger/cmd-help.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
/*
* Copyright (c) 2015 Balabit
* Copyright (c) 2015 Balázs Scheidler
* Copyright (c) 2024 Balázs Scheidler <balazs.scheidler@axoflow.com>
* Copyright (c) 2024 Axoflow
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
* As an additional exemption you are allowed to compile & link against the
* OpenSSL libraries as published by the OpenSSL project. See the file
* COPYING for details.
*
*/

static gboolean
_cmd_help(Debugger *self, gint argc, gchar *argv[])
{
if (self->breakpoint_site)
{
printf("syslog-ng interactive console\n"
"Stopped on a breakpoint.\n"
"The following commands are available:\n\n"
" help, h, ? Display this help\n"
" info, i Display information about the current execution state\n"
" list, l Display source code at the current location\n"
" continue, c Continue until the next breakpoint\n"
" step, s Single step\n"
" follow, f Follow this message, ignoring any other breakpoints\n"
" display Set the displayed message template\n"
" trace, t Trace this message along the configuration\n"
" print, p Print the current log message\n"
" printx, px Print the value of a filterx expression\n"
" drop, d Drop the current message\n"
" quit, q Tell syslog-ng to exit\n"
);
}
else
{
printf("syslog-ng interactive console\n"
"Stopped on an interrupt.\n"
"The following commands are available:\n\n"
" help, h, ? Display this help\n"
" list, l Display source code at the current location\n"
" continue, c Continue until the next breakpoint\n"
" quit, q Tell syslog-ng to exit\n"
);
}
return TRUE;
}
50 changes: 50 additions & 0 deletions lib/debugger/cmd-info.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/*
* Copyright (c) 2015 Balabit
* Copyright (c) 2015 Balázs Scheidler
* Copyright (c) 2024 Balázs Scheidler <balazs.scheidler@axoflow.com>
* Copyright (c) 2024 Axoflow
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
* As an additional exemption you are allowed to compile & link against the
* OpenSSL libraries as published by the OpenSSL project. See the file
* COPYING for details.
*
*/

static gboolean
_cmd_info_pipe(Debugger *self, LogPipe *pipe)
{
gchar buf[1024];

printf("LogPipe %p at %s\n", pipe, log_expr_node_format_location(pipe->expr_node, buf, sizeof(buf)));
_display_source_line(self);

return TRUE;
}

static gboolean
_cmd_info(Debugger *self, gint argc, gchar *argv[])
{
if (argc >= 2)
{
if (strcmp(argv[1], "pipe") == 0)
return _cmd_info_pipe(self, self->breakpoint_site->pipe);
}

printf("info: List of info subcommands\n"
"info pipe -- display information about the current pipe\n");
return TRUE;
}
57 changes: 57 additions & 0 deletions lib/debugger/cmd-list.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
/*
* Copyright (c) 2015 Balabit
* Copyright (c) 2015 Balázs Scheidler
* Copyright (c) 2024 Balázs Scheidler <balazs.scheidler@axoflow.com>
* Copyright (c) 2024 Axoflow
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
* As an additional exemption you are allowed to compile & link against the
* OpenSSL libraries as published by the OpenSSL project. See the file
* COPYING for details.
*
*/

static gboolean
_cmd_list(Debugger *self, gint argc, gchar *argv[])
{
gint shift = 11;
if (argc >= 2)
{
if (strcmp(argv[1], "+") == 0)
shift = 11;
else if (strcmp(argv[1], "-") == 0)
shift = -11;
else if (strcmp(argv[1], ".") == 0)
{
shift = 0;
if (self->breakpoint_site)
_set_current_location(self, self->breakpoint_site->pipe->expr_node);
}
else if (isdigit(argv[1][0]))
{
gint target_lineno = atoi(argv[1]);
if (target_lineno <= 0)
target_lineno = 1;
self->current_location.list_start = target_lineno;
}
/* drop any arguments for repeated execution */
_set_command(self, "l");
}
_display_source_line(self);
if (shift)
self->current_location.list_start += shift;
return TRUE;
}
Loading
Loading