Skip to content
This repository was archived by the owner on Jan 17, 2019. It is now read-only.

Logger: added tool for parsing new trace format#77

Merged
lgirdwood merged 2 commits intothesofproject:masterfrom
bkokoszx:logger
Sep 28, 2018
Merged

Logger: added tool for parsing new trace format#77
lgirdwood merged 2 commits intothesofproject:masterfrom
bkokoszx:logger

Conversation

@bkokoszx
Copy link
Copy Markdown
Contributor

I've added tool for parsing new trace format.
As input tool gets two files:

  1. extracted .static_log_entries section generated by rimage in file *ldc (sof\src\arch\xtensa*ldc) - this rimage feature is added in #418 PR in sof repository;
  2. binary file containing catch trace from dma.
    Tool throws parsed logs to stdout.

Copy link
Copy Markdown
Member

@lgirdwood lgirdwood left a comment

Choose a reason for hiding this comment

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

@bardliao please work with @bkokoszx here so that teh kernel output will align with the new tool. Can you also provide some kernel output once you have the ASCII HEX part working.

Comment thread logger/logger.c Outdated
uint32_t *params;
};

struct dma_log_header {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Is this a FW struct, if so we should include it from a header in uapi/

@bardliao is also making changes to the driver to use the kernel trace framework to output the tarce/log data. This means the format output will be the structure in ASCII HEX format.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@lgirdwood Ok, but in what way can I include uapi headers existing in different repo? (sof)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@bkokoszx the should be installed by "make install" rule from FW.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I've included from "/usr/local/include/sof/uapi/logging.h"

Comment thread logger/logger.c Outdated
entry.file_name,
entry.header.line_idx);

switch(entry.header.params_num){
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

switch ( needs a space

Comment thread logger/logger.c Outdated
switch(entry.header.params_num){
case 0:
fprintf(stdout, "%s", entry.text);
break;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

break should be indented.

Comment thread logger/logger.c
uint32_t base_address,
uint32_t data_offset,
struct dma_log dma_log) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

why the newlines within the variable declaration block ?

Comment thread logger/logger.c Outdated

/* fetching elf header params */
ret = fread(&entry.header, sizeof(entry.header), 1, f_ldc);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

no need for newline

Comment thread logger/logger.c Outdated
/* fetching text */
entry.text = (char *) malloc(entry.text_len);
if (entry.text == NULL) {
printf("Memory error.");
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

fprintf(stderr, "error: can't alocate %d bytes for XXX\n"); and for similar errors.

Comment thread logger/logger.c Outdated
return ret;
}

int main(int argc, char *argv[]) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

{ on next line

Comment thread logger/logger.c Outdated
int ret;

if (argc < 3) {
printf("Error: Too few input arguments. \n");
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

fprintf(stderr, etc...
this should also print the usage of logger including cmd line args.

Comment thread logger/logger.c Outdated
return -EINVAL;
}

const char *LDC_DIR = argv[1];
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This should be in one block above and lowercase

Comment thread logger/Makefile.am Outdated
@@ -0,0 +1,4 @@
bin_PROGRAMS = logger
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

sof-logger as this will avoid namespace conflicts.

@bkokoszx bkokoszx force-pushed the logger branch 3 times, most recently from 174554d to 957ee93 Compare September 27, 2018 09:35
@bkokoszx
Copy link
Copy Markdown
Contributor Author

travis-ci was expected to fail. Sof should be installed ("make install") before building soft.

@xiulipan
Copy link
Copy Markdown
Contributor

@bkokoszx
Why we need sof install for soft?
We want SOFT to be install independently. Thus why we move rimage into sof to avoid this situation.

@bkokoszx
Copy link
Copy Markdown
Contributor Author

@xiulipan
I have to exploit struct existing in uapi header in FW. I can use use it since I install FW (make install copy headers to: /usr/local/include/sof/uapi/). It was change due Liam suggestion (#77 (comment)).
@lgirdwood
Did I misunderstand something?

@xiulipan
Copy link
Copy Markdown
Contributor

@lgirdwood
So now we need some dependency on SOF again?
What should this work with trace event from @bardliao then? And the trace level from @RanderWang

@singalsu
Copy link
Copy Markdown
Collaborator

@bkokoszx @lgirdwood Is it possible for you to remove the offending code from SOF if this work is not mature enough to be merged to kernel and SOFT.

@lgirdwood
Copy link
Copy Markdown
Member

@xiulipan soft tools can depend on sof. rimage was moved as dependency was the other way around. The tools need the uapi headers to use the ABI.

@bkokoszx can you resend new PR today and ignore the ASCII HEX readback part, this wont be ready for at least a week since national holidays in China.

@bkokoszx
Copy link
Copy Markdown
Contributor Author

@lgirdwood
Can not it be merge from this PR? I've made changes due to your suggestions

@lgirdwood
Copy link
Copy Markdown
Member

lgirdwood commented Sep 28, 2018

@bkokoszx have you re-pushed the new updates. I can still see some changes related to errno that are missing. i.e. you are returning EINVAL when you should be returning errno.

@bkokoszx
Copy link
Copy Markdown
Contributor Author

@lgirdwood
I have return errno only to handle fopen functions. I've read that fread function doesn't set errno, so in that case I return EINVAL. Am I wrong?

@xiulipan
Copy link
Copy Markdown
Contributor

@lgirdwood
So how do we handler the CI issues?
If we need to git clone SOF first?

@bkokoszx
And how about the old rmbox? should this logger to replace the rmbox or rmbox will still alive?
Maybe you can just rewrite the rmbox with the rmbox help functions.

Comment thread logger/logger.c Outdated
int ret;

const char *ldc_dir = argv[1];
const char *dma_dump = argv[2];
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.

Can you take rmbox as reference to have use getopt for the function.
Or just replace the old rmbox.

	while ((opt = getopt(argc, argv, "ho:i:s:m:c:t")) != -1) {
		switch (opt) {
		case 'o':
			out_file = optarg;
			break;
		case 'i':
			in_file = optarg;
			break;
		case 't':
			trace = 1;
			break;
		case 'c':
			clk = atof(optarg);
			break;
		case 's':
			return snapshot(optarg);
		case 'h':
		default: /* '?' */
			usage(argv[0]);
		}
	}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@bkokoszx yes pls use getopt, no need to replace rmbox atm as we need it for legacy. I want to merge this PR today.

@bkokoszx
Copy link
Copy Markdown
Contributor Author

To handle fread I use following code:
ret = fread(..., file);
if (!ret) {
ret = -ferror(file);
goto out;
}
I will update getops

Signed-off-by: Bartosz Kokoszko <bartoszx.kokoszko@linux.intel.com>
Signed-off-by: Bartosz Kokoszko <bartoszx.kokoszko@linux.intel.com>
@bkokoszx
Copy link
Copy Markdown
Contributor Author

@lgirdwood
I've updated PR using getops function

@lgirdwood lgirdwood merged commit 918e401 into thesofproject:master Sep 28, 2018
@lgirdwood
Copy link
Copy Markdown
Member

@bkokoszx one more change that can be done incrementally is to use relative path for uapi/logger.h i.e. include <sof/uapi/logger.h>

@cujomalainey
Copy link
Copy Markdown
Contributor

Synchronization through version matching in the ABI?

@lgirdwood
Copy link
Copy Markdown
Member

Yes, we would need some version data. @bkokoszx can you add versioning support here and we can duplicate the header.

@mwierzbix
Copy link
Copy Markdown
Contributor

mwierzbix commented Oct 10, 2018

@lgirdwood @bkokoszx regarding header duplication in developement.
We could do this via git-submodule.
Make soft repo an optional submodule for sof repo, like ${sof_repo_root}/soft
This way, if one wants to checkout only soft he still can do this (it is separate repository still), and then can either replicate the directory tree and place the header in ${soft_repo_root}/../src/include/uapi/logging.h, or symlink it (even from a different repo).

And when you checkout both sof and soft inside of it, then you can freely change between branches/commits of both sof and soft.

If you want to check if logger from soft revision A works with sof revision B, then you just

cd "${sof_repo_root}"
git checkout B
cd soft
git checkout A
./logger (...)

Or we could do this the other way around.
Treat sof as a "library" for soft, and then make logger look for the header file in ${soft_repo_root}/sof, which would be a submodule populated via git-submodule update or just containing a header file / symlink to header file.

If you want to check if logger from soft revision A works with sof revision B, then you just

cd "${soft_repo_root}"
git checkout A
cd sof
git checkout B
cd ..
./logger (...)

And without populating submodule, only copying file

cd "${soft_repo_root}"
echo "sof/" >> .gitignore
mkdir -p sof/src/include/uapi
cp "${header_path}" sof/src/include/uapi/logging.h

or symlinking file
ln -s "${header_path}" sof/src/include/uapi/logging.h
from elsewhere.

git-submodule is an elegant way of forcing fixed directory structure between multiple git repositories.
What BTW we already have (it is, fixed directory structure, not git-submodule) with sof and sof-docs.

Regading how to make git-submodule optional: https://stackoverflow.com/questions/44366417/what-is-the-point-of-git-submodule-init

@dabekjakub
Copy link
Copy Markdown
Member

@mwierzbix @lgirdwood @bkokoszx
In my experience having duplicate headers doesn't work very good. Tool repository headers will get updated only when the tool stops working and most of the users won't even be aware of the dependency. Which in worst case can lead to incorrect translation of the logs with no other symptoms.

Another solution to this could be moving logger itself to the FW repository (As was done with rimage). Since then we will have a complete package after building (FW and application to translate logs).

@lgirdwood
Copy link
Copy Markdown
Member

@mmaka1 any objections to merging soft -> sof repo ? This would make CI easier too for working topologies since they would be aligned with FW. @cujomalainey would merging repos be OK for you ?

@cujomalainey
Copy link
Copy Markdown
Contributor

Would it be just the tools migrated or the topologies as well? Either should be fine, I don't see any reason why that would be an issue over here. We will just need to update the scripts and docker system once the change is done.

@lgirdwood
Copy link
Copy Markdown
Member

@cujomalainey everything over, tools and topologies.

@mmaka1
Copy link
Copy Markdown

mmaka1 commented Oct 11, 2018

@lgirdwood I am Ok with this simplification.

@bkokoszx bkokoszx deleted the logger branch October 16, 2018 07:51
@bkokoszx
Copy link
Copy Markdown
Contributor Author

@lgirdwood What is your opinion about using git-submodule mentioned by @mwierzbix?

@mwierzbix
Copy link
Copy Markdown
Contributor

@cujomalainey
Copy link
Copy Markdown
Contributor

Just make sure everyone understands to run git submodule update --init --recursive otherwise there will be a lot of confusing build failures

@mwierzbix
Copy link
Copy Markdown
Contributor

@cujomalainey Hmm, you suggest README.md or maybe get-sof.sh?

@cujomalainey
Copy link
Copy Markdown
Contributor

I would do a readme personally. Git submodules are pretty easy once you get over the short learning curve. The script would add to the confusion in my opinion.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants