jcrodriguez-dis / moodle-mod_vpl

Virtual Programming Lab for Moodle (Module)
GNU General Public License v3.0
97 stars 84 forks source link

Cannot debug C programs #155

Closed julesfm closed 9 months ago

julesfm commented 9 months ago

If I write a trivial "Hello world" C program such as this:

include

int main(void) { printf("Hello this is Jules 1\n"); }

I can click the "Run" button and it works fine. It produces the output in a little console window with a blue background. However, clicking the "Debug" button produces this error: "The compilation process did not generate an executable nor error message." even when I set the execution server to the demo site. It produces the same fault when I use either my Ubuntu 22 or RHEL9 vpl jail servers too.

I don't quite understand the execution flow, but if I set the LOG_LEVEL to 8 on my vpl jail server and look at the home directory of the prisoner after running, the "vpl_run.sh" file is 0 bytes. "vpl_debug.sh" has content, but attempts to call the empty vpl_run.sh script.

Any thoughts? Thanks, Jules.

jcrodriguez-dis commented 9 months ago

Dear @julesfm,

Thank you for submitting a detailed bug report concerning the "Debug" button issue in the VPL environment.

We acknowledge that this is a known issue introduced in the most recent VPL release. Please be assured that we are actively working on this, and the issue will be addressed in the forthcoming release.

Regarding the specific symptoms you've described — zero-byte vpl_run.sh and the error message when attempting to debug a C program — these are consistent with the problem we have identified internally. Your detailed observation about LOG_LEVEL and the vpl jail server environment is highly valuable to us for diagnostic purposes.

In the interim, you might consider using the vpl_debug.sh file below.

We sincerely apologize for any inconvenience this may have caused you, and we appreciate your patience as we work to resolve this issue.

Best regards, Juan Carlos

vpl_debug.sh

#!/bin/bash
# This file is part of VPL for Moodle
# Script for debugging C language
# Copyright (C) 2014 Juan Carlos Rodríguez-del-Pino
# License http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
# Author Juan Carlos Rodríguez-del-Pino <jcrodriguez@dis.ulpgc.es>

# @vpl_script_description Using GDB or ddd if available
# load common script and check programs
. common_script.sh
check_program gcc
check_program ddd gdb
if [ "$1" == "version" ] ; then
    get_program_version --version
fi
# compile
get_source_files c
# Generate file with source files
generate_file_of_files .vpl_source_files
gcc -fno-diagnostics-color -o vpl_execution -g -O0 @.vpl_source_files -lm -lutil 
rm .vpl_source_files
if [ -f vpl_execution ] ; then
    mv vpl_execution vpl_program
    cat common_script.sh > vpl_execution
    chmod +x vpl_execution
    if [ "$(command -v ddd)" == "" ] ; then
        check_program gdb
        echo "gdb vpl_program" >> vpl_execution
    else
        echo "ddd --quiet vpl_program &>/dev/null" >> vpl_execution
        mkdir .ddd &>/dev/null
        mkdir .ddd/sessions &>/dev/null
        mkdir .ddd/themes &>/dev/null
        cat >.ddd/init <<END_OF_FILE
Ddd*splashScreen: off
Ddd*startupTips: off
Ddd*suppressWarnings: on
Ddd*displayLineNumbers: on
Ddd*saveHistoryOnExit: off

! DO NOT ADD ANYTHING BELOW THIS LINE -- DDD WILL OVERWRITE IT
END_OF_FILE
        mv vpl_execution vpl_wexecution
    fi
else
    echo "Compilation process doesn't generate an execution file"
fi
jcrodriguez-dis commented 9 months ago

This issue was resolved in VPL 4.2.1 ef11c5d82bfef946cc7b0a56a749226b50ed5b9b