mirror of
https://github.com/Mercury-Language/mercury.git
synced 2025-12-20 00:15:27 +00:00
Estimated hours taken: 2 Branches: main, release Fix a problem with the recent debugger changes that broke the 0.13 branch in nogc grades on jupiter (and would presumably have broken the main branch tonight). The problem was that the static global variable MR_trace_browser_persistent_state_type, defined in mercury_trace_browser.c, is referred to in the recently added file mercury_trace_cmd_parameter.c. This causes a link-time error in the latter. This only shows up in nogc grades since in other grades the the references to MR_trace_browser_persistent_state_type are eliminated by the preprocessor. Fix some other problems that cause warnings from the C compiler. trace/mercury_trace_browse.[ch]: Export the global MR_trace_browser_persistent_state_type since it is now referred to from the module mercury_trace_cmd_parameter. trace/mercury_trace_cmd_parameter.c: #include mercury_trace_browse.h here because this file refers to MR_trace_browser_persistent_state_type. Call ML_LISTING_listing_type rather than passing its address to MR_make_permanent. Avoid a C compiler warning on 64-bit architectures about the size of int and MR_Integer differing. trace/mercury_trace_holds_vars.c: Avoid C compiler warnings in calls to MR_make_permanent by adding casts so that the arguments have the correct type. (Again this only shows up in nogc grades since it's all just macros in the other grades.) browser/listing.m: Export ML_LISTING_listing_type as a function rather than as a predicate since that is how it was being used in the trace directory.
83 lines
2.2 KiB
C
83 lines
2.2 KiB
C
/*
|
|
** vim: ts=4 sw=4 expandtab
|
|
*/
|
|
/*
|
|
** Copyright (C) 2005-2006 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.
|
|
*/
|
|
|
|
#include "mercury_imp.h"
|
|
#include "mercury_array_macros.h" /* MR_bsearch etc */
|
|
#include "mercury_trace_base.h" /* MR_TRACE_CALL_MERCURY */
|
|
#include "type_desc.mh" /* ML_get_type_info_for_type_info */
|
|
#include "mercury_trace_hold_vars.h"
|
|
|
|
typedef struct {
|
|
const char *MR_held_name;
|
|
MR_TypeInfo MR_held_type;
|
|
MR_Word MR_held_value;
|
|
} MR_Held_Var;
|
|
|
|
/* The initial size of the held vars table. */
|
|
#define MR_INIT_HELD_VARS 10
|
|
|
|
static MR_Held_Var *MR_held_vars;
|
|
static int MR_held_var_max = 0;
|
|
static int MR_held_var_next = 0;
|
|
|
|
MR_bool
|
|
MR_add_hold_var(const char *name, const MR_TypeInfo typeinfo, MR_Word value)
|
|
{
|
|
MR_TypeInfo old_type;
|
|
MR_Word old_value;
|
|
int slot;
|
|
MR_Word typeinfo_type_word;
|
|
|
|
if (MR_lookup_hold_var(name, &old_type, &old_value)) {
|
|
return MR_FALSE;
|
|
}
|
|
|
|
MR_TRACE_CALL_MERCURY(
|
|
typeinfo_type_word = ML_get_type_info_for_type_info();
|
|
);
|
|
|
|
MR_ensure_room_for_next(MR_held_var, MR_Held_Var, MR_INIT_HELD_VARS);
|
|
MR_prepare_insert_into_sorted(MR_held_vars, MR_held_var_next, slot,
|
|
strcmp(MR_held_vars[slot].MR_held_name, name));
|
|
MR_held_vars[slot].MR_held_name = strdup(name);
|
|
MR_held_vars[slot].MR_held_type = (MR_TypeInfo) MR_make_permanent(
|
|
(MR_Word) typeinfo, (MR_TypeInfo) typeinfo_type_word);
|
|
MR_held_vars[slot].MR_held_value = MR_make_permanent(value, typeinfo);
|
|
|
|
return MR_TRUE;
|
|
}
|
|
|
|
MR_bool
|
|
MR_lookup_hold_var(const char *name, MR_TypeInfo *typeinfo,
|
|
MR_Word *value)
|
|
{
|
|
MR_bool found;
|
|
int slot;
|
|
|
|
MR_bsearch(MR_held_var_next, slot, found,
|
|
strcmp(MR_held_vars[slot].MR_held_name, name));
|
|
if (found) {
|
|
*typeinfo = MR_held_vars[slot].MR_held_type;
|
|
*value = MR_held_vars[slot].MR_held_value;
|
|
return MR_TRUE;
|
|
} else {
|
|
return MR_FALSE;
|
|
}
|
|
}
|
|
|
|
void
|
|
MR_trace_list_held_vars(FILE *fp)
|
|
{
|
|
int i;
|
|
|
|
for (i = 0; i < MR_held_var_next; i++) {
|
|
fprintf(fp, "$%s\n", MR_held_vars[i].MR_held_name);
|
|
}
|
|
}
|