-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
debugger: move commands into their separate implementation file
Signed-off-by: Balazs Scheidler <balazs.scheidler@axoflow.com>
- Loading branch information
Showing
13 changed files
with
503 additions
and
204 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
/* | ||
* 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" | ||
" 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; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} |
Oops, something went wrong.