From: Jan Kratochvil <jan.kratochvil@redhat.com>
To: gdb-patches@sourceware.org
Cc: Phil Muldoon <pmuldoon@redhat.com>
Subject: [PATCH 3/4] compile: Constify some parameters
Date: Thu, 26 Mar 2015 20:57:00 -0000 [thread overview]
Message-ID: <20150326205745.28223.81205.stgit@host1.jankratochvil.net> (raw)
In-Reply-To: <20150326205727.28223.54648.stgit@host1.jankratochvil.net>
gdb/ChangeLog
2015-03-26 Jan Kratochvil <jan.kratochvil@redhat.com>
* compile/compile.c (compile_to_object): Make the cmd_string parameter
const. Use new variables for the const compatibility.
(eval_compile_command): Make the cmd_string parameter const.
* compile/compile.h (eval_compile_command): Make the cmd_string
parameter const.
---
gdb/compile/compile.c | 15 +++++++++------
gdb/compile/compile.h | 3 ++-
2 files changed, 11 insertions(+), 7 deletions(-)
diff --git a/gdb/compile/compile.c b/gdb/compile/compile.c
index 7fe556d..7589f2a 100644
--- a/gdb/compile/compile.c
+++ b/gdb/compile/compile.c
@@ -415,11 +415,12 @@ print_callback (void *ignore, const char *message)
freeing both strings. */
static char *
-compile_to_object (struct command_line *cmd, char *cmd_string,
+compile_to_object (struct command_line *cmd, const char *cmd_string,
enum compile_i_scope_types scope,
char **source_filep)
{
char *code;
+ const char *input;
char *source_file, *object_file;
struct compile_instance *compiler;
struct cleanup *cleanup, *inner_cleanup;
@@ -459,6 +460,7 @@ compile_to_object (struct command_line *cmd, char *cmd_string,
{
struct ui_file *stream = mem_fileopen ();
struct command_line *iter;
+ char *stream_buf;
make_cleanup_ui_file_delete (stream);
for (iter = cmd->body_list[0]; iter; iter = iter->next)
@@ -467,15 +469,16 @@ compile_to_object (struct command_line *cmd, char *cmd_string,
fputs_unfiltered ("\n", stream);
}
- code = ui_file_xstrdup (stream, NULL);
- make_cleanup (xfree, code);
+ stream_buf = ui_file_xstrdup (stream, NULL);
+ make_cleanup (xfree, stream_buf);
+ input = stream_buf;
}
else if (cmd_string != NULL)
- code = cmd_string;
+ input = cmd_string;
else
error (_("Neither a simple expression, or a multi-line specified."));
- code = current_language->la_compute_program (compiler, code, gdbarch,
+ code = current_language->la_compute_program (compiler, input, gdbarch,
expr_block, expr_pc);
make_cleanup (xfree, code);
if (compile_debug)
@@ -554,7 +557,7 @@ compile_command (char *args, int from_tty)
/* See compile.h. */
void
-eval_compile_command (struct command_line *cmd, char *cmd_string,
+eval_compile_command (struct command_line *cmd, const char *cmd_string,
enum compile_i_scope_types scope, void *scope_data)
{
char *object_file, *source_file;
diff --git a/gdb/compile/compile.h b/gdb/compile/compile.h
index 93c4786..a973167 100644
--- a/gdb/compile/compile.h
+++ b/gdb/compile/compile.h
@@ -28,7 +28,8 @@ struct dynamic_prop;
expression command. GDB returns either a CMD, or a CMD_STRING, but
never both. */
-extern void eval_compile_command (struct command_line *cmd, char *cmd_string,
+extern void eval_compile_command (struct command_line *cmd,
+ const char *cmd_string,
enum compile_i_scope_types scope,
void *scope_data);
next prev parent reply other threads:[~2015-03-26 20:57 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-03-26 20:57 [PATCH 1/4] Code cleanup: Make parts of print_command_1 public Jan Kratochvil
2015-03-26 20:57 ` Jan Kratochvil [this message]
2015-04-06 17:28 ` obsolete: [PATCH 3/4] compile: Constify some parameters Jan Kratochvil
2015-03-26 20:57 ` [PATCH 2/4] compile: Add new field scope_data Jan Kratochvil
2015-04-06 17:28 ` obsolete: " Jan Kratochvil
2015-03-26 20:58 ` [PATCH 4/4] compile: New 'compile print' Jan Kratochvil
2015-03-26 20:59 ` Jan Kratochvil
2015-03-27 7:18 ` Eli Zaretskii
2015-03-27 7:33 ` Jan Kratochvil
2015-03-27 7:41 ` Eli Zaretskii
2015-03-27 7:56 ` Phil Muldoon
2015-03-27 9:08 ` Eli Zaretskii
2015-03-27 9:10 ` Eli Zaretskii
2015-03-27 9:16 ` Jan Kratochvil
2015-03-27 9:56 ` Eli Zaretskii
2015-03-27 10:11 ` Jan Kratochvil
2015-03-27 10:20 ` Phil Muldoon
2015-03-27 13:09 ` Eli Zaretskii
2015-03-27 10:24 ` Jan Kratochvil
2015-03-27 13:12 ` Eli Zaretskii
2015-04-05 17:01 ` cancel: " Jan Kratochvil
2015-04-06 17:29 ` obsolete: " Jan Kratochvil
2015-03-27 20:06 ` [PATCH 1/4] v2: Code cleanup: Make parts of print_command_1 public Jan Kratochvil
2015-04-06 17:27 ` obsolete: " Jan Kratochvil
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20150326205745.28223.81205.stgit@host1.jankratochvil.net \
--to=jan.kratochvil@redhat.com \
--cc=gdb-patches@sourceware.org \
--cc=pmuldoon@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).