Writer/Debugging

From Apache OpenOffice Wiki
Jump to: navigation, search

Writer Icon.png

Writer Project

Please view the guidelines
before contributing.

Popular Subcategories:

Internal Documentation:

API Documentation:

Ongoing Efforts:

Sw.OpenOffice.org

GDB functions to look at writer stuff

Here are some GDB functions to examine the writer model a bit. Put these into .gdbinit.

def p_indent
  set $indent_ = $arg0
  set $i_ = 0
  while ($i_ < $indent_)
    printf "  "
    set $i_ = $i_ + 1
  end
end

# print SwNodes
def pna
  set $pna_nodes = $arg0
  set $pna_size = $pna_nodes.ppInf[0].nElem
  set $pna_i = 0
  set $pna_indent = 0
  printf "Nodes: %d\n", $pna_size
  while ($pna_i < $pna_size)
    set $pna_node = (SwNode*) ($pna_nodes.ppInf[0].pData[$pna_i])
    if ($pna_node.nNodeType & ND_ENDNODE)
      set $pna_indent = $pna_indent - 1
    end
    p_indent $pna_indent
    printf "[%4d] %p ", $pna_i, $pna_node
    if ($pna_node.nNodeType & ND_STARTNODE)
      set $pna_indent = $pna_indent - 1
    end
#FIXME how to get the dynamic class? this is ugly...
    if ($pna_node.nNodeType == ND_TEXTNODE)
      printf "   TextNode "
      printf "content: "
      set $pna_txtnode = (SwTxtNode*) $pna_node
      ptu $pna_txtnode.m_Text
    else
      if ($pna_node.nNodeType == ND_OLENODE)
        printf "    OLENode "
      else
        if ($pna_node.nNodeType == ND_GRFNODE)
          printf "    GrfNode "
        else
          if ($pna_node.nNodeType == ND_SECTIONNODE)
            printf "SectionNode "
          else
            if ($pna_node.nNodeType & ND_STARTNODE)
              printf "  StartNode "
            else
              if ($pna_node.nNodeType & ND_ENDNODE)
                printf "    EndNode "
              end
            end
          end
        end
      end
      printf "\n"
    end
    set $pna_i = $pna_i + 1
  end
end

# print SwDoc->GetNodes()
def pdna
  pna $arg0.m_pNodes.px
end

# print SwPosition
def ppos
  set $ppos_pos = $arg0
  set $ppos_node = $ppos_pos.nNode.pNd
  printf "pos: [%4d] %p ", $ppos_node.nOffset, $ppos_node
  printf "index: %d\n", $ppos_pos.nContent.nIndex
end

# print SwPaM
def ppam
  set $ppam_pam = $arg0
  printf "point: "
  ppos *$ppam_pam.m_pPoint
  if ($ppam_pam.m_pPoint != $ppam_pam.m_pMark)
    printf " mark: "
    ppos *$ppam_pam.m_pMark
  else
    printf "no mark.\n"
  end
end


DBX functions to look at writer stuff

Here are some DBX functions to examine the writer model a bit. Put these into .dbxrc.

# print SwNodes
function pna
{
    : ${1?"usage: $0 SwNodes # print SwNodes"}
    typeset len=$[(long) ($1).ppInf[0].nElem]
    typeset i=$[0]
    while [ $i -lt $len ]
    do
#        print -d ((SwNode*)($1).aNodes.ppInf[0].pData[$i])
        typeset node="(SwNode*)($1).ppInf[0].pData[$i]"
        print -d -p $node
        if $[((SwNode*)$node).nNodeType == ND_TEXTNODE]; then
            pu "((SwTxtNode*)$node).m_Text"
        fi
        i=$[$i+1]
    done
}

# print SwDoc->GetNodes()
function pdna
{
    : ${1?"usage: $0 SwDoc # print SwNodes"}
    pna "($1).m_pNodes.px"
}

# print SwPosition
function ppos
{
    : ${1?"usage: $0 SwPosition     # print SwPosition"}
    print ($1).nNode.pNd.nOffset
    print ($1).nContent.nIndex
}

# print SwPaM
function ppam
{
    : ${1?"usage: $0 SwPaM          # print SwPaM"}
    print ($1).m_Bound1.nNode.pNd.nOffset
    print ($1).m_Bound1.nContent.nIndex
    print ($1).m_Bound2.nNode.pNd.nOffset
    print ($1).m_Bound2.nContent.nIndex
}
Personal tools