mirror of
https://github.com/Mercury-Language/mercury.git
synced 2025-12-12 20:34:19 +00:00
Estimated hours taken: 1.5 Branches: main Fix Mantis bug #45, which was that mdb effectively ignored some commands in .mdbrc files. trace/mercury_trace_internal.[ch]: trace/mercury_trace_command_queue.[ch]: Move the code for manipulating the command queue from mercury_trace_internal.c to a new module. This improves the level of abstraction. The ultimate cause of the bug was a lack of abstraction. The old code put commands from startup files in the command queue in a mixed order: respecting order within each startup file, but reversing order among startup files. The cause of the bug was that the commands from .mdbrc files were put into the queue *after* the commands from the system's standard startup file in time, but *before* them in order, so the commands in the standard startup file could override commands from .mdbrc files. The fix is to consistently put commands in order: from the standard system startup file, from .mdbrc, and from the environment. Give better names to some functions. Provide a mechanism for debugging the command queue mechanism. trace/mercury_trace_cmd_backward.c: Use those better names. trace/Mmakefile: Add the new module. tests/debugger/mdbrc_test.{m,inp,exp,mdbrc}: Add a regression test for this bug, a minimally modified version of the bug demo program in Mantis. tests/debugger/Mmakefile: Enable the new test case, which specifies its own .mdbrc file. tests/Mmake.common: Provide a way for a test case to not use the .mdbrc file used by all the other debugger tests, so it could specify its own.
43 lines
1.3 KiB
C
43 lines
1.3 KiB
C
/*
|
|
** vim: ts=4 sw=4 expandtab
|
|
*/
|
|
/*
|
|
** Copyright (C) 2008 The University of Melbourne.
|
|
** This file may only be copied under the terms of the GNU Library General
|
|
** Public License - see the file COPYING.LIB in the Mercury distribution.
|
|
*/
|
|
|
|
#ifndef MERCURY_TRACE_COMMAND_QUEUE_H
|
|
#define MERCURY_TRACE_COMMAND_QUEUE_H
|
|
|
|
/*
|
|
** The structure of the queue of command lines, and the operations
|
|
** that work on it.
|
|
**
|
|
** The contents of each command line should be allocated with MR_malloc().
|
|
*/
|
|
|
|
typedef struct MR_CmdLines_Struct MR_CmdLines;
|
|
|
|
struct MR_CmdLines_Struct {
|
|
char *MR_cmd_line_contents;
|
|
MR_CmdLines *MR_cmd_line_next;
|
|
};
|
|
|
|
extern void MR_insert_command_line_at_head(const char *line);
|
|
extern void MR_insert_command_line_at_tail(const char *line);
|
|
|
|
extern void MR_insert_command_lines_at_head(MR_CmdLines *lines);
|
|
extern void MR_insert_command_lines_at_tail(MR_CmdLines *lines);
|
|
|
|
/*
|
|
** If there any lines waiting in the queue, return the first of these.
|
|
** The memory for the line will have been allocated with MR_malloc(),
|
|
** and it is the caller's responsibility to MR_free() it when appropriate.
|
|
** If there are no lines in the queue, this function returns NULL.
|
|
*/
|
|
|
|
extern char *MR_trace_getline_command_queue(void);
|
|
|
|
#endif /* MERCURY_TRACE_COMMAND_QUEUE_H */
|