Bug 478921 - flush_instructions() cause some breakpoints to not be hit on VxWorks
Summary: flush_instructions() cause some breakpoints to not be hit on VxWorks
Status: RESOLVED FIXED
Alias: None
Product: TCF
Classification: Tools
Component: Agent (show other bugs)
Version: 1.4   Edit
Hardware: PC Linux
: P3 normal (vote)
Target Milestone: 1.4   Edit
Assignee: Project Inbox CLA
QA Contact: Eugene Tarassov CLA
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-10-02 12:19 EDT by Jean-Michel Pedrono CLA
Modified: 2016-03-18 08:21 EDT (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jean-Michel Pedrono CLA 2015-10-02 12:19:13 EDT
The following code from flush_instructions() unplants software breakpoints, and this is causing troubles to the VxWorks application mode debugger. This application mode debugger (As opposed to the VxWorks stop mode debugger) does not stop all VxWorks contexts. This means that when executing flush_instructions() other VxWorks tasks are still running, and calling remove_instruction() may cause some breakpoints not to be hit.

Disabling this part of the code resolves the issue on VxWorks (See #ifdef(_WRS_KERNEL).

    /* Unplant breakpoints */
    l = lst.next;
    while (l != &lst) {
        BreakInstruction * bi = link_lst2bi(l);
        l = l->next;
        if (!bi->valid) {
            assert(!bi->hardware);
            assert(!bi->virtual_addr);
            continue;
        }
        if (bi->stepping_over_bp) continue;
        if (bi->planted) {
            if (bi->dirty || bi->address_error) {
                (void)remove_instruction(bi);
            }
            else if (bi->ref_cnt == 0 && bi->virtual_addr) {
                (void)remove_instruction(bi);
            }
#if !defined(_WRS_KERNEL)
            /*
             * It is an issue if the TCF agent removes and install again and again
             * the breakpoints on a VxWorks target even if the breakpoint has not
             * changed. It may cause some breakpoints to not be hit. 
             * This is caused by the optimisation below; this optimisation
             * does not apply to VxWorks and can be safely disabled.
             */
            else if (bi->saved_size == 0 && !bi->hardware) {
                /* Free space for hardware breakpoints */
                (void)remove_instruction(bi);
            }
#endif  /* _WRS_KERNEL */
        }
        if (bi->planted || bi->ref_cnt == 0 || bi->address_error ||
                bi->cb.ctx->exiting || bi->cb.ctx->exited) {
            list_remove(&bi->link_lst);
        }
    }


Unless you have a better idea, I suggest to either integrate the above workaround, or to define a macro in breakpoints-ext.h (See Bug 478914). Something like this:

            else if (DISABLE_SOFT_BP_ON_FLUSH && bi->saved_size == 0 &&
                     !bi->hardware) {
                /* Free space for hardware breakpoints */
                (void)remove_instruction(bi);
            }


The default breakpoints-ext.h would define:

#define DISABLE_SOFT_BP_ON_FLUSH        TRUE

Thanks to provide me your feedback.
Comment 1 Eugene Tarassov CLA 2015-10-09 15:04:14 EDT
I have added #if !defined(_WRS_KERNEL).
Fixed.
Thanks!
Comment 2 Jean-Michel Pedrono CLA 2015-10-12 10:10:29 EDT
Thanks!