CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Programming & Development

Recursive output of Foam::word in gdb print command

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   July 18, 2017, 19:11
Unhappy Recursive output of Foam::word in gdb print command
  #1
Member
 
Di Cheng
Join Date: May 2010
Location: Beijing, China
Posts: 47
Rep Power: 16
chengdi is on a distinguished road
Hi, everyone

I am using gdb to read OpenFOAM codes and it is difficult to print fields like p and U because it contains recursively self static contained class Foam::word type and hence the gdb's print command will output things like this:

Code:
(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",
                                  static debug = 0, static null = {<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >> = "", static typeName = 0x7ffff4e38b8a "string", static debug = 0,
question: I want to know why and how to print it better.

note: Foam::word is contained in almost every Foam object, so the print command is almost useless in gdb now.

I tried to search stack-overflow and this forum. I found some circumvent method to overcome this in certain cases. For example

Code:
(gdb) p *p.v_@p.size_
$86 = {0, 0, 0, 0, 0, 0, 0, 0, 0}
will output the scalarFields values and do not output any Foam::word

However, it is difficult to apply this method to U, a Foam::GeometricField vector type.
chengdi is offline   Reply With Quote

Old   July 19, 2017, 20:19
Default
  #2
Member
 
Di Cheng
Join Date: May 2010
Location: Beijing, China
Posts: 47
Rep Power: 16
chengdi is on a distinguished road
As the answer in stackoverflow: https://stackoverflow.com/a/45184261/4592964

set print static-members off

is a good choice
chengdi is offline   Reply With Quote

Reply

Tags
gdb, openfoam


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Working directory via command line Luiz CFX 4 March 6, 2011 20:02
Problems of running the parallel computations lorraine FLUENT 17 July 6, 2007 08:08
Job Scheduler for parallel processing kumar2 OpenFOAM Running, Solving & CFD 10 March 8, 2006 06:09
Output from the Monitor point command swapnil CFX 0 November 20, 2002 22:08
command to output run information? x. yan Siemens 2 October 17, 2001 01:56


All times are GMT -4. The time now is 01:46.