- A hozzászóláshoz be kell jelentkezni
- 2835 megtekintés
Hozzászólások
Ezek a franciák nagyon tudnak néha. :-)
- A hozzászóláshoz be kell jelentkezni
hm... jól jött volna, amikor c-ben programoztam még.
- A hozzászóláshoz be kell jelentkezni
Ma eppen azon gonsolkoztam, hogy alignolasi hibakat(lassu) kereso cuccot kene osszedobni.
Vajon ezzel lehet -e ? Ha nem, valoszinuleg ennek a bovitesevel erhetnek celt a leghamarabb.
- A hozzászóláshoz be kell jelentkezni
alignolasi hibakat
Ez alatt konkrétan mit értesz?
- A hozzászóláshoz be kell jelentkezni
fizikus baratunk tort magyarsaggal szokott szakszavakat dobalni, odase neki:)
*peace :)*
- A hozzászóláshoz be kell jelentkezni
pl. struct-uraknal erdemes lehet figyelni.
(Valoszinuleg a C++ oroklodes is hozhat ilyen hibat.)
Nehany architekturan ennek sulyosabb kovetkezmenye is lehetnek, (nem letilthato) kivetel keletkezik, amit kezelni kell.
- A hozzászóláshoz be kell jelentkezni
Mintha a struktúrákban a tagok igazítását a fordító végezné. Ráadásul különböző optimalizálási beállítások mellett különbözően.
- A hozzászóláshoz be kell jelentkezni
Nezegettem, Valoban figyel ra. Sorrendet nem valtoztatja, a meretben kaphatsz bunteteest. (align error nem lesz, de cache missek szaporaodhatnak miatta)
Igy eshet, meg, hogy 3*8+4*1=56 (28 (32)) vagy 2*1+1*8=24 (10 (16))
- A hozzászóláshoz be kell jelentkezni
Nyilván. És vannak esetek, amikor pontosan meg kell mondanod, hogy mi milyen sorrendben van, és milyen méretű, akkor is ha nem hatékony, mert például a másik oldal olyan formában várja az adatokat.
De általában elmondható, hogy a forráskód-elemző nem tudja megmondani, hogy mi milyen igazítású lesz, az fordításkor dől el, fordítóprogram-, és fordító-paraméterezés függő.
- A hozzászóláshoz be kell jelentkezni
Sorrend valtoztatast nem tesz a fordito szerintem. (Melyik opcio tenne ilyet ?)
sizeof-okat csak tud nekem mondani ez a cucc, az alapjan mar tudhatom mikor foglal tobbet a kelletenel.
Egybkent a zarojelekbe azt irtam, hogy mennyi a hasznos adat, ill. hogy menyi lenne jobb sorrendben a merete.
- A hozzászóláshoz be kell jelentkezni
Nem mondhat siezof-ot, hiszen az már a fordítótól (is) függ.
KisKresz
- A hozzászóláshoz be kell jelentkezni
Modern forditoknal, 64 ill 32 bites rendszerk kozott van kulombseg, de
sizeof(int)<=sizeof long = sizeof (void*)<=sizeof(long long)
Legtobb esetben eleg tudnom <= ket ahogy szabvanyban is vannak definialva, es monoton csokenest figyelnem.
Es valami veletlen folytan, mai (32,64 bites) forditoknal nincs elteres. (long double kakuk tojas lehet (non x86-on), de ez egyebkent is (ultra) ritka)
Szerinted milyen elemzonek kene hivni azt ami mondhat sizeof -ot ?
- A hozzászóláshoz be kell jelentkezni
Az már platform- és compilerfüggő, szóval valami specifikusabb, mint egy "szimpla" forráselemző. Nem tudom, minek kéne hívni.
KisKresz
- A hozzászóláshoz be kell jelentkezni
Nyilván nem tudhatja sem a fordító, sem a forráskód elemző, hogy éppen a .WAV header-t értelmezem rosszul a rossz alignolás miatt.
- A hozzászóláshoz be kell jelentkezni
Az "align" magyar szó ragozása. align -> alignol -> alignolás
Jelentése angolul: alignment
- A hozzászóláshoz be kell jelentkezni
Alig hinném, hogy ezt forráskód-elemzéssel lehet kezelni.
KisKresz
- A hozzászóláshoz be kell jelentkezni
Alig hinném, hogy ezt ...
Mármint "align hinnéd", ugye?
- A hozzászóláshoz be kell jelentkezni
"Frama-C is a suite of tools dedicated to the analysis of the source code of software written in C."
forráskód elemző
András
- A hozzászóláshoz be kell jelentkezni
Szinten francia alkotas az ASTREE nevu statikus elemzo is, amelyet az Airbus A3** gepekhez, sot az ESA is ezt hasznalja.
- A hozzászóláshoz be kell jelentkezni
Az alábbi levelet kaptam az imént:
Hello,
you seem to have initiated a discussion thread on http://hup.hu
where Frama-C was mentioned. We are not comfortable
posting this message to the forum, especially since automatic
translation do not make it easy for us to understand everything
that is said there, but if the text below seems to you
to be relevant to the discussion, please feel free to transmit it
to the forum.Best regards,
Pascal Cuoq and the Frama-C development team
Dear HUP users,
The Frama-C development team has been guilty of a little bit of
kibozing ( http://en.wiktionary.org/wiki/kiboze ) and came across this
discussion thread. Although the development team does not have much in
terms of resources for reading it in its original language, it appears
that one of the topic discussed is that of the verification of
alignement of data.
This question has been asked before in the context of the CAT project
in which Frama-C's development was started. The short answer is "yes,
Frama-C may be able to verify that some addresses are always aligned
on a n-bytes boundary, if the compiler's choices for the layout of
data in memory follow some usual conventions". For instance, the
address of field i+1 in a struct should be determined by the compiler
computed by taking the address of field i, adding the size of field i
and rounding the result up to the required alignment for the
type of field i+1.
The involved parameters, such as types sizes and alignements, can be
autodetected by compiling a special program on the target platform.
Note that the requirement that the compiler has to allow
separate compilation and conform to the platform ABI is likely to
make these hypotheses reasonnable.
Frama-C is only able at this point to verify that an address is
aligned on a n-bytes boundary when this property results from both the
base address being aligned on a n-bytes boundary and the offset being
a multiple of n. For instance, it is able to conclude in this
example, because the base address of p+12 is an int array, and
therefore 4-bytes aligned:
int t[10];
char *p;
p = (char *) t;
* (int*) (p+12) = 42; /* p + 12 should really be aligned
on a 4-bytes boundary */
It definitely will be unable to conclude in the example below, because
the alignement property results from choosing an offset that compensates
the possible misalignement of the base address, and this kind of relation
between the alignment of the base address and the computed offset can
not be represented in the memory model used by Frama-C's value analysis.
char t[80];
char *p;
p = (t + 7) & ~7;
* (int*) p = 42; /* p absolutely needs to be aligned
on a 4-bytes boundary */
Please find below a more complete example. In this example,
one would like to check that the pointer passed to function f
is always 4-bytes aligned.
____________________________________________
#ifdef USING_FRAMA_C_FOR_VERIFICATION
#include ".../share/builtin.h"
int Frama_C_is_base_aligned(void *, int);
/* this should be in .../share/builtin.h but it is not as of version 20080502 */
void check_alignment(void *p, int n)
{
int good_alignment = Frama_C_is_base_aligned(p, n) && Frama_C_offset(p) % n == 0;
if (!good_alignment) Frama_C_show_each_alignment_warning(p,n);
}
#define CHECK_ALIGNMENT(P, N) check_alignment(P, N);
#else
#define CHECK_ALIGNMENT(P, N)
#endif
int t[12];
char c[14];
struct S { int a; char b; } s[5];
int o1, o2, o3;
int r1, r2, r3;
int b1, b2, b3;
struct S2 { int a; char b[10]; int c;} s2;
int os2a, os2b, os2c;
int o;
void f (char * p){
CHECK_ALIGNMENT (p, 4)
*(int*)p = 42;
}
void main(void)
{
int i;
#ifdef USING_FRAMA_C_FOR_VERIFICATION
i = Frama_C_interval(0, 10);
#else
i = 5;
#endif
o1 = Frama_C_offset(&t[i]);
r1 = o1 % 4 == 0;
b1 = Frama_C_is_base_aligned(&t[i], 4);
f(&t[i]);
f(c + 3);
o2 = Frama_C_offset(&c[i]);
r2 = o2 % 4 == 0;
b2 = Frama_C_is_base_aligned(&c[i], 4);
o3 = Frama_C_offset(&s[i].a);
r3 = o3 % 4 == 0;
b3 = Frama_C_is_base_aligned(&s[i].a, 4);
f(&s[i].a);
os2a = Frama_C_offset(&s2.a);
os2b = Frama_C_offset(&s2.b);
f(&s2.b);
os2c = Frama_C_offset(&s2.c);
f(&s2.c);
}
_______________________
Use the command line (please replace ... by Frama-C's installation
path everywhere):
.../bin/viewer.opt -val .../share/builtin.c alignement_args_fonctions.c -cpp-command "gcc -C -E -I. -D USING_FRAMA_C_FOR_VERIFICATION"
You should be able to observe the values of variables o1, r1, b1, ...
and see if they correspond to your expectations. Besides, please
note the following lines in the analysis log:
[values] computing for function f <-main
[values] called from alignement_args_fonctions.c:66
[values] computing for function check_alignment <-f <-main
[values] called from alignement_args_fonctions.c:45
Argument of Frama_C_show_each_alignment_warning: {{ &c + {3; } ;}}
Argument of Frama_C_show_each_alignment_warning: {4; }
This part of the log mean that the analyzer is not able to guarantee
that the parameter for f is aligned when it is called from
line 66 in the example (the resolved address that poses a
problem, {{ &c + {3; } ;}}, is also printed, in case that helps
to track down the problem and attribute it to either a bug
in the source or a lack of precision in the analyzer).
Frama-C has been designed to be "correct", which means that there are
no problems in the program when it does not display any warnings.
This distinguishes it from other static analyzers which prefer to
display a warning only when they are quite sure that they have found
an actual problem, so as not to flood the user with too many warnings.
Frama-C typically display more false alarms than these (it displays a
warning as soon as it is not able to conclude that there is no
problem), but on the other hand, it also means that it can be used to
guarantee that there are no problems in a program, if you are so
inclined (it needs to be used properly, and some hypotheses have to
apply. Please see the documentation for more information. Oh, and it
still requires a lot of work).
--
trey @ gépház
- A hozzászóláshoz be kell jelentkezni