Debug logging of items

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Debug logging of items

Cornelis Bockemühl

Right now I am fighting my way through large amounts of CMake code (actually working on a ParaView custom application with many own plugins, views, domains, property widgets etc. etc.), and it is sometimes really not easy not to lose track completely! Sometimes I am happy to be back into complex C++ programming - because I see much more logic in the entire thing. And it is of course no news that CMake code is not famous for being easy to debug.

Anyway, I am dreaming of some "simple" features that would sometimes help a lot, and it is all about "dumping" some kind of data. Actually this is for me often also the favorite way to debug C++ code: just print out the values of variables, arrays, etc. - e.g. if setting a breakpoint in the debugger is difficult because you are interested only in the 928773th occurrence of a certain piece of code (without even knowing that number...).

Accordingly in CMake code I am working a lot with the message() function - but within that code the problem is often that you do not even know which variables would be available at all!

Thus functions like would be really great to have:

    “give me a list of all currently known targets”
    “give me a list of all properties of a target”
    “give me a list of all currently defined variables”
    etc.

What I do not know is: Are this things that already exist - in which case I would be happy if somebody could tell me how to find them! -, or are these functions rather "feature requests"?

In fact I can hardly believe that I am the first with such kind of dreams, so my hope is still that they already exist somewhere...

--
Cornelis Bockemühl
mail: [hidden email]
phone: +41 79 644 9943
Basel, Switzerland
https://cobo.bockemuehl.ch


--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
https://cmake.org/mailman/listinfo/cmake
Reply | Threaded
Open this post in threaded view
|

Re: Debug logging of items

Eric Doenges

I don't know about the targets, but you can get all variables currently defined for a directory by reading the VARIABLES property, e.g.

get_property(_variables DIRECTORY "${CMAKE_SOURCE_DIR}" PROPERTY VARIABLES)

I use this to dump the variables into a file so I can see with which variable settings my build directory was configured with.

With kind regards,
Eric

Am 20.09.19 um 14:49 schrieb Cornelis Bockemühl:

Right now I am fighting my way through large amounts of CMake code (actually working on a ParaView custom application with many own plugins, views, domains, property widgets etc. etc.), and it is sometimes really not easy not to lose track completely! Sometimes I am happy to be back into complex C++ programming - because I see much more logic in the entire thing. And it is of course no news that CMake code is not famous for being easy to debug.

Anyway, I am dreaming of some "simple" features that would sometimes help a lot, and it is all about "dumping" some kind of data. Actually this is for me often also the favorite way to debug C++ code: just print out the values of variables, arrays, etc. - e.g. if setting a breakpoint in the debugger is difficult because you are interested only in the 928773th occurrence of a certain piece of code (without even knowing that number...).

Accordingly in CMake code I am working a lot with the message() function - but within that code the problem is often that you do not even know which variables would be available at all!

Thus functions like would be really great to have:

    “give me a list of all currently known targets”
    “give me a list of all properties of a target”
    “give me a list of all currently defined variables”
    etc.

What I do not know is: Are this things that already exist - in which case I would be happy if somebody could tell me how to find them! -, or are these functions rather "feature requests"?

In fact I can hardly believe that I am the first with such kind of dreams, so my hope is still that they already exist somewhere...

--
Cornelis Bockemühl
mail: [hidden email]
phone: +41 79 644 9943
Basel, Switzerland
https://cobo.bockemuehl.ch


--

Dr. Eric Dönges
Senior Software Engineer

MVTec Software GmbH | Arnulfstr. 205 | 80634 Munich | Germany
[hidden email] | Tel: +49 89 457 695-0 | www.mvtec.com

Find our privacy policy here.

 Sign up for our MVTec Newsletter!

Geschäftsführer: Dr. Wolfgang Eckstein, Dr. Olaf Munkelt
Amtsgericht München HRB 114695

 

MVTec Software GmbH Logo

--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
https://cmake.org/mailman/listinfo/cmake
Reply | Threaded
Open this post in threaded view
|

Re: ?==?utf-8?q? Debug logging of items

Cornelis Bockemühl

Hi Eric,

Thanks for the hint regarding dumping variables: That's good to know!

However, I was learning that working with CMake is in may ways a question of adopting some "good practice", but it is not really being enforced by the language. One of the things that are for me part of this good practice would be to deal with targets and their dependencies, and properties. Which means a certain degree of modularity in the sense that you can easily plug projects together by just referring to targets, like by calling find_package().

But again: You will never easily know what a package is actually giving you - without investing hours and days of code reading - and maybe not even then!

But calling some "dump_targets" function after "find_package" (or also before and after - for comparison) would give you a chance to know the effect of endless "code deserts" with one line of code.

And because this is so fundamental in my eyes, I still almost assume that also for targets and properties there must be some function available - which I simply have not found yet!??

Or else I would consider this an urgent feature request!

Best regards,
Cornelis


Am Freitag, September 20, 2019 15:07 CEST, Eric Doenges <[hidden email]> schrieb:
 

 

I don't know about the targets, but you can get all variables currently defined for a directory by reading the VARIABLES property, e.g.

get_property(_variables DIRECTORY "${CMAKE_SOURCE_DIR}" PROPERTY VARIABLES)

I use this to dump the variables into a file so I can see with which variable settings my build directory was configured with.

With kind regards,
Eric

Am 20.09.19 um 14:49 schrieb Cornelis Bockemühl:

Right now I am fighting my way through large amounts of CMake code (actually working on a ParaView custom application with many own plugins, views, domains, property widgets etc. etc.), and it is sometimes really not easy not to lose track completely! Sometimes I am happy to be back into complex C++ programming - because I see much more logic in the entire thing. And it is of course no news that CMake code is not famous for being easy to debug.

Anyway, I am dreaming of some "simple" features that would sometimes help a lot, and it is all about "dumping" some kind of data. Actually this is for me often also the favorite way to debug C++ code: just print out the values of variables, arrays, etc. - e.g. if setting a breakpoint in the debugger is difficult because you are interested only in the 928773th occurrence of a certain piece of code (without even knowing that number...).

Accordingly in CMake code I am working a lot with the message() function - but within that code the problem is often that you do not even know which variables would be available at all!

Thus functions like would be really great to have:

    “give me a list of all currently known targets”
    “give me a list of all properties of a target”
    “give me a list of all currently defined variables”
    etc.

What I do not know is: Are this things that already exist - in which case I would be happy if somebody could tell me how to find them! -, or are these functions rather "feature requests"?

In fact I can hardly believe that I am the first with such kind of dreams, so my hope is still that they already exist somewhere...

--

Dr. Eric Dönges
Senior Software Engineer

MVTec Software GmbH | Arnulfstr. 205 | 80634 Munich | Germany
doenges@... | Tel: +49 89 457 695-0 | www.mvtec.com

Find our privacy policy here.

 Sign up for our MVTec Newsletter!

Geschäftsführer: Dr. Wolfgang Eckstein, Dr. Olaf Munkelt
Amtsgericht München HRB 114695

 


--
Cornelis Bockemühl
mail: [hidden email]
phone: +41 79 644 9943
Basel, Switzerland
https://cobo.bockemuehl.ch

--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
https://cmake.org/mailman/listinfo/cmake
Reply | Threaded
Open this post in threaded view
|

Re: ?==?utf-8?q? Debug logging of items

Craig Scott-3
You may want to take a look at the BUILDSYSTEM_TARGETS directory property. It might not be quite what you're looking for, but it might be close enough. I'm not aware of any way to get a list of all defined properties on a given target though.


On Mon, Sep 23, 2019 at 12:47 AM Cornelis Bockemühl <[hidden email]> wrote:

Hi Eric,

Thanks for the hint regarding dumping variables: That's good to know!

However, I was learning that working with CMake is in may ways a question of adopting some "good practice", but it is not really being enforced by the language. One of the things that are for me part of this good practice would be to deal with targets and their dependencies, and properties. Which means a certain degree of modularity in the sense that you can easily plug projects together by just referring to targets, like by calling find_package().

But again: You will never easily know what a package is actually giving you - without investing hours and days of code reading - and maybe not even then!

But calling some "dump_targets" function after "find_package" (or also before and after - for comparison) would give you a chance to know the effect of endless "code deserts" with one line of code.

And because this is so fundamental in my eyes, I still almost assume that also for targets and properties there must be some function available - which I simply have not found yet!??

Or else I would consider this an urgent feature request!

Best regards,
Cornelis


Am Freitag, September 20, 2019 15:07 CEST, Eric Doenges <[hidden email]> schrieb:
 

 

I don't know about the targets, but you can get all variables currently defined for a directory by reading the VARIABLES property, e.g.

get_property(_variables DIRECTORY "${CMAKE_SOURCE_DIR}" PROPERTY VARIABLES)

I use this to dump the variables into a file so I can see with which variable settings my build directory was configured with.

With kind regards,
Eric

Am 20.09.19 um 14:49 schrieb Cornelis Bockemühl:

Right now I am fighting my way through large amounts of CMake code (actually working on a ParaView custom application with many own plugins, views, domains, property widgets etc. etc.), and it is sometimes really not easy not to lose track completely! Sometimes I am happy to be back into complex C++ programming - because I see much more logic in the entire thing. And it is of course no news that CMake code is not famous for being easy to debug.

Anyway, I am dreaming of some "simple" features that would sometimes help a lot, and it is all about "dumping" some kind of data. Actually this is for me often also the favorite way to debug C++ code: just print out the values of variables, arrays, etc. - e.g. if setting a breakpoint in the debugger is difficult because you are interested only in the 928773th occurrence of a certain piece of code (without even knowing that number...).

Accordingly in CMake code I am working a lot with the message() function - but within that code the problem is often that you do not even know which variables would be available at all!

Thus functions like would be really great to have:

    “give me a list of all currently known targets”
    “give me a list of all properties of a target”
    “give me a list of all currently defined variables”
    etc.

What I do not know is: Are this things that already exist - in which case I would be happy if somebody could tell me how to find them! -, or are these functions rather "feature requests"?

In fact I can hardly believe that I am the first with such kind of dreams, so my hope is still that they already exist somewhere...



--
Craig Scott
Melbourne, Australia

Get the hand-book for every CMake user: Professional CMake: A Practical Guide
Consulting services (CMake, C++, build/release processes): https://crascit.com/services

--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
https://cmake.org/mailman/listinfo/cmake

62A4-5D878980-D-69A20B00 (22K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: ?==?utf-8?q? ?==?utf-8?q? ?= Debug logging of item

Cornelis Bockemühl

Thanks for the hint: This may indeed help for some situations!

But explicitly not in the most important case because it explicitly says "The list does not include any Imported Targets or Alias Targets, but does include Interface Libraries." Well, these would of course be the most important target types - like after a find_package().

I conclude from your answer (and the previous one) that indeed the thing that I am looking for does currently NOT exist! So I may try to launch it as a "feature request" - because I cannot believe that I am the only one who gets lost in this field.

On the other hand I can also not believe that it can be too difficult to implement: The interpreter can always tell me if a target_link_libraries(...) is referring to an "unknown target" - so why not have a function that simply tells me which targets are known - including ALL possible targets?

I like many of the automatisms that CMake is offering, but like with all automatisms: If things do not work as expected you need a way to find out what the problem is - and plain guessing is only an option for really trivial cases! But even there it is only second choice if the software could just as well tell you exactly what the problem is...

Best regards,
Cornelis

Am Sonntag, September 22, 2019 21:46 CEST, Craig Scott <[hidden email]> schrieb:
 

You may want to take a look at the BUILDSYSTEM_TARGETS directory property. It might not be quite what you're looking for, but it might be close enough. I'm not aware of any way to get a list of all defined properties on a given target though.
 
 
On Mon, Sep 23, 2019 at 12:47 AM Cornelis Bockemühl <cornelis@...> wrote:

Hi Eric,

Thanks for the hint regarding dumping variables: That's good to know!

However, I was learning that working with CMake is in may ways a question of adopting some "good practice", but it is not really being enforced by the language. One of the things that are for me part of this good practice would be to deal with targets and their dependencies, and properties. Which means a certain degree of modularity in the sense that you can easily plug projects together by just referring to targets, like by calling find_package().

But again: You will never easily know what a package is actually giving you - without investing hours and days of code reading - and maybe not even then!

But calling some "dump_targets" function after "find_package" (or also before and after - for comparison) would give you a chance to know the effect of endless "code deserts" with one line of code.

And because this is so fundamental in my eyes, I still almost assume that also for targets and properties there must be some function available - which I simply have not found yet!??

Or else I would consider this an urgent feature request!

Best regards,
Cornelis


Am Freitag, September 20, 2019 15:07 CEST, Eric Doenges <doenges@...> schrieb:
 

 

I don't know about the targets, but you can get all variables currently defined for a directory by reading the VARIABLES property, e.g.

get_property(_variables DIRECTORY "${CMAKE_SOURCE_DIR}" PROPERTY VARIABLES)

I use this to dump the variables into a file so I can see with which variable settings my build directory was configured with.

With kind regards,
Eric

Am 20.09.19 um 14:49 schrieb Cornelis Bockemühl:

Right now I am fighting my way through large amounts of CMake code (actually working on a ParaView custom application with many own plugins, views, domains, property widgets etc. etc.), and it is sometimes really not easy not to lose track completely! Sometimes I am happy to be back into complex C++ programming - because I see much more logic in the entire thing. And it is of course no news that CMake code is not famous for being easy to debug.

Anyway, I am dreaming of some "simple" features that would sometimes help a lot, and it is all about "dumping" some kind of data. Actually this is for me often also the favorite way to debug C++ code: just print out the values of variables, arrays, etc. - e.g. if setting a breakpoint in the debugger is difficult because you are interested only in the 928773th occurrence of a certain piece of code (without even knowing that number...).

Accordingly in CMake code I am working a lot with the message() function - but within that code the problem is often that you do not even know which variables would be available at all!

Thus functions like would be really great to have:

    “give me a list of all currently known targets”
    “give me a list of all properties of a target”
    “give me a list of all currently defined variables”
    etc.

What I do not know is: Are this things that already exist - in which case I would be happy if somebody could tell me how to find them! -, or are these functions rather "feature requests"?

In fact I can hardly believe that I am the first with such kind of dreams, so my hope is still that they already exist somewhere...

 
 
--
Craig Scott
Melbourne, Australia
 
Get the hand-book for every CMake user: Professional CMake: A Practical Guide
Consulting services (CMake, C++, build/release processes): https://crascit.com/services

--
Cornelis Bockemühl
mail: [hidden email]
phone: +41 79 644 9943
Basel, Switzerland
https://cobo.bockemuehl.ch

--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
https://cmake.org/mailman/listinfo/cmake