address_space, context macros in compiler.h - linux-kernel

How to understand the below macros found in include/linux/compiler.h.Mainly, address_space, context macros.
7 # define __user __attribute__((noderef, address_space(1)))
8 # define __kernel __attribute__((address_space(0)))
9 # define __safe __attribute__((safe))
10 # define __force __attribute__((force))
11 # define __nocast __attribute__((nocast))
12 # define __iomem __attribute__((noderef, address_space(2)))
13 # define __must_hold(x) __attribute__((context(x,1,1)))
14 # define __acquires(x) __attribute__((context(x,0,1)))
15 # define __releases(x) __attribute__((context(x,1,0)))
16 # define __acquire(x) __context__(x,1)
17 # define __release(x) __context__(x,-1)
18 # define __cond_lock(x,c) ((c) ? ({ __acquire(x); 1; }) : 0)
19 # define __percpu __attribute__((noderef, address_space(3)))
20 #ifdef CONFIG_SPARSE_RCU_POINTER
21 # define __rcu __attribute__((noderef, address_space(4)))
22 #else
23 # define __rcu
24 #endif

Related

When Accessing the Routes Symfony\Component\HttpFoundation\InputBag::get(): Argument #1 ($key) must be of type string, null given, error is thrown.,,

Symfony\Component\HttpFoundation\InputBag::get(): Argument #1 ($key) must be of type string, null given, called in D:\xampp\htdocs\laravelprojects\burgerStation\vendor\laravel\framework\src\Illuminate\Session\Middleware\StartSession.php on line 160
This is the Error
Help Need.
TypeError
Symfony\Component\HttpFoundation\InputBag::get(): Argument #1 ($key) must be of type string, null given, called in D:\xampp\htdocs\laravelprojects\burgerStation\vendor\laravel\framework\src\Illuminate\Session\Middleware\StartSession.php on line 160
http://127.0.0.1:8000/
Stack trace
Request
App
User
Context
Debug
Share
Collapse vendor frames
34
D:\xampp\htdocs\laravelprojects\burgerStation\vendor\symfony\http-foundation\InputBag.php
Symfony\Component\HttpFoundation\InputBag
:30
33
D:\xampp\htdocs\laravelprojects\burgerStation\vendor\laravel\framework\src\Illuminate\Session\Middleware\StartSession.php
Illuminate\Session\Middleware\StartSession
:160
32
:263
31
Illuminate\Session\Middleware\StartSession
:161
30
Illuminate\Session\Middleware\StartSession
:57
29
Illuminate\Pipeline\Pipeline
:167
28
Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse
:37
27
Illuminate\Pipeline\Pipeline
:167
26
Illuminate\Cookie\Middleware\EncryptCookies
:67
25
Illuminate\Pipeline\Pipeline
:167
24
Illuminate\Pipeline\Pipeline
:103
23
Illuminate\Routing\Router
:697
22
Illuminate\Routing\Router
:672
21
Illuminate\Routing\Router
:636
20
Illuminate\Routing\Router
:625
19
Illuminate\Foundation\Http\Kernel
:167
18
Illuminate\Pipeline\Pipeline
:128
17
Illuminate\Http\Middleware\TrustProxies
:39
16
Illuminate\Pipeline\Pipeline
:167
15
Illuminate\Foundation\Http\Middleware\TransformsRequest
:21
14
Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull
:31
13
Illuminate\Pipeline\Pipeline
:167
12
Illuminate\Foundation\Http\Middleware\TransformsRequest
:21
11
Illuminate\Foundation\Http\Middleware\TrimStrings
:40
10
Illuminate\Pipeline\Pipeline
:167
9
Illuminate\Foundation\Http\Middleware\ValidatePostSize
:27
8
Illuminate\Pipeline\Pipeline
:167
7
Illuminate\Foundation\Http\Middleware\PreventRequestsDuringMaintenance
:86
6
Illuminate\Pipeline\Pipeline
:167
5
Illuminate\Pipeline\Pipeline
:103
4
Illuminate\Foundation\Http\Kernel
:142
3
Illuminate\Foundation\Http\Kernel
:111
2
:52
1
:21
Symfony\Component\HttpFoundation\InputBag::get
D:\xampp\htdocs\laravelprojects\burgerStation\vendor\symfony\http-foundation\InputBag.php:30
/**
InputBag is a container for user input values such as $_GET, $_POST, $_REQUEST, and $_COOKIE.
#author Saif Eddin Gmati azjezz#protonmail.com
*/
final class InputBag extends ParameterBag
{
/**
* Returns a scalar input value by name.
*
* #param string|int|float|bool|null $default The default value if the input key does not exist
*
* #return string|int|float|bool|null
*/
public function get(string $key, $default = null)
{
if (null !== $default && !is_scalar($default) && !(\is_object($default) && method_exists($default, '__toString'))) {
trigger_deprecation('symfony/http-foundation', '5.1', 'Passing a non-scalar value as 2nd argument to "%s()" is deprecated, pass a scalar or null instead.', __METHOD__);
}
I guess you can make sure if the $key is not null either:
public function get(string $key = null, $default = null)
{
if ($key !== null && null !== $default ...

diff two files ignoring some parts of the lines

Let's say I have two files produced from javap -v.
output will look something like this:
[...]
299: astore 15
301: aload 15
303: aload 18
305: if_acmpeq 367
308: aload 15
310: arraylength
311: istore 17
313: iload 17
315: ifeq 348
318: aload 15
320: iconst_2
321: laload
322: lstore 19
324: aload_1
325: getfield #49 // Field my/somewhere/Some.thing:J
328: lstore 21
330: lload 19
332: lload 21
334: land
335: lstore 19
[...]
If I diff this with another file, most of the linenumbers will have changed and show up as a "difference".
I COULD write a sript that removes them, but I still need them to see where my code is jumping to.
Similarly, that field / Field my/somewhere/Some.thing:J happens to have #49 is completely irrelevant.
At the same time, a changed register is relevant.
So is there a tool (preferably with a GUI, of course, as the files are quite large and context is helpful in figuring out what is going on) to diff two files while ignoring parts of the line without removing said parts?
The line number, at least. Could be as simple as "ignore everything up to the first :.
Ideally, of course, it would allow me to set more sophisticated exclusion checks, like "ignore integers if they are marked with an # or follow a word on the same line that is prefixed with either if, jsr or goto. But I don't expect there to be something as convenient.
UPDATE
Using asmtools jdis as suggested by #user882813 will result in an output like
astore 6;
aload 6;
aload 8;
if_acmpeq L795;
aload 6;
arraylength;
istore 7;
iload 7;
ifeq L781;
aload 6;
iload 4;
laload;
lstore 9;
aload_1;
getfield Field my/somehwere/Some.thing:"J";
lstore 11;
lload 9;
lload 11;
land;
lstore 9;
...
L795: stack_frame_type full;
locals_map ...
Which is a LOT better for diffing than the javap -v output.
(And personally, I quite like the inlined locals_map and stack_map.)
Still, the jump targets / labels (e.g. L795) all show up as false positives.
Additionally, the same now goes for try-catch block labels (e.g. t6).
try t6;
aload 4;
getfield Field Something.f:"Lparc/lang/Foo;";
checkcast class SpecialFoo;
endtry t6;
goto L495;
catch t6 java/lang/ClassCastException;
stack_frame_type full;
locals_map class Something, class parc/some/Thing, bogus, int, class Something$1, class SpecialFoo, class "[J", bogus, class "[J", bogus, bogus, bogus, bogus, null, null;
stack_map class java/lang/ClassCastException;
new class java/lang/Error;
dup;
ldc String "not SpecialFoo";
invokespecial Method java/lang/Error."<init>":"(Ljava/lang/String;)V";
athrow;
L495: stack_frame_type stack1;
stack_map class SpecialFoo;
nop;
So it would still be convenient if the tool could be configured to ignore the t<integer> and L<integer> parts of the lines.
Try to use asmtools jdis instead of javap.
asmtools jdis has more clean output.
For example, for simple HelloWorld application
class Hello {
public static void main(String... args) {
System.out.println("Hello, world!");
}
}
asmtools jdis output will be:
super class Hello
version 52:0
{
Method "<init>":"()V"
stack 1 locals 1
{
aload_0;
invokespecial Method java/lang/Object."<init>":"()V";
return;
}
public static varargs Method main:"([Ljava/lang/String;)V"
stack 2 locals 1
{
getstatic Field java/lang/System.out:"Ljava/io/PrintStream;";
ldc String "Hello, world!";
invokevirtual Method java/io/PrintStream.println:"(Ljava/lang/String;)V";
return;
}
} // end Class Hello
JFYI, numbers in the front of instructions is not line numbers but bytecode instruction offsets.

Getting a number of context switches for a process / thread

Out of curiosity I want to know how many times my program was context switched by the OS. Like all the registers were saved and the control was passed to another process or thread, and then after some time everything was restored and we continue as it never happened.
Does the system maintain such a number somewhere or is there a sort of hack or whatever?
I am on Linux in particular but I am interested about other systems as well.
Well, let's examine the case. Linux type O/S keeps these details systematically and one may use a comfort of Python, for both inspecting the state and also for easy design of a monitoring system, that can report any excessive circumstances ( the former quite matching a just out of curiosity cases, the latter quite handy for any re-work / re-use for systematic work ) :
A "Monitor" example for both { voluntary | involuntary }-Ctx Switching :
Python here serves for both the educational role and for the ease and comfort of further extending the scope of functionalities:
Having assigned signal.signal( signal.SIGALRM, SIG_ALRM_handler_A ) and the timing, the system gets ready to report both voluntary and involuntary ( enforced ) Context-Switches, for which a "FAT"-blocking piece of computing was used, that resorts, due to historical reasons to non-GIL Numpy/C/FORTRAN code and thus gets disturbed by just involuntary-CtxSwitched cases, as was shown below:
len(str([np.math.factorial(2**f) for f in range(20)][-1]))
but by using a principally any other PID-number, this trivial monitoring mechanics can serve for whatever other purposes:
########################################################################
### SIGALRM_handler_
###
import psutil, resource, os, time
SIG_ALRM_last_ctx_switch_VOLUNTARY = -1
SIG_ALRM_last_ctx_switch_FORCED = -1
def SIG_ALRM_handler_A( aSigNUM, aFrame ): # SIG_ALRM fired evenly even during [ np.math.factorial( 2**f ) for f in range( 20 ) ] C-based processing =======================================
# onEntry_ROTATE_SigHandlers() -- MAY set another sub-sampled SIG_ALRM_handler_B() ... { last: 0, 0: handler_A, 1: handler_B, 2: handler_C }
#
# onEntry_SEQ of calls of regular, hierarchically timed MONITORS ( just the SNAPSHOT-DATA ACQUISITION Code-SPRINTs, handle later due to possible TimeDOMAIN overlaps )
#
#
# print( time.ctime() )
# print( formatExtMemoryUsed( getExtMemoryUsed() ) )
# print( 60 * "=", psutil.Process( os.getpid() ).num_ctx_switches(), "~~~", aProcess.cpu_percent( interval = 0 ) )
# ??? # WHY CPU 0.0%
aProcess = psutil.Process( os.getpid() )
aProcessCpuPCT = aProcess.cpu_percent( interval = 0 ) # EVENLY-TIME-STEPPED
aCtxSwitchNUMs = aProcess.num_ctx_switches() # THIS PROCESS ( may inspect other per-incident later ... on anomaly )
aVolCtxSwitchCNT = aCtxSwitchNUMs.voluntary
aForcedSwitchCNT = aCtxSwitchNUMs.involuntary
global SIG_ALRM_last_ctx_switch_VOLUNTARY
global SIG_ALRM_last_ctx_switch_FORCED
if ( SIG_ALRM_last_ctx_switch_VOLUNTARY != -1 ): # .INIT VALUE STILL UNCHANGED
#----------
# .ON_TICK: must process delta(s)
if ( SIG_ALRM_last_ctx_switch_VOLUNTARY == aVolCtxSwitchCNT ):
#
# AN INDIRECT INDICATION OF A LONG-RUNNING WORKLOAD OUTSIDE GIL-STEPPING ( regex / C-lib / FORTRAN / numpy-block et al )
# ||||| vvv
# SIG_: Wed Oct 19 12:24:32 2016 ------------------------------ pctxsw(voluntary=48714, involuntary=315) ~~~ 0.0
# SIG_: Wed Oct 19 12:24:37 2016 ------------------------------ pctxsw(voluntary=48714, involuntary=323) ~~~ 0.0
# SIG_: Wed Oct 19 12:24:42 2016 ------------------------------ pctxsw(voluntary=48714, involuntary=331) ~~~ 0.0
# SIG_: Wed Oct 19 12:24:47 2016 ------------------------------ pctxsw(voluntary=48714, involuntary=338) ~~~ 0.0
# SIG_: Wed Oct 19 12:24:52 2016 ------------------------------ pctxsw(voluntary=48714, involuntary=346) ~~~ 0.0
# SIG_: Wed Oct 19 12:24:57 2016 ------------------------------ pctxsw(voluntary=48714, involuntary=353) ~~~ 0.0
# ... ||||| ^^^
# 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000]
# >>> ||||| |||
# vvvvv |||
# SIG_: Wed Oct 19 12:26:17 2016 ------------------------------ pctxsw(voluntary=49983, involuntary=502) ~~~ 0.0
# SIG_: Wed Oct 19 12:26:22 2016 ------------------------------ pctxsw(voluntary=49984, involuntary=502) ~~~ 0.0
# SIG_: Wed Oct 19 12:26:27 2016 ------------------------------ pctxsw(voluntary=49985, involuntary=502) ~~~ 0.0
# SIG_: Wed Oct 19 12:26:32 2016 ------------------------------ pctxsw(voluntary=49986, involuntary=502) ~~~ 0.0
# SIG_: Wed Oct 19 12:26:37 2016 ------------------------------ pctxsw(voluntary=49987, involuntary=502) ~~~ 0.0
# SIG_: Wed Oct 19 12:26:42 2016 ------------------------------ pctxsw(voluntary=49988, involuntary=502) ~~~ 0.0
#rint( "SIG_ALRM_handler_A(): A SUSPECT CPU-LOAD:: ", time.ctime(), 10 * "-", aProcess.num_ctx_switches(), "{0: > 8.2f} CPU_CORE_LOAD [%]".format( aProcessCpuPCT ), " INSPECT processes ... ev. add a Stateful-self-Introspection" )
print( "SIG_ALRM_handler_A(): A SUSPECT CPU-LOAD:: ", time.ctime(), 10 * "-", aProcess.num_ctx_switches(), "{0:_>60s}".format( str( aProcess.threads() ) ), " INSPECT processes ... ev. add a Stateful-self-Introspection" )
#rint( "SIG_ALRM_handler_A(): A SUSPECT CPU-LOAD:: ", str( resource.getrusage( resource.RUSAGE_SELF ) )[22:] )
else:
#----------
# .ON_INIT: may report .INIT()
#rint( "SIG_ALRM_handler_A(): A SUSPECT CPU-LOAD:: ", time.ctime(), ...
print( "SIG_ALRM_handler_A(): activated ", time.ctime(), 30 * "-", aProcess.num_ctx_switches() )
##########
# FINALLY:
SIG_ALRM_last_ctx_switch_VOLUNTARY = aVolCtxSwitchCNT # .STO ACTUALs
SIG_ALRM_last_ctx_switch_FORCED = aForcedSwitchCNT # .STO ACTUALs
#rint( "SIG_: ", time.ctime(), 30 * "-", aProcess.num_ctx_switches(), " ~~~ ", aProcess.cpu_percent( interval = 0 ), " % -?- ", aProcess.threads() )
#____________________________________________________________________
# SIG_ALRM_handler_A( aSigNUM, aFrame ): DEFINED
#####################################################################
##########
# FINALLY:
#
# > signal.signal( signal.SIGALRM, SIG_ALRM_handler_A ) # .ASSOC { SIGALRM: thisHandler }
# > signal.setitimer( signal.ITIMER_REAL, 10, 5 ) # .SET #5 [sec] interval, after first run, starting after 10[sec] initial-delay
# > signal.setitimer( signal.ITIMER_REAL, 0, 5 ) # .UNSET
# > SIG_ALRM_last_ctx_switch_VOLUNTARY = -1 # .RESET .INIT() the global { signalling | state }-variable
# > len(str([np.math.factorial(2**f) for f in range(20)][-1])) # .RUN A "FAT"-BLOCKING CHUNK OF A regex/numpy/C/FORTRAN-calculus
Also the Thread-level CtxSwitch details
While this was not elaborated to a similar depth, the same as above applies to:
>>> psutil.Process( 18263 ).cpu_percent() 0.0
>>> psutil.Process( 18263 ).ppid() 18054
>>> psutil.Process( 18054 ).cpu_percent() 0.0
=== ( 18054 ).threads(): [ 17679, 17680, 17681, 18054, 18265, 18266, 18267, ]
==4 -------------vvv-------------------=4--------------vvvv-------------------=4--------------vvv
>>> [ psutil.Process( p ).num_ctx_switches() for p in ( 18259, 18260, 18261 ) ] [pctxsw(voluntary=4, involuntary=267), pctxsw(voluntary=4, involuntary=1909), pctxsw(voluntary=4, involuntary=444)]
>>> [ psutil.Process( p ).num_ctx_switches() for p in ( 18259, 18260, 18261 ) ] [pctxsw(voluntary=4, involuntary=273), pctxsw(voluntary=4, involuntary=1915), pctxsw(voluntary=4, involuntary=445)]
>>> [ psutil.Process( p ).num_ctx_switches() for p in ( 18259, 18260, 18261 ) ] [pctxsw(voluntary=4, involuntary=275), pctxsw(voluntary=4, involuntary=1917), pctxsw(voluntary=4, involuntary=445)]

Extract detailed symbol information (struct members) from elf file compiled with ARM-GCC

I’m using ARM-GCC 4.7.4 to compile Code for a Cortex-M4. For our Debug tool I need knowledge about names, types and addresses of all variables in human readable format (e.g. .txt). The map file provides most of the information, unfortunately not for structure contents like below:
typedef struct { float32_t Ref; // Input: Reference Value
float32_t Fdb; // Variable: Feedback Value
float32_t Err; // Input: Control Error
float32_t Kp; // Parameter: Gain of the Proportional Part
float32_t Up; // Output: Output of Proportional Part
float32_t Ki; // Parameter: Gain of the Integral Part
float32_t Ui; // Output: Output of the Integral Part
float32_t OutPreSat; // Output: Not saturated Output
float32_t OutMax; // Parameter: Maximum Output
float32_t OutMin; // Parameter: Minimum Output
float32_t Out; // Output: Saturated Output
} PI_REG;
PI_REG BU_Uctrl_Udc_PI_Reg = BU_UCTRL_UDC_PI_REG_INIT;
Therefore I tried the tools nm, readelf and objdump to get something out of the .elf file which is compiled with parameter –g3 in dwarf-2 format. Only with objdump I could find the information I searched for:
objdump –Wi myfile.elf >symbols.txt
The following information about the typedef PI_REG can be found in symbols.txt file:
<1><38883>: Abbrev Number: 2 (DW_TAG_base_type)
<38884> DW_AT_byte_size : 4
<38885> DW_AT_encoding : 4 (float)
<38886> DW_AT_name : (indirect string, offset: 0x2c63e): float
<1><38891>: Abbrev Number: 11 (DW_TAG_typedef)
<38892> DW_AT_name : (indirect string, offset: 0xb336d): float32_t
<38896> DW_AT_decl_file : 4
<38897> DW_AT_decl_line : 370
<38899> DW_AT_type : <0x38883>
<1><390d7>: Abbrev Number: 14 (DW_TAG_structure_type)
<390d8> DW_AT_byte_size : 44
<390d9> DW_AT_decl_file : 6
<390da> DW_AT_decl_line : 26
<390db> DW_AT_sibling : <0x39176>
<2><390df>: Abbrev Number: 16 (DW_TAG_member)
<390e0> DW_AT_name : Ref
<390e4> DW_AT_decl_file : 6
<390e5> DW_AT_decl_line : 26
<390e6> DW_AT_type : <0x38891>
<390ea> DW_AT_data_member_location: 2 byte block: 23 0 (DW_OP_plus_uconst: 0)
<2><390ed>: Abbrev Number: 16 (DW_TAG_member)
<390ee> DW_AT_name : Fdb
<390f2> DW_AT_decl_file : 6
<390f3> DW_AT_decl_line : 27
<390f4> DW_AT_type : <0x38891>
<390f8> DW_AT_data_member_location: 2 byte block: 23 4 (DW_OP_plus_uconst: 4)
[left out structure members with offsets 6-32]
<2><39159>: Abbrev Number: 15 (DW_TAG_member)
<3915a> DW_AT_name : (indirect string, offset: 0xc1d9a): OutMin
<3915e> DW_AT_decl_file : 6
<3915f> DW_AT_decl_line : 35
<39160> DW_AT_type : <0x38891>
<39164> DW_AT_data_member_location: 2 byte block: 23 24 (DW_OP_plus_uconst: 36)
<2><39167>: Abbrev Number: 16 (DW_TAG_member)
<39168> DW_AT_name : Out
<3916c> DW_AT_decl_file : 6
<3916d> DW_AT_decl_line : 36
<3916e> DW_AT_type : <0x38891>
<39172> DW_AT_data_member_location: 2 byte block: 23 28 (DW_OP_plus_uconst: 40)
<1><39176>: Abbrev Number: 3 (DW_TAG_typedef)
<39177> DW_AT_name : (indirect string, offset: 0xc00d0): PI_REG
<3917b> DW_AT_decl_file : 6
<3917c> DW_AT_decl_line : 37
<3917d> DW_AT_type : <0x390d7>
<1><3c348>: Abbrev Number: 29 (DW_TAG_variable)
<3c349> DW_AT_name : (indirect string, offset: 0xc3ece): BU_Uctrl_Udc_PI_Reg
<3c34d> DW_AT_decl_file : 1
<3c34e> DW_AT_decl_line : 40
<3c34f> DW_AT_type : <0x39176>
<3c353> DW_AT_external : 1
<3c354> DW_AT_location : 5 byte block: 3 fc 67 0 20 (DW_OP_addr: 200067fc)
If I want to get information about variables, e.g. the structure BU_Uctrl_Udc_PI_Reg, I have to do the following:
Find an entry called “DW_TAG_variable” and gather following information:
------------------------------------------------------------------------
- DW_AT_name: The name is BU_Uctrl_Udc_PI_Reg
- DW_OP_addr: Base address is 200067fc
- DW_AT_type: The data type can be found at line 39176
Search line 39176 and gather following information:
-----------------------------------------------------
- It is a typedef (DW_TAG_typedef)
- DW_AT_name: The typedef name is PI_REG
- DW_AT_type: The definition can be found at line 390d7
Search line 390d7 and gather following information:
---------------------------------------------------
- It is a structure (DW_TAG_structure_type)
- DW_AT_byte_size: It is 44 bytes wide
Search the structure Members in upcoming lines until 44 bytes are reached:
--------------------------------------------------------
1. Member (DW_TAG_member):
- DW_AT_name: Ref
- DW_AT_data_member_location: 200067fc + 0
- DW_AT_type: The data type can be found at line 38891:
- DW_TAG_typedef: float32_t
- DW_AT_type: The data type can be found at line 38883:
- DW_TAG_base_type: float
- DW_AT_byte_size: 4 bytes
2. Member (DW_TAG_member):
- DW_AT_name: Fdb
- DW_AT_data_member_location: 200067fc + 4
- DW_AT_type: The data type can be found at line 38891:
- DW_TAG_typedef: float32_t
- DW_AT_type: The data type can be found at line 38883:
- DW_TAG_base_type: float
- DW_AT_byte_size: 4 bytes
[left out Members 3-9]
10. Member (DW_TAG_member):
- DW_AT_name: OutMin
- DW_AT_data_member_location: 200067fc + 36
- DW_AT_type: The data type can be found at line 38891:
- DW_TAG_typedef: float32_t
- DW_AT_type: The data type can be found at line 38883:
- DW_TAG_base_type: float
- DW_AT_byte_size: 4 bytes
11. Member (DW_TAG_member):
- DW_AT_name: Out
- DW_AT_data_member_location: 200067fc + 40
- DW_AT_type: The data type can be found at line 38891:
- DW_TAG_typedef: float32_t
- DW_AT_type: The data type can be found at line 38883:
- DW_TAG_base_type: float
- DW_AT_byte_size: 4 bytes
Frankly speaking, a script file, which automatically gathers the information as above mentioned, would be more complex than my application. Additionally I have to admit that I not really know how I could write such a script. Is there a more easy way to get this type of information? Is there maybe some parameter for the objdump which would help me with that, although I think I tried all the relevant ones? Or does a tool exist which is able to do this? In the end I need a table like this (additionally it would be nice to have all the enums which of course can also be found within the .elf file):
0x200067fc float BU_Uctrl_Udc_PI_Reg.Ref
0x20006800 float BU_Uctrl_Udc_PI_Reg.Fdb
[…]
0x20006832 float BU_Uctrl_Udc_PI_Reg.OutMin
0x20006836 float BU_Uctrl_Udc_PI_Reg.Out
The tool Fromelf http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dui0477c/index.html (included in Keil µVision) with the parameter --text exactly delivers such a table, but unfortunately I can’t use this because it supposedly needs the .elf or in this case called .axf files compiled with Arm Compiler Toolchain to work. Additionally there are license issues.
Thanks for any hints.
is pahole what you need? it can dump variable structure with size and offset.
pahole −−reorganize −C foo xxx.out
struct foo {
int a; / 0 4 /
char c[4]; / 4 4 /
void b; / 8 8 /
long g; / 16 8 /
}; / size: 24, cachelines: 1 /
/ last cacheline: 24 bytes /
/ saved 8 bytes! /
You should be able to ask GDB to print this info for you, e.g.
gdb -q a.out
(gdb) ptype PI_REG
You can use eclipse CDT's gdb mi interface to programatically get this information.
private def loadElfFile(String elfFilePath) {
var plugin = new MIPlugin
var file = new File(elfFilePath)
var cmdFactory = new CommandFactory("mi2")
session = plugin.createSession(
MISession::PROGRAM,
'gdb',
cmdFactory,
file,
#[],
true,
new NullProgressMonitor
)
}
There you can query global variables and their types. Addresses are stored in the hexAddress property of values.
The problem with this approach is its slowness. A struct with 50 members takes almost 10 seconds to process. Querying all structs would take minutes. For IDE tool use cases (like a model transformation) this is impractical. You have to deep dive to elf and dwarf.

does the use of meta model can cause memory leak in hibernate code?

Analyzing heap dump of tomcat app that based hibernate 4.3.1.final + `Spring 4'
shows that there is a leak on
org.hibernate.internal.SessionFactoryImpl it seems related to with MetaModel (maybe meta model with #embeddedId)
Does any one have experience that ?
Thanks ,
Alon
some info from dump :
Class Name | Shallow Heap| Retained Heap
org.hibernate.internal.SessionFactoryImpl # 0x7839de890
136 8,109,256
\factory org.hibernate.type.TypeFactory$TypeScopeImpl # 0x7839de880
16 16
.\typeScope org.hibernate.type.ComponentType # 0x783d8c760
56 616
..\hibernateType org.hibernate.jpa.internal.metamodel.EmbeddableTypeImpl # 0x783d8c3f8
48 1,216
...\attributeType org.hibernate.jpa.internal.metamodel.SingularAttributeImpl$Identifier # 0x783d8c338
40 40
....\id class org.jpp.domain.security.ProjectPermission_ # 0x784134cf8
8 8
.....\[3985] java.lang.Object[10240] # 0x784ecd118
40,976 1,087,264
......\elementData java.util.Vector # 0x7832e2680
32 1,087,296
.......\classes org.apache.catalina.loader.WebappClassLoader # 0x7832c76c0
184 1,454,824
........+<classloader> class com.mysql.jdbc.AbandonedConnectionCleanupThread # 0x783bbda40

Resources