Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add hex dump support for trace output #76

Closed
bobbingwide opened this issue Jan 18, 2019 · 2 comments
Closed

Add hex dump support for trace output #76

bobbingwide opened this issue Jan 18, 2019 · 2 comments

Comments

@bobbingwide
Copy link
Owner

@bobbingwide bobbingwide commented Jan 18, 2019

Sometimes, when you want to see the exact contents of data a print_r() is not good enough.
We need to be able to see a hex dump of each character.

Proposed solution

Provide a helper function to return data in hex dump format.

@bobbingwide bobbingwide self-assigned this Jan 18, 2019
@bobbingwide

This comment has been minimized.

Copy link
Owner Author

@bobbingwide bobbingwide commented Nov 22, 2019

In the first version I'll just include the helper functon bw_trace_hexdump which will load and call oik_hexdump from the hexdump shared library. oik-bwtrace will deliver the hexdump library in the libs folder. This file will need to be added to the oik-libs repository.
The hexdump logic is currently tested in oik-batch.

@bobbingwide

This comment has been minimized.

Copy link
Owner Author

@bobbingwide bobbingwide commented Nov 22, 2019

The hexdump function was written to support single byte characters.
To hexdump the first line of Hello Dolly add the following code in hello_dolly_get_lyric()

$lyr = bw_trace_hexdump( $lyrics[0]);
bw_trace2( $lyr, "lyric");

The hexdump output for the first line of "Hello Dolly" is

13
Hello, Dolly........ 48 65 6c 6c 6f 2c 20 44 6f 6c 6c 79 0d 

Notes:

  • When hexdumping characters such as £ and the number of characters dislplayed in the first half of the hexdump output may be fewer than 20.
  • e.g. For the input string ABCDEFG\n12345678910\t£"
    the output is
22\r\n
ABCDEFG.12345678910. 41 42 43 44 45 46 47 0a 31 32 33 34 35 36 37 38 39 31 30 09 \r\n
£.................. c2 a3 \r\n
  • The '.''s represent unprintable ( ctype_cntrl() ) characters or are just padding.
  • In the above example I'm showing the CRLFs that are part of the output
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
1 participant
You can’t perform that action at this time.