GDB reports "No line 92 in the current file." but I actually have line 92

1

I encountered a very bizarre bug when I test my interrupt module of my os class project which is based on HOCA system.

When I start my main function (which is from line66 to line101), but when I set the breakpoint at line92, gdb says

No line 92 in the current file. Make breakpoint pending on future shared library load?

Do you guys know what's going on here?

Furthermore, when I set the breakpoint at line 92 and continue GDB, it reports :"

     trap: nonexistant memory
     address: -1
     memory size: 131072
     ERROR:  address greater than MEMORYSIZE


     Program received signal SIGSEGV, Segmentation fault.
     0x0000002e in ?? ()

"

Source code is as follow:

/* This module coordinates the initialization of the nucleus and it starts the execution
 * of the first process, p1(). It also provides a scheduling function. The module contains
 * two functions: main() and init(). init() is static. It also contains a function that it
 * exports: schedule().
 */

#include "../../h/const.h"
#include "../../h/types.h"
#include "../../h/util.h"
#include "../../h/vpop.h"

#include "../../h/procq.e"
#include "../../h/asl.e"
#include "../../h/trap.h"
#include "../../h/int.h"

proc_link RQ;       /* pointer to the tail of the Ready Queue */
state_t st;         /* the starting state_t */
extern int p1();

/* This function determines how much physical memory there is in the system.
 * It then calls initProc(), initSemd(), trapinit() and intinit().
 */
void static init(){

    STST(&st);

    if(st.s_sp%PAGESIZE != 0){
        st.s_sp -= st.s_sp%PAGESIZE;
    }

    initProc();
    initSemd();

    trapinit();
    intinit();
}


/* If the RQ is not empty this function calls intschedule() and loads the state of
 * the process at the head of the RQ. If the RQ is empty it calls intdeadlock().
 */
void schedule(){
    proc_t *front;
    front = headQueue(RQ);

    if (checkPointer(front)) {
        intschedule();
        LDST(&(front->p_s));
    }
    else {
        intdeadlock();
    }
}


/* This function calls init(), sets up the processor state for p1(), adds p1() to the
 * RQ and calls schedule().
 */

void main(){
    proc_t *pp1;  // pointer to process table entry
    state_t pp1state;  //process state

    long curr_time;   // to store the time

    init();  // initialize the process table, semaphore...

    /*setup the processor state for p1(),  adds p1() to the ReadyQueue */
    RQ.next = (proc_t *) ENULL;
    RQ.index = 1;

    pp1 = allocProc();
    if(!checkPointer(pp1)){
        return;
    }

    pp1->parent = (proc_t *) ENULL; // ENULL is set to -1
    pp1->child = (proc_t *) ENULL;
    pp1->sibling_next = pp1;
    pp1->sibling_prev = pp1;

    pp1state.s_sp = st.s_sp - (PAGESIZE*2);
    pp1state.s_pc = (int)p1;
    pp1state.s_sr.ps_s = 1;  // here should be line 92

    STCK(&curr_time); //store the CPU time to curr_time

    pp1->p_s = pp1state;
    pp1->start_time = curr_time;

    insertProc(&RQ, pp1);

    schedule();

    return;
}
c
debugging
operating-system
gdb
memory-size
asked on Stack Overflow Apr 6, 2015 by John Wang

1 Answer

3

Compile without optimizations. Use O0 gcc flag for that.

answered on Stack Overflow Apr 6, 2015 by user3639612

User contributions licensed under CC BY-SA 3.0