Skip to content

[FIX] Preserve combined debug mask flags and sync Rust logger after CLI parsing - #2527

Open
harshalsp07 wants to merge 1 commit into
CCExtractor:masterfrom
harshalsp07:fix/debug-flags
Open

harshalsp07 wants to merge 1 commit into
CCExtractor:masterfrom
harshalsp07:fix/debug-flags

Conversation

@harshalsp07

Copy link
Copy Markdown
Contributor

In raising this pull request, I confirm the following (please check boxes):

Reason for this PR:

  • This PR adds new functionality.
  • This PR fixes a bug that I have personally experienced or that a real user has reported and for which a sample exists.
  • This PR is porting code from C to Rust.

Sanity check:

  • I have read and understood the contributors guide.
  • I have checked that another pull request for this purpose does not exist.
  • If the PR adds new functionality, I've added it to the changelog. If it's just a bug fix, I have NOT added it to the changelog.
  • I am NOT adding new C code unless it's to fix an existing, reproducible bug.

Repro instructions:

Pass more than one debug option on a repository sample (for example tests/samples/scc_23_976.scc):

./ccextractor --debug --608 tests/samples/scc_23_976.scc

On master, every debug flag in src/rust/src/parser.rs reassigns self.debug_mask = DebugMessageMask::new(...) instead of setting its bit like C params.c used to. Because of that:

  • Combining debug flags drops every earlier flag (--debug --608 shows [Debug: No] in the config summary, and --parsedebug --parsePAT --parsePMT --608 loses all earlier TS/parser traces).
  • Passing any single debug flag clears the default CCX_DMT_GENERIC_NOTICES (DebugMessageFlag::GENERIC_NOTICE) bit.
  • ccxr_init_basic_logger() initializes CCExtractorLogger before ccxr_parse_parameters(), and ccxr_update_logger_target() only updates target afterwards, so Rust logger calls never see parsed debug_mask flags or --gui-mode-reports.
  • --708 no longer initializes the [CEA-708] env_logger output (ccxr_init_logger()), so [CEA-708] log::debug! traces are never printed.

Changes

  • Preserve debug mask bits (src/rust/lib_ccxr/src/util/log.rs, src/rust/src/parser.rs):
    • Added DebugMessageMask::enable_flag() to insert a flag into both mask_on_normal and mask_on_debug.
    • Updated all 14 debug options (--debug, --608, --708, --goppts, --xdsdebug, --vides, --cbraw, --parsedebug, --parsePAT, --parsePMT, --dumpdef, --deblev, --debugdvbsub, --tverbose) in OptionsExt::parse_parameters to use enable_flag() instead of overwriting self.debug_mask.
  • Sync logger settings and [CEA-708] init after CLI parsing (src/rust/src/libccxr_exports/mod.rs, src/rust/src/lib.rs):
    • Added CCExtractorLogger::debug_mask(), set_debug_mask(), and set_gui_mode(), and updated ccxr_update_logger_target() to sync target, debug_mask, and gui_mode from ccx_options.
    • Updated ccxr_update_logger_target() to call ccxr_init_logger() when DECODER_708 is active and output is not quiet (--quiet / --out=report), and switched ccxr_init_logger() from .init() to .try_init().
  • Tests (src/rust/src/cli_tests.rs, src/rust/src/parser.rs, src/rust/lib_ccxr/src/util/log.rs, src/rust/src/libccxr_exports/mod.rs):
    • Added unit tests for enable_flag, logger setters, parse_output_target, parse_debug_mask truncation/fallback, should_init_cea708_logger, and combined debug flags.
    • Added C-FFI tests in cli_tests.rs covering all 13 previously untested debug flags and ccxr_update_logger_target() syncing.

Testing

  • cargo fmt --manifest-path src/rust/Cargo.toml --all -- --check and cargo fmt --manifest-path src/rust/lib_ccxr/Cargo.toml --all -- --check: passed.
  • cargo clippy --manifest-path src/rust/lib_ccxr/Cargo.toml -- -D warnings and cargo clippy --manifest-path src/rust/Cargo.toml -- -D warnings: passed.
  • cargo test --manifest-path src/rust/lib_ccxr/Cargo.toml: 59 unit tests + 46 doc-tests passed.
  • cargo test --manifest-path src/rust/Cargo.toml: 454 tests passed.
  • Full C+Rust CMake binary verified with --debug --608 on tests/samples/scc_23_976.scc, --parsedebug --parsePAT --parsePMT --608 on a synthetic TS stream, and --708 --goppts (with and without --quiet) on a synthetic MPEG-2 ES with GA94 CEA-708 user data.

The Rust CLI parser replaced self.debug_mask on every debug flag
(--debug, --608, --708, --goppts, --xdsdebug, --vides, --cbraw,
--parsedebug, --parsePAT, --parsePMT, --dumpdef, --deblev,
--debugdvbsub, --tverbose) instead of setting the requested bit.
Passing multiple debug flags wiped out earlier ones, and passing any
debug flag cleared the default GENERIC_NOTICE bit.

In addition, ccxr_init_basic_logger() initializes CCExtractorLogger
before argument parsing, and ccxr_update_logger_target() only updated
the output target afterwards. As a result, Rust logger calls never saw
parsed debug flags or --gui_mode_reports, and --708 never initialized
the [CEA-708] env_logger output that the C parser previously started.

Add DebugMessageMask::enable_flag() and use it across all 14 debug
flags in OptionsExt::parse_parameters, sync debug_mask and gui_mode in
ccxr_update_logger_target(), initialize the CEA-708 logger via try_init()
when DECODER_708 is active and output is not quiet, and add Rust unit
and C-FFI tests covering combined debug flags and logger syncing.
@ccextractor-bot

Copy link
Copy Markdown
Collaborator
CCExtractor CI platform finished running the test files on linux. 171/238 tests matched the approved output:
Report Name Tests Passed
Broken 9/13
CEA-708 2/14
DVB 0/7
DVD 3/3
DVR-MS 2/2
General 26/28
Hardsubx 1/1
Hauppage 3/3
MP4 3/3
NoCC 10/10
Options 68/86
Teletext 0/21
WTV 12/13
XDS 32/34

67 tests do not match the approved output. That is the pass/fail verdict. Whether this branch caused it is a separate question, answered below.


Compared with the tip of master — test 10180, commit 2c1c1c6:

  • 0 pass there and fail here
  • 0 fail there and pass here
  • 0 fail on both, with different output
  • 67 fail on both, byte for byte the same

Compared with the commit this branch was cut from: the same run as the tip of master (test 10180), so the comparison above already covers it.


No test changes behaviour relative to the tip of master: every failure above fails there too, byte for byte. The approved output for those tests is out of date, which is a baseline to review rather than a regression in this branch.

@ccextractor-bot

Copy link
Copy Markdown
Collaborator
CCExtractor CI platform finished running the test files on windows. 171/238 tests matched the approved output:
Report Name Tests Passed
Broken 9/13
CEA-708 2/14
DVB 0/7
DVD 3/3
DVR-MS 2/2
General 26/28
Hardsubx 1/1
Hauppage 3/3
MP4 3/3
NoCC 10/10
Options 68/86
Teletext 0/21
WTV 12/13
XDS 32/34

67 tests do not match the approved output. That is the pass/fail verdict. Whether this branch caused it is a separate question, answered below.


Compared with the tip of master — test 10179, commit f56427e:

  • 0 pass there and fail here
  • 0 fail there and pass here
  • 0 fail on both, with different output
  • 67 fail on both, byte for byte the same

Compared with the commit this branch was cut from — test 10181, commit 2c1c1c6:

  • 0 pass there and fail here
  • 0 fail there and pass here
  • 0 fail on both, with different output
  • 67 fail on both, byte for byte the same

No test changes behaviour relative to the tip of master: every failure above fails there too, byte for byte. The approved output for those tests is out of date, which is a baseline to review rather than a regression in this branch.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants