Skip to content

utl: Adds source lines to Logger#10231

Open
QuantamHD wants to merge 12 commits into
The-OpenROAD-Project:masterfrom
QuantamHD:source_lines
Open

utl: Adds source lines to Logger#10231
QuantamHD wants to merge 12 commits into
The-OpenROAD-Project:masterfrom
QuantamHD:source_lines

Conversation

@QuantamHD

Copy link
Copy Markdown
Collaborator

Summary

This PR adds source lines to warn+ log messages to aide in developer/agentic debugging.

This can be disabled by setting an env variable

DISABLE_SOURCE_LINES=1
ethanmoon@ethanmoon2:~/OpenROAD$ ./bazel-bin/openroad
OpenROAD bazel-nostamp
Features included (+) or not (-): -GPU -GUI -Python
This program is licensed under the BSD-3 license. See the LICENSE file for details.
Components of this program may be licensed under more restrictive licenses which must be honored.
openroad> initialize_floorplan
[ERROR IFP-0019] [bazel-out/k8-opt/bin/src/utl/swig.cc:2326] no -utilization or -die_area specified.
IFP-0019
while evaluating initialize_floorplan
openroad> [WARNING UTL-0014] [src/utl/src/Progress.cpp:52] OpenROAD will terminate after the next control+C

Type of Change

  • New feature

Verification

  • I have verified that the local build succeeds (./etc/Build.sh).
  • I have run the relevant tests and they pass.
  • My code follows the repository's formatting guidelines.
  • I have signed my commits (DCO).

This PR adds source lines to warn+ log messages to aide
in developer/agentic debugging.

This can be disabled by setting an env variable
```
DISABLE_SOURCE_LINES=1
```

```
ethanmoon@ethanmoon2:~/OpenROAD$ ./bazel-bin/openroad
OpenROAD bazel-nostamp
Features included (+) or not (-): -GPU -GUI -Python
This program is licensed under the BSD-3 license. See the LICENSE file for details.
Components of this program may be licensed under more restrictive licenses which must be honored.
openroad> initialize_floorplan
[ERROR IFP-0019] [bazel-out/k8-opt/bin/src/utl/swig.cc:2326] no -utilization or -die_area specified.
IFP-0019
while evaluating initialize_floorplan
openroad> [WARNING UTL-0014] [src/utl/src/Progress.cpp:52] OpenROAD will terminate after the next control+C
```

Signed-off-by: Ethan Mahintorabi <ethanmoon@google.com>

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request integrates std::source_location into the logging framework to provide file and line information for warning, error, and critical log levels. It introduces a LogMessage struct to encapsulate the message and location, adds environment variable support to disable the feature, and updates the build system to handle path mapping. Review feedback identifies a significant compatibility risk with the project's minimum compiler versions, a breaking change in the SWIG-based scripting interfaces, and a recommendation to pass LogMessage by reference to avoid unnecessary string copies.

Comment thread CMakeLists.txt
Comment thread src/utl/src/Logger.i Outdated
Comment thread src/utl/include/utl/Logger.h Outdated

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clang-tidy made some suggestions

Comment thread src/utl/include/utl/Logger.h
Comment thread src/utl/include/utl/Logger.h Outdated
Comment thread src/utl/src/LoggerCommon.cpp Outdated
Comment thread src/utl/src/LoggerCommon.h Outdated
Comment thread src/utl/src/LoggerCommon.h Outdated
Comment thread src/utl/src/LoggerCommon.h Outdated
Signed-off-by: Ethan Mahintorabi <ethanmoon@google.com>
@gadfort

gadfort commented Apr 23, 2026

Copy link
Copy Markdown
Contributor

I think this should be disabled by default and enabled as needed in a users environment

Signed-off-by: Ethan Mahintorabi <ethanmoon@google.com>
@github-actions

Copy link
Copy Markdown
Contributor

clang-tidy review says "All clean, LGTM! 👍"

Signed-off-by: Ethan Mahintorabi <ethanmoon@google.com>
Signed-off-by: Ethan Mahintorabi <ethanmoon@google.com>
@github-actions

Copy link
Copy Markdown
Contributor

clang-tidy review says "All clean, LGTM! 👍"

1 similar comment
@github-actions

Copy link
Copy Markdown
Contributor

clang-tidy review says "All clean, LGTM! 👍"

Comment thread CMakeLists.txt
@maliberty

Copy link
Copy Markdown
Member

[ERROR IFP-0019] [bazel-out/k8-opt/bin/src/utl/swig.cc:2326] no -utilization or -die_area specified.
IFP-0019

This isn't very helpful as the error is in ifp but the line in utl.

@QuantamHD

QuantamHD commented Apr 23, 2026

Copy link
Copy Markdown
Collaborator Author

The true error comes from TCL embedded in the app, but the C++ can't know that. We would need to wrap this logic in TCL proc and have TCL say what line number it came from.

I think it's a good start, and more motivation to move things into C++ rather than TCL.

Signed-off-by: Ethan Mahintorabi <ethanmoon@google.com>
@github-actions

Copy link
Copy Markdown
Contributor

clang-tidy review says "All clean, LGTM! 👍"

@maliberty

Copy link
Copy Markdown
Member

I think this should be off by default

@QuantamHD

Copy link
Copy Markdown
Collaborator Author

@gadfort @maliberty

Let me make an argument for keeping it on by default, if you still respond no I'll change it. Agents need more context to work in a loop this provides them that context to get them unstuck. I think if we're aiming for more agents to use OpenROAD in a loop this is beneficial to that use case. Keeping it off by default reduces the value of this feature significantly for the agent use case.

@maliberty

Copy link
Copy Markdown
Member

Perhaps you picked a bad example as the information shown would mislead an agent afaik (i.e. nothing pointed to ifp). Do you have a positive c++ example? Thoughts on how we can suppress it when coming from tcl?

@QuantamHD

QuantamHD commented Apr 27, 2026

Copy link
Copy Markdown
Collaborator Author
ethanmoon@ethanmoon2:~/OpenROAD$ bazelisk run //src/dpl/test:pad02-tcl_test
[INFO ODB-0227] LEF file: Nangate45/Nangate45.lef, created 22 layers, 27 vias, 135 library cells
[INFO ODB-0128] Design: single_cell
[INFO ODB-0130]     Created 2 pins.
[INFO ODB-0131]     Created 1 components and 4 component-terminals.
[INFO ODB-0132]     Created 2 special nets and 2 connections.
[INFO ODB-0133]     Created 2 nets and 2 connections.
[INFO DPL-0006] Core area: 34.05 um^2, Instances area: 1.86 um^2, Utilization: 5.5%
[INFO DPL-0005] Diamond search max displacement: +/- 500 sites horizontally, +/- 100 rows vertically.
[INFO DPL-1101] Legalizing using diamond search.
[ERROR DPL-0015] [src/dpl/src/Place.cpp:376] instance _277_ does not fit inside the ROW core area.
DPL-0015
image

@github-actions

Copy link
Copy Markdown
Contributor

clang-tidy review says "All clean, LGTM! 👍"

Signed-off-by: Ethan Mahintorabi <ethanmoon@google.com>
@QuantamHD

Copy link
Copy Markdown
Collaborator Author

@maliberty suppressed errors and warnings originating from TCL.

ethanmoon@ethanmoon2:~/OpenROAD$ bazel-bin/openroad
OpenROAD bazel-nostamp 
Features included (+) or not (-): -GPU -GUI -Python
This program is licensed under the BSD-3 license. See the LICENSE file for details.
Components of this program may be licensed under more restrictive licenses which must be honored.
openroad> initialize_floorplan 
[ERROR IFP-0019] no -utilization or -die_area specified.
IFP-0019
while evaluating initialize_floorplan 
openroad> [WARNING UTL-0014] [src/utl/src/Progress.cpp:52] OpenROAD will terminate after the next control+C

@github-actions

Copy link
Copy Markdown
Contributor

clang-tidy review says "All clean, LGTM! 👍"

Signed-off-by: Ethan Mahintorabi <ethanmoon@google.com>
@QuantamHD QuantamHD requested a review from maliberty April 27, 2026 20:42
@github-actions

Copy link
Copy Markdown
Contributor

clang-tidy review says "All clean, LGTM! 👍"

@maliberty

maliberty commented Apr 27, 2026

Copy link
Copy Markdown
Member

@oharboe opinion on on/off by default? Is this useful to you or your AI?

@oharboe

oharboe commented Apr 27, 2026

Copy link
Copy Markdown
Collaborator

No opinion. My use-case have changed though, I don't read logs as much as I used to, so I'm less sensitive to log spam, I suppose. Mostly claude reads logs these days.

@QuantamHD

QuantamHD commented Apr 27, 2026

Copy link
Copy Markdown
Collaborator Author

@oharboe The goal with this change is to give Gemini/claude more context on errors, namely to allow it to explore the code to get itself unstuck.

@oharboe

oharboe commented Apr 27, 2026

Copy link
Copy Markdown
Collaborator

@oharboe The goal with this change is to give Gemini/claude more context on errors, namely to allow it to explore the code to get itself unstuck.

Yes. This sort of logging fixes help enormously in closing the feedback loop is our experience too. I think it will work.

@maliberty

Copy link
Copy Markdown
Member

It is too front loaded with context, perhaps:

[ERROR IFP-0019] no -utilization or -die_area specified. [bazel-out/k8-opt/bin/src/utl/swig.cc:2326]

or

[ERROR IFP-0019] no -utilization or -die_area specified. 
     [bazel-out/k8-opt/bin/src/utl/swig.cc:2326]

@maliberty

Copy link
Copy Markdown
Member

A command should be introduced to control this rather than an envar.

@maliberty

Copy link
Copy Markdown
Member

debug/debugPrint too please.

@QuantamHD

Copy link
Copy Markdown
Collaborator Author

It is too front loaded with context, perhaps:

[ERROR IFP-0019] no -utilization or -die_area specified. [bazel-out/k8-opt/bin/src/utl/swig.cc:2326]

or

[ERROR IFP-0019] no -utilization or -die_area specified. 
     [bazel-out/k8-opt/bin/src/utl/swig.cc:2326]

This is difficult to acomodate due to the way splog interacts with std::format. You can append things to the front, but not the rear.

@QuantamHD

QuantamHD commented Apr 27, 2026

Copy link
Copy Markdown
Collaborator Author

A command should be introduced to control this rather than an

I'm amenable to a command, but the envvar is specifically for the unit tests to ensure the test harness can turn off this behavior for all unit tests at once. Are you okay if we have both?

@maliberty

Copy link
Copy Markdown
Member

This is difficult to acomodate due to the way splog interacts with std::format. You can append things to the front, but not the rear.

AI suggests pre-formatting the user portion:

  auto formatted = fmt::format(FMT_RUNTIME(message), args...);         
  logger_->log(level,                                                           
               "[{} {}-{:04d}] {} [{}:{}]{}",
               level_names[level],                                              
               tool_names_[tool],                                               
               id,
               formatted,                                                       
               loc.file_name(),                                        
               loc.line(),
               spdlog::details::os::default_eol);

@maliberty

Copy link
Copy Markdown
Member

I'm amenable to a command, but the envvar is specifically for the unit tests to ensure the test harness can turn off this behavior for all unit tests at once. Are you okay if we have both?

We have helpers.tcl and helpers.py in test/ where you could add the command (we already do this for supress_message).

@QuantamHD

Copy link
Copy Markdown
Collaborator Author

Do you want debug messages to always have source lines or be controllable similar to the other message. Since the debug messages are largely dev only I would argue the control doesn't make as much sense. It would also require duplicate code since the code paths for debug are different than those of the other log messages

@QuantamHD

Copy link
Copy Markdown
Collaborator Author
ethanmoon@ethanmoon2:~/OpenROAD$ bazel-bin/openroad
OpenROAD bazel-nostamp 
Features included (+) or not (-): -GPU -GUI -Python
This program is licensed under the BSD-3 license. See the LICENSE file for details.
Components of this program may be licensed under more restrictive licenses which must be honored.
openroad> [WARNING UTL-0014] OpenROAD will terminate after the next control+C [src/utl/src/Progress.cpp:52]

@gadfort @maliberty We happy with this?

@gadfort

gadfort commented Apr 28, 2026

Copy link
Copy Markdown
Contributor

@QuantamHD much better :-) thanks

@gadfort

gadfort commented Apr 28, 2026

Copy link
Copy Markdown
Contributor

@QuantamHD also to answer the other question, I would generally agree that on debug it's fine to how them without any gate

@maliberty

Copy link
Copy Markdown
Member

Agree for debug they are helpful.

Comment thread src/mpl/test/cpp/CMakeLists.txt
Comment thread src/mpl/test/BUILD Outdated
Signed-off-by: Ethan Mahintorabi <ethanmoon@google.com>
@QuantamHD QuantamHD requested review from a team as code owners May 15, 2026 21:51
QuantamHD added 2 commits May 15, 2026 21:54
Signed-off-by: Ethan Mahintorabi <ethanmoon@google.com>

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clang-tidy made some suggestions

Comment thread src/utl/src/Logger.cpp
addMetricsSink(metrics_filename);
}

const char* disable_source_lines = std::getenv("DISABLE_SOURCE_LINES");

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: no header providing "std::getenv" is directly included [misc-include-cleaner]

src/utl/src/Logger.cpp:8:

- #include <cstring>
+ #include <cstdlib>
+ #include <cstring>

@maliberty

Copy link
Copy Markdown
Member

@QuantamHD this seems to have stalled out. Is there more work from your perspective?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants