Developer forums (C::B DEVELOPMENT STRICTLY!) > Development

Some thoughts on doing breakpoints persistent

<< < (5/9) > >>

ollydbg:

--- Quote from: jens on June 17, 2009, 01:23:10 pm ---Do you use AddBreakpoint from debugger-plugin or from editor ?

You can use the function from cbEditor, if the source-file is already opened and set notifyDebugger to true or use the function from debugger-plugin, if the file is not (yet) opened.

--- End quote ---

I totally use the function AddBreakpoint from debuggergdb plugin  debuggerstate.

I will try it now, Thanks very much!

ollydbg:
Sorry, I can't figure how to check if the current file was opened in cbEditor. Can someone help me?

here is the patch.( The patch has include some patches from oBFusCATed adding a command entry)


http://sites.google.com/site/studycodeblocks/imagescb/breakpoints.patch This patch has been updated in

https://developer.berlios.de/patch/index.php?func=detailpatch&patch_id=2775&group_id=5358


Here is some explanation about this patch:

1, I add two files: breakpointslayout.cpp and breakpointslayout.h(They are similar with code in BrowserTracker plugin)

2, I add some code in doing DebuggerGDB::OnProjectOpened and DebuggerGDB::OnProjectClosed

3, When a project is opened, I will use Addbreakpoints function in debuggerstate structure.

4, when a project is closed, I just read the breakpointsList in debuggerstate, then save them to a xml file.

5, I still can't find a way to notify cbEditor, so, the breakpoints add silently. :(



By the way, I can't upload an attachment any more(upload folder is FULL), can someone help me?  :(

Thanks

Edit:

Here are some ideas:


--- Code: ---class ProjectFile  : public BlockAllocated<ProjectFile, 1000>
{
......
        /** If true, the file is open inside an editor. */
        bool editorOpen; // layout info


--- End code ---

Can we use "ProjectFile" related method?

Jenna:
You can try:

--- Code: ---EditorBase* eb = Manager::Get()->GetEditorManager()->IsOpen(filename);
--- End code ---
or

--- Code: ---cbEditor* ed = Manager::Get()->GetEditorManager()->IsBuiltinOpen( filename );
--- End code ---

Both return NULL if not opened.

ollydbg:
@jens
Thanks very much! I will try it....So excited!!!

Edit:

Problem solved!!!! Works perfectly! Just change this function to:


--- Code: ---// ----------------------------------------------------------------------------
bool BreakpointsLayout::Load(const wxString& filename, DebuggerState * pDebuggerState)
// ----------------------------------------------------------------------------
{
    TiXmlDocument doc;
    if (!TinyXML::LoadDocument(filename, &doc))
        return false;

    TiXmlElement* root;
    TiXmlElement* elem;
    wxString fname;
    ProjectFile* pf;


    root = doc.FirstChildElement("Breakpoints_layout_file");
    if (!root)
    {
        return false;
    }

    elem = root->FirstChildElement("Breakpoint");

    while (elem)
    {
        wxString fname = cbC2U(elem->Attribute("file"));
        ProjectFile* pf;
        if (fname.IsEmpty())
        {
            break;
        }
        else
            pf = m_pProject->GetFileByFilename(fname);

        wxString filenamePath = pf->file.GetFullPath();

        int line = 0;
        if (not elem->QueryIntAttribute("position", &line) == TIXML_SUCCESS)
            break;

        //Manager::Get()->GetLogManager()->DebugLog(F(_T("file='%s', line='%d'"), filenamePath.c_str(), line));


        cbEditor* ed = Manager::Get()->GetEditorManager()->IsBuiltinOpen( filenamePath );
        if (ed==NULL){
            pDebuggerState->AddBreakpoint(filenamePath,line); //add breakpoints silently
            Manager::Get()->GetLogManager()->DebugLog(F(_T("silently add bp file='%s', line='%d'"), filenamePath.c_str(), line));
        }
        else{
            ed->AddBreakpoint(line);
            Manager::Get()->GetLogManager()->DebugLog(F(_T("add bp from editor file='%s', line='%d'"), filenamePath.c_str(), line));

        }
        elem = elem->NextSiblingElement();
    }
    return true;
}//Load

--- End code ---



ollydbg:
Hi, every one.
I have finished the finally patch.

Both watches and breakpoints can be persistent with the current project.

I add the patch here:

https://developer.berlios.de/patch/index.php?func=detailpatch&patch_id=2775&group_id=5358

Here is the example of a projectname.bps file


--- Code: ---<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<Debugger_layout_file>
<BreakpointsList>
<Breakpoint file="main.cpp" position="67" />
<Breakpoint file="main.cpp" position="69" />
<Breakpoint file="main.cpp" position="62" />
<Breakpoint file="main.cpp" position="58" />
</BreakpointsList>
<WatchesList>
<Watch variable="abcdefg" />
<Watch variable="llll" />
</WatchesList>
</Debugger_layout_file>


--- End code ---

Any comments and enhancements are welcome!!

Thanks. :D

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version