mirror of git://gcc.gnu.org/git/gcc.git
toyvm.c: use correct path in debuginfo
gcc/jit/ChangeLog: * docs/examples/tut04-toyvm/toyvm.c (toyvm_function_compile): Move logic for determine "funcname" to new function... (get_function_name): ...here, adding logic to skip any leading path from the filename. (toyvm_function_parse): Use the filename for fn_filename, rather than "name", so that the debugger can locate the source .toy file. (toyvm_function_parse): Don't fclose a NULL FILE *. From-SVN: r218540
This commit is contained in:
parent
dd91332382
commit
5cd614cecc
|
|
@ -1,3 +1,14 @@
|
||||||
|
2014-12-09 David Malcolm <dmalcolm@redhat.com>
|
||||||
|
|
||||||
|
* docs/examples/tut04-toyvm/toyvm.c (toyvm_function_compile): Move
|
||||||
|
logic for determine "funcname" to new function...
|
||||||
|
(get_function_name): ...here, adding logic to skip any leading
|
||||||
|
path from the filename.
|
||||||
|
(toyvm_function_parse): Use the filename for fn_filename, rather
|
||||||
|
than "name", so that the debugger can locate the source .toy
|
||||||
|
file.
|
||||||
|
(toyvm_function_parse): Don't fclose a NULL FILE *.
|
||||||
|
|
||||||
2014-12-09 David Malcolm <dmalcolm@redhat.com>
|
2014-12-09 David Malcolm <dmalcolm@redhat.com>
|
||||||
|
|
||||||
PR jit/63854
|
PR jit/63854
|
||||||
|
|
|
||||||
|
|
@ -121,6 +121,25 @@ add_unary_op (toyvm_function *fn, enum opcode opcode,
|
||||||
add_op (fn, opcode, operand, linenum);
|
add_op (fn, opcode, operand, linenum);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static char *
|
||||||
|
get_function_name (const char *filename)
|
||||||
|
{
|
||||||
|
/* Skip any path separators. */
|
||||||
|
const char *pathsep = strrchr (filename, '/');
|
||||||
|
if (pathsep)
|
||||||
|
filename = pathsep + 1;
|
||||||
|
|
||||||
|
/* Copy filename to funcname. */
|
||||||
|
char *funcname = (char *)malloc (strlen (filename) + 1);
|
||||||
|
|
||||||
|
strcpy (funcname, filename);
|
||||||
|
|
||||||
|
/* Convert "." to NIL terminator. */
|
||||||
|
*(strchr (funcname, '.')) = '\0';
|
||||||
|
|
||||||
|
return funcname;
|
||||||
|
}
|
||||||
|
|
||||||
static toyvm_function *
|
static toyvm_function *
|
||||||
toyvm_function_parse (const char *filename, const char *name)
|
toyvm_function_parse (const char *filename, const char *name)
|
||||||
{
|
{
|
||||||
|
|
@ -149,7 +168,7 @@ toyvm_function_parse (const char *filename, const char *name)
|
||||||
fprintf (stderr, "out of memory allocating toyvm_function\n");
|
fprintf (stderr, "out of memory allocating toyvm_function\n");
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
fn->fn_filename = name;
|
fn->fn_filename = filename;
|
||||||
|
|
||||||
/* Read the lines of the file. */
|
/* Read the lines of the file. */
|
||||||
while ((linelen = getline (&line, &bufsize, f)) != -1)
|
while ((linelen = getline (&line, &bufsize, f)) != -1)
|
||||||
|
|
@ -208,7 +227,8 @@ toyvm_function_parse (const char *filename, const char *name)
|
||||||
|
|
||||||
error:
|
error:
|
||||||
free (line);
|
free (line);
|
||||||
fclose (f);
|
if (f)
|
||||||
|
fclose (f);
|
||||||
free (fn);
|
free (fn);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
@ -460,12 +480,7 @@ toyvm_function_compile (toyvm_function *fn)
|
||||||
|
|
||||||
memset (&state, 0, sizeof (state));
|
memset (&state, 0, sizeof (state));
|
||||||
|
|
||||||
/* Copy filename to funcname. */
|
funcname = get_function_name (fn->fn_filename);
|
||||||
funcname = (char *)malloc (strlen (fn->fn_filename) + 1);
|
|
||||||
strcpy (funcname, fn->fn_filename);
|
|
||||||
|
|
||||||
/* Convert "." to NIL terminator. */
|
|
||||||
*(strchr (funcname, '.')) = '\0';
|
|
||||||
|
|
||||||
state.ctxt = gcc_jit_context_acquire ();
|
state.ctxt = gcc_jit_context_acquire ();
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue