nuttx-apps icon indicating copy to clipboard operation
nuttx-apps copied to clipboard

refactor and modify the bugs of examples/elf project

Open extinguish opened this issue 1 month ago • 5 comments

Summary

  1. rearrange the elf test directory, make the sub-testcase in separate directory
  2. delete unnecessary generation of mod_symtab.c
  3. make the examples/elf project can work when signal is disabled
  4. avoid interference between different ELFs generated by symtab

this request is depends on https://github.com/apache/nuttx/pull/17397

Impact

mainly affect the examples/elf project, has no impact on other modules

Testing

  1. has passed the ostest:
End of test memory usage:
VARIABLE  BEFORE   AFTER
======== ======== ========
arena     4000000  4000000
ordblks         5        4
mxordblk  3e1e5e8  3e70e10
uordblks   17aed0   17aed0
fordblks  3e85130  3e85130

Final memory usage:
VARIABLE  BEFORE   AFTER
======== ======== ========
arena     4000000  4000000
ordblks         1        4
mxordblk  3e95de8  3e70e10
uordblks   16a218   17aed0
fordblks  3e95de8  3e85130
user_main: Exiting
ostest_main: Exiting with status 0
stdio_test: Standard I/O Check: fprintf to stderr
  1. elf test
nsh> elf
Initial memory usage: 16416
Registering romdisk at /dev/ram0

Memory Usage after romdisk_register:
  Before:    16416 After:    16480 Change:       64
Mounting ROMFS filesystem at target=/mnt/elf/romfs with source=/dev/ram0

Memory Usage after mount:
  Before:    16480 After:    17776 Change:     1296

****************************************************************************
* Executing errno
****************************************************************************


Memory Usage after exec:
  Before:    17776 After:    22960 Change:     5184
Wait a bit for test completion
Hello, World on stderr
We failed to open "aflav-sautga-ay!" errno is 2
Hello, World on stdout

Memory Usage after program execution:
  Before:    22960 After:    22776 Change:     -184

****************************************************************************
* Executing hello
****************************************************************************


Memory Usage after exec:
  Before:    22776 After:    22960 Change:      184
Wait a bit for test completion
Getting ready to say "Hello, world"

Hello, world!
It has been said.

argc	= 1
argv	= 0x1009160
argv[0]	= (0x1009168) "hello"
argv[1]	= 0
Goodbye, world!

Memory Usage after program execution:
  Before:    22960 After:    22776 Change:     -184

****************************************************************************
* Executing signal
****************************************************************************


Memory Usage after exec:
  Before:    22776 After:    22984 Change:      208
Wait a bit for test completion
Setting up signal handlers from pid=5
Old SIGUSR1 sighandler at 0
New SIGUSR1 sighandler at 0x2100045d
Old SIGUSR2 sighandler at 0
New SIGUSR2 sighandler at 0x2100045d
Raising SIGUSR1 from pid=5
Kill-ing SIGUSR1 from pid=5
siguser_action: Received signo=10 siginfo=0x1001e88 arg=0
  SIGUSR1 received
siginfo:
  si_signo  = 10
  si_code   = 0
  si_errno  = 4
  si_value  = 0
SIGUSR1 raised from pid=5
SIGUSR1 not received

Memory Usage after program execution:
  Before:    22984 After:    22776 Change:     -208

****************************************************************************
* Executing struct
****************************************************************************


Memory Usage after exec:
  Before:    22776 After:    22984 Change:      208
Wait a bit for test completion
Calling getstruct()
getstruct returned 0x21000f7c
  n = 42 (vs 42) PASS
  pn = 0x1008bc8 (vs 0x1008bc8) PASS
 *pn = 87 (vs 87) PASS
  ps = 0x21000f78 (vs 0x21000f78) PASS
  ps->n = 117 (vs 117) PASS
  pf = 0x21000e4d (vs 0x21000e4d) PASS
Calling mystruct->pf()
In dummyfunc() -- PASS
Exit-ing

Memory Usage after program execution:
  Before:    22984 After:    22776 Change:     -208

****************************************************************************
* Executing hello++1
****************************************************************************


Memory Usage after exec:
  Before:    22776 After:    22960 Change:      184
Wait a bit for test completion
Hello, World!

Memory Usage after program execution:
  Before:    22960 After:    22776 Change:     -184

****************************************************************************
* Executing hello++2
****************************************************************************


Memory Usage after exec:
  Before:    22776 After:    22960 Change:      184
Wait a bit for test completion
main: Started.  Creating MyThingSayer
CThingSayer::CThingSayer: I am!
main: Created MyThingSayer=0x01008a58
main: Calling MyThingSayer->Initialize
CThingSayer::Initialize: When told, I will say 'Hello, World!'
main: Calling MyThingSayer->SayThing
CThingSayer::SayThing: I am now saying 'Hello, World!'
main: Destroying MyThingSayer
CThingSayer::~CThingSayer: I cease to be
CThingSayer::~CThingSayer: I will never say 'Hello, World!' again
main: Returning

Memory Usage after program execution:
  Before:    22960 After:    22776 Change:     -184

****************************************************************************
* Executing hello++3
****************************************************************************


Memory Usage after exec:
  Before:    22776 After:    22984 Change:      208
Wait a bit for test completion
CThingSayer::CThingSayer: I am!
main: Started.  MyThingSayer should already exist
main: Calling MyThingSayer.Initialize
CThingSayer::Initialize: When told, I will say 'Hello, World!'
main: Calling MyThingSayer.SayThing
CThingSayer::SayThing: I am now saying 'Hello, World!'
main: Returning.  MyThingSayer should be destroyed

Memory Usage after program execution:
  Before:    22984 After:    22776 Change:     -208

****************************************************************************
* Executing mutex
****************************************************************************


Memory Usage after exec:
  Before:    22776 After:    23016 Change:      240
Wait a bit for test completion
Starting thread 1
Starting thread 2
Stopping threads
	Thread1	Thread2
Loops	11	10
Errors	0	0

Memory Usage after program execution:
  Before:    23016 After:    31416 Change:     8400

****************************************************************************
* Executing pthread
****************************************************************************


Memory Usage after exec:
  Before:    31416 After:    22960 Change:    -8456
Wait a bit for test completion
PARENT: started

PARENT: calling pthread_start with arg=305419896
CHILD: started with arg=305419896
CHILD: returning -2023406815
PARENT child exitted with -2023406815
PARENT returning success


Memory Usage after program execution:
  Before:    22960 After:    27096 Change:     4136

****************************************************************************
* Executing task
****************************************************************************


Memory Usage after exec:
  Before:    27096 After:    23016 Change:    -4080
Wait a bit for test completion
Parent: Started, pid=14
Parent: Calling task_create()
Parent: Waiting for child (pid=20)
Child: execv was successful!
Child: argc=2
Child: argv[0]="child"
Child: argv[1]="Hello from your parent!"
Child: Exit-ting with status=0
Parent: Exit-ing

Memory Usage after program execution:
  Before:    23016 After:    25728 Change:     2712

Memory Usage End-of-Test:
  Before:    25728 After:    25728 Change:        0

extinguish avatar Nov 28 '25 02:11 extinguish