bkryza / clang-uml

Customizable automatic UML diagram generator for C++ based on Clang.
Apache License 2.0
550 stars 40 forks source link

Add debug log with information which filter rejected some element #147

Open bkryza opened 1 year ago

bkryza commented 1 year ago

Currently it is very difficult to figure out why specific element e.g. a class, was not included in the diagram. Usually this is caused by improper filters definition.

There should be a log entry in the verbose log with information on which filter rejected any of the elements (this could be a lot - but it will be limited to translation units specified by glob pattern and system headers are skipped by default anyway...)

rob-weiss commented 9 months ago

Is there any workaround until this is implemented? When I run

clang-uml --progress -vvv --remove-compile-flag -Wno-error=class-memaccess --remove-compile-flag -rdynamic --print-from -n example_class_diagram | grep RsbLoc::StationaryLocations::StationaryLocations

I get

Dc::Per::RsbLoc::StationaryLocations::StationaryLocations(const ObstacleSensorRoad::sensor_type &,const ::Per::Frames::Rot1dAcc2dFor &,const TrackedPolylines &)

When I copy the output to my generated .uml-clang file, it generates an almost empty .puml file.

@startuml

'Generated with clang-uml, version 0.4.0
'LLVM version Ubuntu clang version 12.0.0-3ubuntu1~20.04.5
@enduml

It works fine for type: class. Here's my config:

# Change to directory where compile_commands.json is
compilation_database_dir: /workspaces/repos/pj-dc_int/build/unittests/compile_commands.json
# Change to directory where diagram should be written
output_directory: diagrams
diagrams:
  example_class_diagram:
    type: sequence
    glob:
      - src/*.cpp
    using_namespace:
      - Dc::Per::RsbLoc
    include:
      namespaces:
        - Dc::Per::RsbLoc
    exclude:
      namespaces:
        - myproject::detail
    from:
      - function: "Dc::Per::RsbLoc::StationaryLocations::StationaryLocations(const ObstacleSensorRoad::sensor_type &,const ::Per::Frames::Rot1dAcc2dFor &,const TrackedPolylines &)"
clang-uml --version                                                                                                                         ─╯
clang-uml 0.4.0
Copyright (C) 2021-2023 Bartek Kryza <bkryza@gmail.com>
Linux x86_64 3.10.0-1160.95.1.el7.x86_64
Built against LLVM/Clang libraries version: 12.0.0
Using LLVM/Clang libraries version: Ubuntu clang version 12.0.0-3ubuntu1~20.04.5
bkryza commented 9 months ago

@rob-weiss Can you generate the diagram with full verbosity and without -p and check if you get an error saying that the specified entrypoint method signature was not found?

rob-weiss commented 9 months ago

Thanks for your swift reply, @bkryza! I was wondering why -vvv didn't seem to have any effect and wasn't aware that -p prevents the output.

clang-uml -vvv --remove-compile-flag -Wno-error=class-memaccess --remove-compile-flag -rdynamic 

doesn't seem to throw any apparent errors like the one mentioned above, but it seems to be missing sequences. I could share the full log, but it's massive.

...
[trace] [tid 73608] [diagram.cc:447]        Message from=Dc::Per::RsbLoc::StationaryLocations::getValidTrackedLocations(const TrackedPolylines &) const, from_id=2117836952607764917, to=Dc::Per::RsbLoc::Vertex::getX() const, to_id=263640730606845517, name=getX, type=call
[trace] [tid 73608] [diagram.cc:447]        Message from=Dc::Per::RsbLoc::StationaryLocations::getValidTrackedLocations(const TrackedPolylines &) const, from_id=2117836952607764917, to=Dc::Per::RsbLoc::Vertex::getY() const, to_id=1115386493799863632, name=getY, type=call
[trace] [tid 73608] [diagram.cc:447]        Message from=Dc::Per::RsbLoc::StationaryLocations::getValidTrackedLocations(const TrackedPolylines &) const, from_id=2117836952607764917, to=Dc::Per::RsbLoc::EllipticalRatioInterpolator::calcEllipticalRatioForRegionQuery(const vfc::float32_t), to_id=984077938161644863, name=Dc::Per::RsbLoc::EllipticalRatioInterpolator::calcEllipticalRatioForRegionQuery, type=call
[trace] [tid 73608] [diagram.cc:447]        Message from=Dc::Per::RsbLoc::StationaryLocations::getValidTrackedLocations(const TrackedPolylines &) const, from_id=2117836952607764917, to=Dc::Per::RsbLoc::Location::Location(const vfc::float32_t,const vfc::CRadian,const vfc::float32_t,const vfc::float32_t,const vfc::float32_t,const vfc::int32_t,const vfc::float32_t), to_id=395498143371739108, name=Dc::Per::RsbLoc::Location::Location, type=call
[trace] [tid 73608] [diagram.cc:438]        Message from=Dc::Per::RsbLoc::StationaryLocations::getValidTrackedLocations(const TrackedPolylines &) const, from_id=2117836952607764917, to=__UNRESOLVABLE_ID__, to_id=0, name=, type=end for
[trace] [tid 73608] [diagram.cc:438]        Message from=Dc::Per::RsbLoc::StationaryLocations::getValidTrackedLocations(const TrackedPolylines &) const, from_id=2117836952607764917, to=__UNRESOLVABLE_ID__, to_id=0, name=, type=end for
[trace] [tid 73608] [diagram.cc:424] Sequence id=2221320942975980108:
[trace] [tid 73608] [diagram.cc:428]    Activity id=2221320942975980108, from=Dc::Per::RsbLoc::findBestMergeCandidate<40,200>(const vfc::int32_t,const Dc::Per::RsbLocTypes::Polylines<40,200> &):
[trace] [tid 73608] [diagram.cc:447]        Message from=Dc::Per::RsbLoc::findBestMergeCandidate<40,200>(const vfc::int32_t,const Dc::Per::RsbLocTypes::Polylines<40,200> &), from_id=2221320942975980108, to=Dc::Per::RsbLoc::findAllMergeCandidates<40,200>(const vfc::int32_t,const Dc::Per::RsbLocTypes::Polylines<40,200> &,vfc::TFixedVector<vfc::int32_t,Params::maxNumberOfMergeCandidates> &,vfc::TFixedVector<vfc::float32_t,Params::maxNumberOfMergeCandidates> &), to_id=629456817618112261, name=Dc::Per::RsbLoc::findAllMergeCandidates, type=call
[debug] [tid 73608] [sequence_diagram_generator.cc:498] Found sequence diagram start point: 848280990975368959
[debug] [tid 73608] [sequence_diagram_generator.cc:144] Generating message [848280990975368959] --> [635751086666514868]
[debug] [tid 73608] [sequence_diagram_generator.cc:107] Generated call 'getValidCurrentLocations(const ObstacleSensorRoad::sensor_type &,const ::Per::Frames::Rot1dAcc2dFor &) const' from true [848280990975368959] to true [635751086666514868]
[debug] [tid 73608] [sequence_diagram_generator.cc:156] Creating activity 848280990975368959 --> 635751086666514868 - missing sequence 635751086666514868
[debug] [tid 73608] [sequence_diagram_generator.cc:144] Generating message [635751086666514868] --> [941675519119347269]
[debug] [tid 73608] [sequence_diagram_generator.cc:107] Generated call '__isValidLocation(const ObstacleSensorRoad::sensor_type &,const ::Per::Frames::Rot1dAcc2dFor &)__' from true [635751086666514868] to true [941675519119347269]
[debug] [tid 73608] [sequence_diagram_generator.cc:156] Creating activity 635751086666514868 --> 941675519119347269 - missing sequence 941675519119347269
[debug] [tid 73608] [sequence_diagram_generator.cc:144] Generating message [941675519119347269] --> [10223226466453449]
[debug] [tid 73608] [sequence_diagram_generator.cc:107] Generated call '__invalidateMovingLocations(const ObstacleSensorRoad::sensor_type &,const ::Per::Frames::Rot1dAcc2dFor &)__' from true [941675519119347269] to true [10223226466453449]
[debug] [tid 73608] [sequence_diagram_generator.cc:156] Creating activity 941675519119347269 --> 10223226466453449 - missing sequence 10223226466453449
[debug] [tid 73608] [sequence_diagram_generator.cc:144] Generating message [941675519119347269] --> [1364985846403034051]
[debug] [tid 73608] [sequence_diagram_generator.cc:107] Generated call '__markValidElevationPeer(const ::Per::InputCollection< ::Per::InterfaceRadar::RadarBoschGen5Feature,Dc::Per::Param::PerCompiletimeParamConfig::get_g_sizeMeasRF()> &,const vfc::uint32_t,LocationMaskType &)__' from true [941675519119347269] to true [1364985846403034051]
[debug] [tid 73608] [sequence_diagram_generator.cc:156] Creating activity 941675519119347269 --> 1364985846403034051 - missing sequence 1364985846403034051
[debug] [tid 73608] [sequence_diagram_generator.cc:144] Generating message [635751086666514868] --> [1898973953744879010]
[debug] [tid 73608] [sequence_diagram_generator.cc:107] Generated call '__calcEllipticalRatioForRegionQuery(const vfc::float32_t,const vfc::float32_t)__' from true [635751086666514868] to true [1898973953744879010]
[debug] [tid 73608] [sequence_diagram_generator.cc:156] Creating activity 635751086666514868 --> 1898973953744879010 - missing sequence 1898973953744879010
[debug] [tid 73608] [sequence_diagram_generator.cc:144] Generating message [1898973953744879010] --> [1512139706327837390]
[debug] [tid 73608] [sequence_diagram_generator.cc:107] Generated call 'getInterpolation(const vfc::float32_t) const' from true [1898973953744879010] to true [1512139706327837390]
[debug] [tid 73608] [sequence_diagram_generator.cc:156] Creating activity 1898973953744879010 --> 1512139706327837390 - missing sequence 1512139706327837390
[debug] [tid 73608] [sequence_diagram_generator.cc:144] Generating message [1898973953744879010] --> [1512139706327837390]
[debug] [tid 73608] [sequence_diagram_generator.cc:107] Generated call 'getInterpolation(const vfc::float32_t) const' from true [1898973953744879010] to true [1512139706327837390]
[debug] [tid 73608] [sequence_diagram_generator.cc:156] Creating activity 1898973953744879010 --> 1512139706327837390 - missing sequence 1512139706327837390
[debug] [tid 73608] [sequence_diagram_generator.cc:144] Generating message [635751086666514868] --> [395498143371739108]
[debug] [tid 73608] [sequence_diagram_generator.cc:107] Generated call 'Location(const vfc::float32_t,const vfc::CRadian,const vfc::float32_t,const vfc::float32_t,const vfc::float32_t,const vfc::int32_t,const vfc::float32_t)' from true [635751086666514868] to true [395498143371739108]
[debug] [tid 73608] [sequence_diagram_generator.cc:163] Skipping activity 635751086666514868 --> 395498143371739108 - missing sequence 395498143371739108
[debug] [tid 73608] [sequence_diagram_generator.cc:144] Generating message [848280990975368959] --> [2117836952607764917]
[debug] [tid 73608] [sequence_diagram_generator.cc:107] Generated call 'getValidTrackedLocations(const TrackedPolylines &) const' from true [848280990975368959] to true [2117836952607764917]
[debug] [tid 73608] [sequence_diagram_generator.cc:156] Creating activity 848280990975368959 --> 2117836952607764917 - missing sequence 2117836952607764917
[debug] [tid 73608] [sequence_diagram_generator.cc:144] Generating message [2117836952607764917] --> [201190617364001809]
[debug] [tid 73608] [sequence_diagram_generator.cc:107] Generated call 'getCyclesSinceMeasured() const' from true [2117836952607764917] to true [201190617364001809]
[debug] [tid 73608] [sequence_diagram_generator.cc:156] Creating activity 2117836952607764917 --> 201190617364001809 - missing sequence 201190617364001809
[debug] [tid 73608] [sequence_diagram_generator.cc:144] Generating message [2117836952607764917] --> [263640730606845517]
[debug] [tid 73608] [sequence_diagram_generator.cc:107] Generated call 'getX() const' from true [2117836952607764917] to true [263640730606845517]
[debug] [tid 73608] [sequence_diagram_generator.cc:163] Skipping activity 2117836952607764917 --> 263640730606845517 - missing sequence 263640730606845517
[debug] [tid 73608] [sequence_diagram_generator.cc:144] Generating message [2117836952607764917] --> [1115386493799863632]
[debug] [tid 73608] [sequence_diagram_generator.cc:107] Generated call 'getY() const' from true [2117836952607764917] to true [1115386493799863632]
[debug] [tid 73608] [sequence_diagram_generator.cc:163] Skipping activity 2117836952607764917 --> 1115386493799863632 - missing sequence 1115386493799863632
[debug] [tid 73608] [sequence_diagram_generator.cc:144] Generating message [2117836952607764917] --> [263640730606845517]
[debug] [tid 73608] [sequence_diagram_generator.cc:107] Generated call 'getX() const' from true [2117836952607764917] to true [263640730606845517]
[debug] [tid 73608] [sequence_diagram_generator.cc:163] Skipping activity 2117836952607764917 --> 263640730606845517 - missing sequence 263640730606845517
[debug] [tid 73608] [sequence_diagram_generator.cc:144] Generating message [2117836952607764917] --> [1115386493799863632]
[debug] [tid 73608] [sequence_diagram_generator.cc:107] Generated call 'getY() const' from true [2117836952607764917] to true [1115386493799863632]
[debug] [tid 73608] [sequence_diagram_generator.cc:163] Skipping activity 2117836952607764917 --> 1115386493799863632 - missing sequence 1115386493799863632
[debug] [tid 73608] [sequence_diagram_generator.cc:144] Generating message [2117836952607764917] --> [984077938161644863]
[debug] [tid 73608] [sequence_diagram_generator.cc:107] Generated call '__calcEllipticalRatioForRegionQuery(const vfc::float32_t)__' from true [2117836952607764917] to true [984077938161644863]
[debug] [tid 73608] [sequence_diagram_generator.cc:156] Creating activity 2117836952607764917 --> 984077938161644863 - missing sequence 984077938161644863
[debug] [tid 73608] [sequence_diagram_generator.cc:144] Generating message [984077938161644863] --> [1512139706327837390]
[debug] [tid 73608] [sequence_diagram_generator.cc:107] Generated call 'getInterpolation(const vfc::float32_t) const' from true [984077938161644863] to true [1512139706327837390]
[debug] [tid 73608] [sequence_diagram_generator.cc:156] Creating activity 984077938161644863 --> 1512139706327837390 - missing sequence 1512139706327837390
[debug] [tid 73608] [sequence_diagram_generator.cc:144] Generating message [984077938161644863] --> [1348448219752293813]
[debug] [tid 73608] [sequence_diagram_generator.cc:107] Generated call 'LinearInterpolator(const vfc::float32_t,const vfc::float32_t,const vfc::float32_t,const vfc::float32_t)' from true [984077938161644863] to true [1348448219752293813]
[debug] [tid 73608] [sequence_diagram_generator.cc:156] Creating activity 984077938161644863 --> 1348448219752293813 - missing sequence 1348448219752293813
[debug] [tid 73608] [sequence_diagram_generator.cc:144] Generating message [984077938161644863] --> [1348448219752293813]
[debug] [tid 73608] [sequence_diagram_generator.cc:107] Generated call 'LinearInterpolator(const vfc::float32_t,const vfc::float32_t,const vfc::float32_t,const vfc::float32_t)' from true [984077938161644863] to true [1348448219752293813]
[debug] [tid 73608] [sequence_diagram_generator.cc:156] Creating activity 984077938161644863 --> 1348448219752293813 - missing sequence 1348448219752293813
[debug] [tid 73608] [sequence_diagram_generator.cc:144] Generating message [2117836952607764917] --> [395498143371739108]
[debug] [tid 73608] [sequence_diagram_generator.cc:107] Generated call 'Location(const vfc::float32_t,const vfc::CRadian,const vfc::float32_t,const vfc::float32_t,const vfc::float32_t,const vfc::int32_t,const vfc::float32_t)' from true [2117836952607764917] to true [395498143371739108]
[debug] [tid 73608] [sequence_diagram_generator.cc:163] Skipping activity 2117836952607764917 --> 395498143371739108 - missing sequence 395498143371739108
[debug] [tid 73608] [sequence_diagram_generator.cc:144] Generating message [848280990975368959] --> [1042686377999027375]
[debug] [tid 73608] [sequence_diagram_generator.cc:107] Generated call '' from true [848280990975368959] to true [1042686377999027375]
[debug] [tid 73608] [sequence_diagram_generator.cc:156] Creating activity 848280990975368959 --> 1042686377999027375 - missing sequence 1042686377999027375
[info] [tid 73608] [generators.cc:78] Written example_class_diagram diagram to /workspaces/repos/pj-dc_int/dc_fw/src/per/src/controllers/rsbloc/diagrams/example_class_diagram.puml
bkryza commented 9 months ago

@rob-weiss I'm actually AFK until tomorrow afternoon, and I cant see any apparent problem in the logs on my phone but I'll check tomorrow on my monitor...

bkryza commented 9 months ago

@rob-weiss I've checked the logs and it's very strange as the log message Generated call and Generating message are printed along with printing to the PlantUML output stream - so I'm not sure at the moment how it is possible that you are getting an empty file with these logs. If you could share the entire log output it could be helpful.

Also, could you try generating the diagram in MermaidJS and JSON formats as well to see if maybe this is an issue only related to PlantUML generator?

clang-uml -vvv -g json -g mermaid --remove-compile-flag -Wno-error=class-memaccess --remove-compile-flag -rdynamic 
rob-weiss commented 9 months ago

I had switched branches in the meantime and deleted the generated file. It suddenly worked, without any changes. VS Code usually displays changes in files that were changed in the background. No idea what the problem actually was though. Also the JSON and Mermaid output work fine. Sorry for bothering you and thank you so much for this wonderful tool, really appreciate it :)

bkryza commented 9 months ago

@rob-weiss No problem, glad it worked!