2017-07-18 21 views
2

皆、再帰出力

私はOpenFOAMのを使用していますが、それはこのような独自のフォーム:: stringと泡::ワードタイプ作っ:

(gdb) ptype Foam::word 
type = class Foam::word : public Foam::string { 
    public: 
    static pointer typeName; 
    static int debug; 
    static const Foam::word null; 

    private: 
    void stripInvalid(void); 
    public: 
    word(void); 
    word(const Foam::word &); 
    word(pointer, bool); 
    word(pointer, size_type, bool); 
    word(const Foam::string &, bool); 
    word(const std::__cxx11::string &, bool); 
    word(Foam::Istream &); 
    static bool valid(char); 
    void operator=(const Foam::word &); 
    void operator=(const Foam::string &); 
    void operator=(const std::__cxx11::string &); 
    void operator=(pointer); 
} 
(gdb) ptype Foam::string 
type = class Foam::string : public std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > { 
    public: 
    static pointer typeName; 
    static int debug; 
    static const Foam::string null; 

    string(void); 
    string(const std::__cxx11::string &); 
    string(pointer); 
    string(pointer, size_type); 
    string(char); 
    string(Foam::Istream &); 
    size_type count(char) const; 
    bool match(const std::__cxx11::string &) const; 
    Foam::string & replace(const Foam::string &, const Foam::string &, size_type); 
    Foam::string & replaceAll(const Foam::string &, const Foam::string &, size_type); 
    Foam::string & expand(bool); 
    bool removeRepeated(char); 
    Foam::string removeRepeated(char) const; 
    bool removeTrailing(char); 
    Foam::string removeTrailing(char) const; 
    Foam::string operator()(size_type, size_type) const; 
    Foam::string operator()(size_type) const; 
    static bool stripInvalid<Foam::word>(Foam::string &); 
    static bool stripInvalid<Foam::fileName>(Foam::string &); 
    static bool valid<Foam::word>(const Foam::string &); 
    static bool valid<Foam::fileName>(const Foam::string &); 
} 
をそれは Foam::word::nullに来るとき、GDBはこのような無限の再帰的な出力を生成します、しかし

(gdb) p Foam::string::null 
$82 = {<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >> = "", static typeName = 0x7ffff4e38b8a "string", static debug = 0, static null = {<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >> = "", 
    static typeName = 0x7ffff4e38b8a "string", static debug = 0, static null = <same as static member of an already seen type>}} 

は今、このようなFoam::string::nullを印刷することが可能である

(gdb) p Foam::word::null 
$83 = {<Foam::string> = {<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >> = "", static typeName = 0x7ffff4e38b8a "string", static debug = 0, 
    static null = {<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >> = "", static typeName = 0x7ffff4e38b8a "string", static debug = 0, static null = <same as static member of an already seen type>}}, 
    static typeName = 0x7ffff4e398eb "word", static debug = 0, static null = {<Foam::string> = {<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >> = "", static typeName = 0x7ffff4e38b8a "string", static debug = 0, 
     static null = {<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >> = "", static typeName = 0x7ffff4e38b8a "string", static debug = 0, static null = <same as static member of an already seen type>}}, 
    static typeName = 0x7ffff4e398eb "word", static debug = 0, static null = {<Foam::string> = {<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >> = "", static typeName = 0x7ffff4e38b8a "string", static debug = 0, 
     static null = {<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >> = "", static typeName = 0x7ffff4e38b8a "string", static debug = 0, static null = <same as static member of an already seen type>}}, 
     static typeName = 0x7ffff4e398eb "word", static debug = 0, static null = {<Foam::string> = {<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >> = "", static typeName = 0x7ffff4e38b8a "string", static debug = 0, 
      static null = {<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >> = "", static typeName = 0x7ffff4e38b8a "string", static debug = 0, static null = <same as static member of an already seen type>}}, 
     static typeName = 0x7ffff4e398eb "word", static debug = 0, static null = {<Foam::string> = {<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >> = "", static typeName = 0x7ffff4e38b8a "string", static debug = 0, 
      static null = {<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >> = "", static typeName = 0x7ffff4e38b8a "string", static debug = 0, static null = <same as static member of an already seen type>}}, 
      static typeName = 0x7ffff4e398eb "word", static debug = 0, static null = {<Foam::string> = {<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >> = "", static typeName = 0x7ffff4e38b8a "string", static debug = 0, 
       static null = {<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >> = "", static typeName = 0x7ffff4e38b8a "string", static debug = 0, static null = <same as static member of an already seen type>}}, 
      static typeName = 0x7ffff4e398eb "word", static debug = 0, static null = {<Foam::string> = {<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >> = "", static typeName = 0x7ffff4e38b8a "string", static debug = 0, 
       static null = {<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >> = "", static typeName = 0x7ffff4e38b8a "string", static debug = 0, static null = <same as static member of an already seen type>}}, 
       static typeName = 0x7ffff4e398eb "word", static debug = 0, static null = {<Foam::string> = {<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >> = "", static typeName = 0x7ffff4e38b8a "string", static debug = 0, 
        static null = {<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >> = "", static typeName = 0x7ffff4e38b8a "string", static debug = 0, static null = <same as static member of an already seen type>}}, 
       static typeName = 0x7ffff4e398eb "word", static debug = 0, static null = {<Foam::string> = {<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >> = "", static typeName = 0x7ffff4e38b8a "string", static debug = 0, 
        static null = {<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >> = "", static typeName = 0x7ffff4e38b8a "string", static debug = 0, static null = <same as static member of an already seen type>}}, 
        static typeName = 0x7ffff4e398eb "word", static debug = 0, static null = {<Foam::string> = {<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >> = "", static typeName = 0x7ffff4e38b8a "string", static debug = 0, 
         static null = {<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >> = "", static typeName = 0x7ffff4e38b8a "string", static debug = 0, static null = <same as static member of an already seen type>}}, 
        static typeName = 0x7ffff4e398eb "word", static debug = 0, static null = {<Foam::string> = {<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >> = "", static typeName = 0x7ffff4e38b8a "string", static debug = 0, 
         static null = {<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >> = "", static typeName = 0x7ffff4e38b8a "string", static debug = 0, static null = <same as static member of an already seen type>}}, 
         static typeName = 0x7ffff4e398eb "word", static debug = 0, static null = {<Foam::string> = {<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >> = "", static typeName = 0x7ffff4e38b8a "string", static debug = 0, 
          static null = {<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >> = "", static typeName = 0x7ffff4e38b8a "string", static debug = 0, static null = <same as static member of an already seen type>}}, 
         static typeName = 0x7ffff4e398eb "word", static debug = 0, static null = {<Foam::string> = {<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >> = "", static typeName = 0x7ffff4e38b8a "string", static debug = 0, 
          static null = {<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >> = "", static typeName = 0x7ffff4e38b8a "string", static debug = 0, static null = <same as static member of an already seen type>}}, 
          static typeName = 0x7ffff4e398eb "word", static debug = 0, static null = {<Foam::string> = {<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >> = "", static typeName = 0x7ffff4e38b8a "string", static debug = 0, 
           static null = {<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >> = "", static typeName = 0x7ffff4e38b8a "string", static debug = 0, static null = <same as static member of an already seen type>}}, 
          static typeName = 0x7ffff4e398eb "word", static debug = 0, static null = {<Foam::string> = {<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >> = "", static typeName = 0x7ffff4e38b8a "string", static debug = 0, 
           static null = {<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >> = "", static typeName = 0x7ffff4e38b8a "string", static debug = 0, static null = <same as static member of an already seen type>}}, 
           static typeName = 0x7ffff4e398eb "word", static debug = 0, static null = {<Foam::string> = {<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >> = "", static typeName = 0x7ffff4e38b8a "string", 

私の質問は:Cのこの種++クラスGDBにおける構造とどのようにより良い結果を印刷することと間違っている何

ありがとうございます!

+0

なぜ標準の 'std :: string'ではなく' std :: __ cxx11 :: basic_string'を使用していますか? – ks1322

答えて

4

あなたはこれを試みることができる:再帰は静的部材を介して起こるので、これは、より管理しやすい出力を生じるはずである

set print static-members off 

。あるいは、そのタイプにPython pretty-printerと書くこともできますが、それはもちろんもっと複雑です。

1

私はこの問題をeclipseで突き止めました。その結果、デバッグセッションが黙ってクラッシュしました。 これは本当にうんざりされ、 'set print static-members off'は回避策ですが実行可能な解決策ではありません。

+0

この問題はGDB 8.1で修正されています(自分で検証していない)。対応するコミットを参照してください。 https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;a=commit;h = a43f3893f6cb66dfca7f628cd159a008009ad06f –

関連する問題