Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[tcf-dev] Creating contexts

Hi guys!

First of all some good news:

After spending quite a lot time on writing the parser to provide all necessary debug information to the TCF Agent, I am now able to set breakpoints in public and private/static functions and I am also able to display scoped symbols such as local variables in Eclipse (no values yet since I need to write support on another end of this project but it won't take me too long to get there). This means that one can soon debug a simple C program that runs on an i8051 ancestor in Eclipse via the TCF Agent. :) At this point thanks for all your help so far!

One thing I ignored till now since I was just clumping a way to the proof of concept until being able to display symbols is creating the contexts.

What I am doing at the moment is I took that context that used to be a context and call it SIB-context. SIB is just a server but in a way it is the only interface to my device so there it is. Then there is the device-context which is the actual context the agent is going to work with in order to communicate with the device and get some debug information.

Running this once is no problem but after I disconnect from the agent the program crashes. I tried a few things but it seems the problem is that the agent still has those contexts somewhere having their old states save e.g. ctx->pending_intercept might still be true even I disconnected from the agent.

In the attachement you can see the function that creates the contexts. I assume that I don't have to take care about removing the contexts from the agent somehow since it could always happen that a client crashes without saying goodbye - and speaking of it: how does the agent take care of such a case? If the server is running somewhere on a machine this could be a memory leak, am I right?

Well to end this Email: Could someone tell or show me how I could take care of these contexts? The SIB Server getsa pseudo ID as well as the device because these will never change and for now these two contexts will be the only one needed.

Thanks for any help or suggestions!

Best regards,
Stefan Falk




--
Stefan Falk

Infineon Technologies Austria AG
Trainee
Automotive Sense and Control
Component Verification

Tel:  +43 (0)5 / 1777 - 5439
Email: stefan.falk@xxxxxxxxxxxx<mailto:stefan.falk@xxxxxxxxxxxx>

"Aim above the mark to hit the mark." - Ralph Waldo Emerson



/**
 * @brief Create context for SIB and device.
 */
void create_sib_context()
{
    Context * ctxSib = NULL;
    Context * ctxDev = NULL;
    ContextExtensionSib * dext = NULL;

    // Create context for SIB Server which is basically
    // a substitution of a parental process for the running
    // program on the device.

	ctxSib = create_context(pid2id(PSEUDO_PROCESS_ID, 0));
	ctxSib->big_endian = 1; /** \todo Call big_endian_host(); here */
	ctxSib->mem = ctxSib;
	/** \todo Check how to set mem_access correctly */
	ctxSib->mem_access |= MEM_ACCESS_INSTRUCTION;
	ctxSib->mem_access |= MEM_ACCESS_DATA;
	ctxSib->mem_access |= MEM_ACCESS_USER;

	dext = DEXT(ctxSib);        
	dext->pid = PSEUDO_PROCESS_ID;//device_event->sibId; 
	dext->ddebug_state = 0;//ddebug_state;

	// Link context and send context-created event.    
	link_context(ctxSib);

	send_context_created_event(ctxSib);
	send_context_changed_event(ctxSib); // Is that necessary?
    
    // ----------

	ctxDev = create_context(pid2id(PSEUDO_MAINTHREAD_ID, PSEUDO_PROCESS_ID/*device_event->sibId*/));

	dext        = DEXT(ctxDev);
	dext->regs  = (REG_SET*)loc_alloc_zero(sizeof(REG_SET));
	dext->pid   = PSEUDO_MAINTHREAD_ID;
   
	ctxDev->mem         = ctxSib;
	ctxDev->big_endian  = big_endian_host();
	ctxDev->parent      = ctxSib;
	ctxDev->parent->ref_count++;

	list_add_last(&ctxDev->cldl, &ctxSib->children);
	link_context(ctxDev);

	send_context_created_event(ctxDev);
	send_context_changed_event(ctxDev); // Is that necessary?
    
    // ----------

	// The device is stopped after reset
    event_sib_context_stopped(ctxDev);
}

Back to the top