Coder Social home page Coder Social logo

Comments (15)

mubes avatar mubes commented on July 29, 2024

from orbuculum.

Benjoyo avatar Benjoyo commented on July 29, 2024

Thanks for your reply. Does that work? Btw the example code above is not entirely correct, I have a nrf_delay_ms(1000); inside the loop.

trace.txt

from orbuculum.

mubes avatar mubes commented on July 29, 2024

from orbuculum.

Benjoyo avatar Benjoyo commented on July 29, 2024

Yes, it does. I tried several traces that I collected, all segfault. Some give an ITM Overflow warning before, some don't. Can this be related to my machine? I am running this on a Raspberry Pi 3 B+. Normal ITM SendChar etc. works totally fine though.

from orbuculum.

mubes avatar mubes commented on July 29, 2024

from orbuculum.

mubes avatar mubes commented on July 29, 2024

Just tried it over lunch on Ubuntu on Pi. Still works perfectly :-/ Do you get any warnings on build?

Next step is to run it under gdb with your existing command line like; gdb --args so we can see where exactly it's falling over.

from orbuculum.

Benjoyo avatar Benjoyo commented on July 29, 2024

Good idea, this is what gdb gave me:

(gdb) run
Starting program: /home/pi/orb/ofiles/orbuculum -f trace.txt
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/arm-linux-gnueabihf/libthread_db.so.1".
[New Thread 0x76e12460 (LWP 4082)]
[New Thread 0x76611460 (LWP 4083)]

Thread 1 "orbuculum" received signal SIGSEGV, Segmentation fault.
strlen () at ../sysdeps/arm/armv6t2/strlen.S:126
126	../sysdeps/arm/armv6t2/strlen.S: No such file or directory.
(gdb) bt
#0  strlen () at ../sysdeps/arm/armv6t2/strlen.S:126
#1  0x76e9f344 in __vfprintf_internal (s=s@entry=0x7effe290, format=format@entry=0x406920 "%d,%ld,%d,%s,0x%x\n", ap=..., ap@entry=..., 
    mode_flags=mode_flags@entry=0) at vfprintf-internal.c:1688
#2  0x76eab0a4 in __vsnprintf_internal (string=0x7effe3dc "4,56,0,0", maxlen=<optimized out>, format=0x406920 "%d,%ld,%d,%s,0x%x\n", 
    format@entry=0x7effe3bc "\004", args=..., args@entry=..., mode_flags=mode_flags@entry=0) at vsnprintf.c:114
#3  0x76e92d26 in __GI___snprintf (s=<optimized out>, maxlen=<optimized out>, format=0x406920 "%d,%ld,%d,%s,0x%x\n") at snprintf.c:31
#4  0x004040aa in _handleDataRWWP ()
#5  0x0040446a in _itmPumpProcess ()
#6  0x00401f82 in _processBlock ()
#7  0x00402f5c in fileFeeder ()
#8  0x00401804 in main ()
(gdb) 

I actually got a lot of string format warnings when building, I thought that would be fine but now that I see this error it may actually have something to do with it?

Example:

Src/fifos.c: In function ‘_handleException’:
Src/fifos.c:309:66: warning: format ‘%ld’ expects argument of type ‘long int’, but argument 5 has type ‘uint64_t’ {aka ‘long long unsigned int’} [-Wformat=]
  309 |         opLen = snprintf( outputString, MAX_STRING_LENGTH, "%d,%ld,%s,%s" EOL, HWEVENT_EXCEPTION, eventdifftS, exEvent[m->eventType & 0x03], exNames[m->exceptionNumber & 0x0F] );
      |                                                                ~~^                                ~~~~~~~~~~~
      |                                                                  |                                |
      |                                                                  long int                         uint64_t {aka long long unsigned int}
      |                                                                %lld

If you don't have an immediate clue I will try with ubuntu instead of raspbian tomorrow. Did you use 20.04?

from orbuculum.

mubes avatar mubes commented on July 29, 2024

from orbuculum.

mubes avatar mubes commented on July 29, 2024

The dwt_segfault_fix contains a patch for the deprecation warning. It's also where any eventual patch for this segfault would end up going.

DAVE

from orbuculum.

mubes avatar mubes commented on July 29, 2024

Src/fifos.c: In function ‘_handleException’:
Src/fifos.c:309:66: warning: format ‘%ld’ expects argument of type ‘long int’, but argument 5 has type ‘uint64_t’ {aka ‘long long unsigned int’} [-Wformat=]
309 | opLen = snprintf( outputString, MAX_STRING_LENGTH, "%d,%ld,%s,%s" EOL, HWEVENT_EXCEPTION, eventdifftS, exEvent[m->eventType & 0x03], exNames[m->exceptionNumber & 0x0F] );
| ~~^ ~~~~~~~~~~~
| | |
| long int uint64_t {aka long long unsigned int}
| %lld

Now, this could easily cause a problem. AFAIK rasbian is 32 bit native so then all of the other parameters on that command line would be out by 32 bits. Can you try changing that parameter to %lld and let's see if that fixes it? If it does then I guess we need to use the exact length format specifiers for printf, which we can easily do...but let's see if that's the problem first.

from orbuculum.

mubes avatar mubes commented on July 29, 2024

Benjoyo,

It's flying a bit of a kite, but please try the current dwt_segfault_fix branch. It includes explicit 64 bit uint codings. I don't know if it will work but it's worth a fiddle with.

DAVE

from orbuculum.

Benjoyo avatar Benjoyo commented on July 29, 2024

It's flying a bit of a kite, but please try the current dwt_segfault_fix branch. It includes explicit 64 bit uint codings. I don't know if it will work but it's worth a fiddle with.

Yes! That does work! The warnings for fifos.c are gone and it writes to hwevent file just fine, no segfault.

If it helps, this is the build output with the remaining warnings:

Compiling Src/generics.c
 Compiling Src/itmDecoder.c
 Compiling Src/tpiuDecoder.c
 Compiling Src/msgDecoder.c
 Compiling Src/msgSeq.c
Completed build of orb
 Compiling Src/orbuculum.c
 Compiling Src/filewriter.c
 Compiling Src/external/ftdispi.c
 Compiling Src/fifos.c
 Compiling Src/nwclient.c
Completed build of orbuculum
 Compiling Src/orbcat.c
Completed build of orbcat
 Compiling Src/orbtop.c
In file included from Src/orbtop.c:59:
Src/orbtop.c: In function ‘_outputTop’:
Inc/generics.h:67:19: warning: format ‘%ld’ expects argument of type ‘long int’, but argument 5 has type ‘uint64_t’ {aka ‘long long unsigned int’} [-Wformat=]
   67 | #define C_YELLOW  "\033[1;33m"
      |                   ^~~~~~~~~~~~
Src/orbtop.c:637:38: note: in expansion of macro ‘C_YELLOW’
  637 |                     fprintf( stdout, C_YELLOW "%3d.%02d%% " C_LBLUE " %8ld ", percentage / 100, percentage % 100, report[n].count );
      |                                      ^~~~~~~~
Src/orbtop.c:637:74: note: format string is defined here
  637 |                     fprintf( stdout, C_YELLOW "%3d.%02d%% " C_LBLUE " %8ld ", percentage / 100, percentage % 100, report[n].count );
      |                                                                       ~~~^
      |                                                                          |
      |                                                                          long int
      |                                                                       %8lld
In file included from Src/orbtop.c:59:
Inc/generics.h:67:19: warning: format ‘%ld’ expects argument of type ‘long int’, but argument 5 has type ‘uint64_t’ {aka ‘long long unsigned int’} [-Wformat=]
   67 | #define C_YELLOW  "\033[1;33m"
      |                   ^~~~~~~~~~~~
Src/orbtop.c:693:22: note: in expansion of macro ‘C_YELLOW’
  693 |     fprintf( stdout, C_YELLOW "%3d.%02d%% " C_LBLUE " %8ld " C_RESET "of "C_YELLOW" %ld "C_RESET" Samples" EOL, totPercent / 100, totPercent % 100, dispSamples, samples );
      |                      ^~~~~~~~
Src/orbtop.c:693:58: note: format string is defined here
  693 |     fprintf( stdout, C_YELLOW "%3d.%02d%% " C_LBLUE " %8ld " C_RESET "of "C_YELLOW" %ld "C_RESET" Samples" EOL, totPercent / 100, totPercent % 100, dispSamples, samples );
      |                                                       ~~~^
      |                                                          |
      |                                                          long int
      |                                                       %8lld
In file included from Src/orbtop.c:59:
Inc/generics.h:67:19: warning: format ‘%ld’ expects argument of type ‘long int’, but argument 6 has type ‘uint64_t’ {aka ‘long long unsigned int’} [-Wformat=]
   67 | #define C_YELLOW  "\033[1;33m"
      |                   ^~~~~~~~~~~~
Src/orbtop.c:693:22: note: in expansion of macro ‘C_YELLOW’
  693 |     fprintf( stdout, C_YELLOW "%3d.%02d%% " C_LBLUE " %8ld " C_RESET "of "C_YELLOW" %ld "C_RESET" Samples" EOL, totPercent / 100, totPercent % 100, dispSamples, samples );
      |                      ^~~~~~~~
Src/orbtop.c:693:87: note: format string is defined here
  693 |     fprintf( stdout, C_YELLOW "%3d.%02d%% " C_LBLUE " %8ld " C_RESET "of "C_YELLOW" %ld "C_RESET" Samples" EOL, totPercent / 100, totPercent % 100, dispSamples, samples );
      |                                                                                     ~~^
      |                                                                                       |
      |                                                                                       long int
      |                                                                                     %lld
 Compiling Src/symbols.c
 Compiling Src/external/cJSON.c
Completed build of orbtop
 Compiling Src/orbdump.c
Completed build of orbdump
 Compiling Src/orbstat.c
Src/orbstat.c: In function ‘_dumpProfile’:
Src/orbstat.c:367:65: warning: format ‘%ld’ expects argument of type ‘long int’, but argument 9 has type ‘uint64_t’ {aka ‘long long unsigned int’} [-Wformat=]
  367 |             fprintf( _r.c, "fl=(%d) %s\nfn=(%d) %s\n0x%08x %d %ld\n", t->index, t->n->filename, t->index, t->n->function, t->n->addr, t->n->line, myCost );
      |                                                               ~~^                                                                                 ~~~~~~
      |                                                                 |                                                                                 |
      |                                                                 long int                                                                          uint64_t {aka long long unsigned int}
      |                                                               %lld
Src/orbstat.c:396:65: warning: format ‘%ld’ expects argument of type ‘long int’, but argument 9 has type ‘uint64_t’ {aka ‘long long unsigned int’} [-Wformat=]
  396 |             fprintf( _r.c, "fl=(%d) %s\nfn=(%d) %s\n0x%08x %d %ld\n", t->index, t->n->filename, t->index, t->n->function, t->n->addr, t->n->line, myCost );
      |                                                               ~~^                                                                                 ~~~~~~
      |                                                                 |                                                                                 |
      |                                                                 long int                                                                          uint64_t {aka long long unsigned int}
      |                                                               %lld
Src/orbstat.c:415:37: warning: format ‘%ld’ expects argument of type ‘long int’, but argument 5 has type ‘uint64_t’ {aka ‘long long unsigned int’} [-Wformat=]
  415 |         fprintf( _r.c, "0x%08x %d %ld\n", _r.sub[i].src, f->n->line, totalCost );
      |                                   ~~^                                ~~~~~~~~~
      |                                     |                                |
      |                                     long int                         uint64_t {aka long long unsigned int}
      |                                   %lld
Src/orbstat.c: In function ‘_outputProfile’:
Src/orbstat.c:475:32: warning: format ‘%ld’ expects argument of type ‘long int’, but argument 3 has type ‘uint64_t’ {aka ‘long long unsigned int’} [-Wformat=]
  475 |     fprintf( _r.c, "summary: %ld\n", _r.calls[_r.cdCount - 1].tstamp - _r.calls[0].tstamp );
      |                              ~~^     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      |                                |                                     |
      |                                long int                              uint64_t {aka long long unsigned int}
      |                              %lld
Completed build of orbstat

But for my current use case that fix was enough, thanks so much!

from orbuculum.

mubes avatar mubes commented on July 29, 2024

from orbuculum.

Benjoyo avatar Benjoyo commented on July 29, 2024

Yes, all warnings are gone 👍

from orbuculum.

mubes avatar mubes commented on July 29, 2024

OK, this is now folded into main, as at 9f6a8e9

from orbuculum.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.