2
0

strace.c 110 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005
  1. #include "qemu/osdep.h"
  2. #include <sys/ipc.h>
  3. #include <sys/msg.h>
  4. #include <sys/sem.h>
  5. #include <sys/shm.h>
  6. #include <sys/select.h>
  7. #include <sys/mount.h>
  8. #include <arpa/inet.h>
  9. #include <netinet/in.h>
  10. #include <netinet/tcp.h>
  11. #include <netinet/udp.h>
  12. #include <linux/if_packet.h>
  13. #include <linux/in6.h>
  14. #include <linux/netlink.h>
  15. #include <sched.h>
  16. #include "qemu.h"
  17. #include "user-internals.h"
  18. #include "strace.h"
  19. #include "signal-common.h"
  20. #include "target_mman.h"
  21. struct syscallname {
  22. int nr;
  23. const char *name;
  24. const char *format;
  25. void (*call)(CPUArchState *, const struct syscallname *,
  26. abi_long, abi_long, abi_long,
  27. abi_long, abi_long, abi_long);
  28. void (*result)(CPUArchState *, const struct syscallname *, abi_long,
  29. abi_long, abi_long, abi_long,
  30. abi_long, abi_long, abi_long);
  31. };
  32. /*
  33. * It is possible that target doesn't have syscall that uses
  34. * following flags but we don't want the compiler to warn
  35. * us about them being unused. Same applies to utility print
  36. * functions. It is ok to keep them while not used.
  37. */
  38. #define UNUSED __attribute__ ((unused))
  39. /*
  40. * Structure used to translate flag values into strings. This is
  41. * similar that is in the actual strace tool.
  42. */
  43. struct flags {
  44. abi_long f_value; /* flag */
  45. const char *f_string; /* stringified flag */
  46. };
  47. /* common flags for all architectures */
  48. #define FLAG_GENERIC(name) { name, #name }
  49. /* target specific flags (syscall_defs.h has TARGET_<flag>) */
  50. #define FLAG_TARGET(name) { TARGET_ ## name, #name }
  51. /* end of flags array */
  52. #define FLAG_END { 0, NULL }
  53. /* Structure used to translate enumerated values into strings */
  54. struct enums {
  55. abi_long e_value; /* enum value */
  56. const char *e_string; /* stringified enum */
  57. };
  58. /* common enums for all architectures */
  59. #define ENUM_GENERIC(name) { name, #name }
  60. /* target specific enums */
  61. #define ENUM_TARGET(name) { TARGET_ ## name, #name }
  62. /* end of enums array */
  63. #define ENUM_END { 0, NULL }
  64. UNUSED static const char *get_comma(int);
  65. UNUSED static void print_pointer(abi_long, int);
  66. UNUSED static void print_flags(const struct flags *, abi_long, int);
  67. UNUSED static void print_enums(const struct enums *, abi_long, int);
  68. UNUSED static void print_at_dirfd(abi_long, int);
  69. UNUSED static void print_file_mode(abi_long, int);
  70. UNUSED static void print_open_flags(abi_long, int);
  71. UNUSED static void print_syscall_prologue(const struct syscallname *);
  72. UNUSED static void print_syscall_epilogue(const struct syscallname *);
  73. UNUSED static void print_string(abi_long, int);
  74. UNUSED static void print_buf(abi_long addr, abi_long len, int last);
  75. UNUSED static void print_raw_param(const char *, abi_long, int);
  76. UNUSED static void print_timeval(abi_ulong, int);
  77. UNUSED static void print_timespec(abi_ulong, int);
  78. UNUSED static void print_timespec64(abi_ulong, int);
  79. UNUSED static void print_timezone(abi_ulong, int);
  80. UNUSED static void print_itimerval(abi_ulong, int);
  81. UNUSED static void print_number(abi_long, int);
  82. UNUSED static void print_signal(abi_ulong, int);
  83. UNUSED static void print_sockaddr(abi_ulong, abi_long, int);
  84. UNUSED static void print_socket_domain(int domain);
  85. UNUSED static void print_socket_type(int type);
  86. UNUSED static void print_socket_protocol(int domain, int type, int protocol);
  87. /*
  88. * Utility functions
  89. */
  90. static void
  91. print_ipc_cmd(int cmd)
  92. {
  93. #define output_cmd(val) \
  94. if( cmd == val ) { \
  95. qemu_log(#val); \
  96. return; \
  97. }
  98. cmd &= 0xff;
  99. /* General IPC commands */
  100. output_cmd( IPC_RMID );
  101. output_cmd( IPC_SET );
  102. output_cmd( IPC_STAT );
  103. output_cmd( IPC_INFO );
  104. /* msgctl() commands */
  105. output_cmd( MSG_STAT );
  106. output_cmd( MSG_INFO );
  107. /* shmctl() commands */
  108. output_cmd( SHM_LOCK );
  109. output_cmd( SHM_UNLOCK );
  110. output_cmd( SHM_STAT );
  111. output_cmd( SHM_INFO );
  112. /* semctl() commands */
  113. output_cmd( GETPID );
  114. output_cmd( GETVAL );
  115. output_cmd( GETALL );
  116. output_cmd( GETNCNT );
  117. output_cmd( GETZCNT );
  118. output_cmd( SETVAL );
  119. output_cmd( SETALL );
  120. output_cmd( SEM_STAT );
  121. output_cmd( SEM_INFO );
  122. output_cmd( IPC_RMID );
  123. output_cmd( IPC_RMID );
  124. output_cmd( IPC_RMID );
  125. output_cmd( IPC_RMID );
  126. output_cmd( IPC_RMID );
  127. output_cmd( IPC_RMID );
  128. output_cmd( IPC_RMID );
  129. output_cmd( IPC_RMID );
  130. output_cmd( IPC_RMID );
  131. /* Some value we don't recognize */
  132. qemu_log("%d", cmd);
  133. }
  134. static const char * const target_signal_name[] = {
  135. #define MAKE_SIG_ENTRY(sig) [TARGET_##sig] = #sig,
  136. MAKE_SIGNAL_LIST
  137. #undef MAKE_SIG_ENTRY
  138. };
  139. static void
  140. print_signal(abi_ulong arg, int last)
  141. {
  142. const char *signal_name = NULL;
  143. if (arg < ARRAY_SIZE(target_signal_name)) {
  144. signal_name = target_signal_name[arg];
  145. }
  146. if (signal_name == NULL) {
  147. print_raw_param("%ld", arg, last);
  148. return;
  149. }
  150. qemu_log("%s%s", signal_name, get_comma(last));
  151. }
  152. static void print_si_code(int arg)
  153. {
  154. const char *codename = NULL;
  155. switch (arg) {
  156. case SI_USER:
  157. codename = "SI_USER";
  158. break;
  159. case SI_KERNEL:
  160. codename = "SI_KERNEL";
  161. break;
  162. case SI_QUEUE:
  163. codename = "SI_QUEUE";
  164. break;
  165. case SI_TIMER:
  166. codename = "SI_TIMER";
  167. break;
  168. case SI_MESGQ:
  169. codename = "SI_MESGQ";
  170. break;
  171. case SI_ASYNCIO:
  172. codename = "SI_ASYNCIO";
  173. break;
  174. case SI_SIGIO:
  175. codename = "SI_SIGIO";
  176. break;
  177. case SI_TKILL:
  178. codename = "SI_TKILL";
  179. break;
  180. default:
  181. qemu_log("%d", arg);
  182. return;
  183. }
  184. qemu_log("%s", codename);
  185. }
  186. static void get_target_siginfo(target_siginfo_t *tinfo,
  187. const target_siginfo_t *info)
  188. {
  189. abi_ulong sival_ptr;
  190. int sig;
  191. int si_errno;
  192. int si_code;
  193. int si_type;
  194. __get_user(sig, &info->si_signo);
  195. __get_user(si_errno, &tinfo->si_errno);
  196. __get_user(si_code, &info->si_code);
  197. tinfo->si_signo = sig;
  198. tinfo->si_errno = si_errno;
  199. tinfo->si_code = si_code;
  200. /* Ensure we don't leak random junk to the guest later */
  201. memset(tinfo->_sifields._pad, 0, sizeof(tinfo->_sifields._pad));
  202. /* This is awkward, because we have to use a combination of
  203. * the si_code and si_signo to figure out which of the union's
  204. * members are valid. (Within the host kernel it is always possible
  205. * to tell, but the kernel carefully avoids giving userspace the
  206. * high 16 bits of si_code, so we don't have the information to
  207. * do this the easy way...) We therefore make our best guess,
  208. * bearing in mind that a guest can spoof most of the si_codes
  209. * via rt_sigqueueinfo() if it likes.
  210. *
  211. * Once we have made our guess, we record it in the top 16 bits of
  212. * the si_code, so that print_siginfo() later can use it.
  213. * print_siginfo() will strip these top bits out before printing
  214. * the si_code.
  215. */
  216. switch (si_code) {
  217. case SI_USER:
  218. case SI_TKILL:
  219. case SI_KERNEL:
  220. /* Sent via kill(), tkill() or tgkill(), or direct from the kernel.
  221. * These are the only unspoofable si_code values.
  222. */
  223. __get_user(tinfo->_sifields._kill._pid, &info->_sifields._kill._pid);
  224. __get_user(tinfo->_sifields._kill._uid, &info->_sifields._kill._uid);
  225. si_type = QEMU_SI_KILL;
  226. break;
  227. default:
  228. /* Everything else is spoofable. Make best guess based on signal */
  229. switch (sig) {
  230. case TARGET_SIGCHLD:
  231. __get_user(tinfo->_sifields._sigchld._pid,
  232. &info->_sifields._sigchld._pid);
  233. __get_user(tinfo->_sifields._sigchld._uid,
  234. &info->_sifields._sigchld._uid);
  235. __get_user(tinfo->_sifields._sigchld._status,
  236. &info->_sifields._sigchld._status);
  237. __get_user(tinfo->_sifields._sigchld._utime,
  238. &info->_sifields._sigchld._utime);
  239. __get_user(tinfo->_sifields._sigchld._stime,
  240. &info->_sifields._sigchld._stime);
  241. si_type = QEMU_SI_CHLD;
  242. break;
  243. case TARGET_SIGIO:
  244. __get_user(tinfo->_sifields._sigpoll._band,
  245. &info->_sifields._sigpoll._band);
  246. __get_user(tinfo->_sifields._sigpoll._fd,
  247. &info->_sifields._sigpoll._fd);
  248. si_type = QEMU_SI_POLL;
  249. break;
  250. default:
  251. /* Assume a sigqueue()/mq_notify()/rt_sigqueueinfo() source. */
  252. __get_user(tinfo->_sifields._rt._pid, &info->_sifields._rt._pid);
  253. __get_user(tinfo->_sifields._rt._uid, &info->_sifields._rt._uid);
  254. /* XXX: potential problem if 64 bit */
  255. __get_user(sival_ptr, &info->_sifields._rt._sigval.sival_ptr);
  256. tinfo->_sifields._rt._sigval.sival_ptr = sival_ptr;
  257. si_type = QEMU_SI_RT;
  258. break;
  259. }
  260. break;
  261. }
  262. tinfo->si_code = deposit32(si_code, 16, 16, si_type);
  263. }
  264. static void print_siginfo(const target_siginfo_t *tinfo)
  265. {
  266. /* Print a target_siginfo_t in the format desired for printing
  267. * signals being taken. We assume the target_siginfo_t is in the
  268. * internal form where the top 16 bits of si_code indicate which
  269. * part of the union is valid, rather than in the guest-visible
  270. * form where the bottom 16 bits are sign-extended into the top 16.
  271. */
  272. int si_type = extract32(tinfo->si_code, 16, 16);
  273. int si_code = sextract32(tinfo->si_code, 0, 16);
  274. qemu_log("{si_signo=");
  275. print_signal(tinfo->si_signo, 1);
  276. qemu_log(", si_code=");
  277. print_si_code(si_code);
  278. switch (si_type) {
  279. case QEMU_SI_KILL:
  280. qemu_log(", si_pid=%u, si_uid=%u",
  281. (unsigned int)tinfo->_sifields._kill._pid,
  282. (unsigned int)tinfo->_sifields._kill._uid);
  283. break;
  284. case QEMU_SI_TIMER:
  285. qemu_log(", si_timer1=%u, si_timer2=%u",
  286. tinfo->_sifields._timer._timer1,
  287. tinfo->_sifields._timer._timer2);
  288. break;
  289. case QEMU_SI_POLL:
  290. qemu_log(", si_band=%d, si_fd=%d",
  291. tinfo->_sifields._sigpoll._band,
  292. tinfo->_sifields._sigpoll._fd);
  293. break;
  294. case QEMU_SI_FAULT:
  295. qemu_log(", si_addr=");
  296. print_pointer(tinfo->_sifields._sigfault._addr, 1);
  297. break;
  298. case QEMU_SI_CHLD:
  299. qemu_log(", si_pid=%u, si_uid=%u, si_status=%d"
  300. ", si_utime=" TARGET_ABI_FMT_ld
  301. ", si_stime=" TARGET_ABI_FMT_ld,
  302. (unsigned int)(tinfo->_sifields._sigchld._pid),
  303. (unsigned int)(tinfo->_sifields._sigchld._uid),
  304. tinfo->_sifields._sigchld._status,
  305. tinfo->_sifields._sigchld._utime,
  306. tinfo->_sifields._sigchld._stime);
  307. break;
  308. case QEMU_SI_RT:
  309. qemu_log(", si_pid=%u, si_uid=%u, si_sigval=" TARGET_ABI_FMT_ld,
  310. (unsigned int)tinfo->_sifields._rt._pid,
  311. (unsigned int)tinfo->_sifields._rt._uid,
  312. tinfo->_sifields._rt._sigval.sival_ptr);
  313. break;
  314. default:
  315. g_assert_not_reached();
  316. }
  317. qemu_log("}");
  318. }
  319. static void
  320. print_sockaddr(abi_ulong addr, abi_long addrlen, int last)
  321. {
  322. struct target_sockaddr *sa;
  323. int i;
  324. int sa_family;
  325. sa = lock_user(VERIFY_READ, addr, addrlen, 1);
  326. if (sa) {
  327. sa_family = tswap16(sa->sa_family);
  328. switch (sa_family) {
  329. case AF_UNIX: {
  330. struct target_sockaddr_un *un = (struct target_sockaddr_un *)sa;
  331. int i;
  332. qemu_log("{sun_family=AF_UNIX,sun_path=\"");
  333. for (i = 0; i < addrlen -
  334. offsetof(struct target_sockaddr_un, sun_path) &&
  335. un->sun_path[i]; i++) {
  336. qemu_log("%c", un->sun_path[i]);
  337. }
  338. qemu_log("\"}");
  339. break;
  340. }
  341. case AF_INET: {
  342. struct target_sockaddr_in *in = (struct target_sockaddr_in *)sa;
  343. uint8_t *c = (uint8_t *)&in->sin_addr.s_addr;
  344. qemu_log("{sin_family=AF_INET,sin_port=htons(%d),",
  345. ntohs(in->sin_port));
  346. qemu_log("sin_addr=inet_addr(\"%d.%d.%d.%d\")",
  347. c[0], c[1], c[2], c[3]);
  348. qemu_log("}");
  349. break;
  350. }
  351. case AF_PACKET: {
  352. struct target_sockaddr_ll *ll = (struct target_sockaddr_ll *)sa;
  353. uint8_t *c = (uint8_t *)&ll->sll_addr;
  354. qemu_log("{sll_family=AF_PACKET,"
  355. "sll_protocol=htons(0x%04x),if%d,pkttype=",
  356. ntohs(ll->sll_protocol), ll->sll_ifindex);
  357. switch (ll->sll_pkttype) {
  358. case PACKET_HOST:
  359. qemu_log("PACKET_HOST");
  360. break;
  361. case PACKET_BROADCAST:
  362. qemu_log("PACKET_BROADCAST");
  363. break;
  364. case PACKET_MULTICAST:
  365. qemu_log("PACKET_MULTICAST");
  366. break;
  367. case PACKET_OTHERHOST:
  368. qemu_log("PACKET_OTHERHOST");
  369. break;
  370. case PACKET_OUTGOING:
  371. qemu_log("PACKET_OUTGOING");
  372. break;
  373. default:
  374. qemu_log("%d", ll->sll_pkttype);
  375. break;
  376. }
  377. qemu_log(",sll_addr=%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x",
  378. c[0], c[1], c[2], c[3], c[4], c[5], c[6], c[7]);
  379. qemu_log("}");
  380. break;
  381. }
  382. case AF_NETLINK: {
  383. struct target_sockaddr_nl *nl = (struct target_sockaddr_nl *)sa;
  384. qemu_log("{nl_family=AF_NETLINK,nl_pid=%u,nl_groups=%u}",
  385. tswap32(nl->nl_pid), tswap32(nl->nl_groups));
  386. break;
  387. }
  388. default:
  389. qemu_log("{sa_family=%d, sa_data={", sa->sa_family);
  390. for (i = 0; i < 13; i++) {
  391. qemu_log("%02x, ", sa->sa_data[i]);
  392. }
  393. qemu_log("%02x}", sa->sa_data[i]);
  394. qemu_log("}");
  395. break;
  396. }
  397. unlock_user(sa, addr, 0);
  398. } else {
  399. print_raw_param("0x"TARGET_ABI_FMT_lx, addr, 0);
  400. }
  401. qemu_log(", "TARGET_ABI_FMT_ld"%s", addrlen, get_comma(last));
  402. }
  403. static void
  404. print_socket_domain(int domain)
  405. {
  406. switch (domain) {
  407. case PF_UNIX:
  408. qemu_log("PF_UNIX");
  409. break;
  410. case PF_INET:
  411. qemu_log("PF_INET");
  412. break;
  413. case PF_NETLINK:
  414. qemu_log("PF_NETLINK");
  415. break;
  416. case PF_PACKET:
  417. qemu_log("PF_PACKET");
  418. break;
  419. default:
  420. qemu_log("%d", domain);
  421. break;
  422. }
  423. }
  424. static void
  425. print_socket_type(int type)
  426. {
  427. switch (type & TARGET_SOCK_TYPE_MASK) {
  428. case TARGET_SOCK_DGRAM:
  429. qemu_log("SOCK_DGRAM");
  430. break;
  431. case TARGET_SOCK_STREAM:
  432. qemu_log("SOCK_STREAM");
  433. break;
  434. case TARGET_SOCK_RAW:
  435. qemu_log("SOCK_RAW");
  436. break;
  437. case TARGET_SOCK_RDM:
  438. qemu_log("SOCK_RDM");
  439. break;
  440. case TARGET_SOCK_SEQPACKET:
  441. qemu_log("SOCK_SEQPACKET");
  442. break;
  443. case TARGET_SOCK_PACKET:
  444. qemu_log("SOCK_PACKET");
  445. break;
  446. }
  447. if (type & TARGET_SOCK_CLOEXEC) {
  448. qemu_log("|SOCK_CLOEXEC");
  449. }
  450. if (type & TARGET_SOCK_NONBLOCK) {
  451. qemu_log("|SOCK_NONBLOCK");
  452. }
  453. }
  454. static void
  455. print_socket_protocol(int domain, int type, int protocol)
  456. {
  457. if (domain == AF_PACKET ||
  458. (domain == AF_INET && type == TARGET_SOCK_PACKET)) {
  459. switch (protocol) {
  460. case 0x0003:
  461. qemu_log("ETH_P_ALL");
  462. break;
  463. default:
  464. qemu_log("%d", protocol);
  465. }
  466. return;
  467. }
  468. if (domain == PF_NETLINK) {
  469. switch (protocol) {
  470. case NETLINK_ROUTE:
  471. qemu_log("NETLINK_ROUTE");
  472. break;
  473. case NETLINK_AUDIT:
  474. qemu_log("NETLINK_AUDIT");
  475. break;
  476. case NETLINK_NETFILTER:
  477. qemu_log("NETLINK_NETFILTER");
  478. break;
  479. case NETLINK_KOBJECT_UEVENT:
  480. qemu_log("NETLINK_KOBJECT_UEVENT");
  481. break;
  482. case NETLINK_RDMA:
  483. qemu_log("NETLINK_RDMA");
  484. break;
  485. case NETLINK_CRYPTO:
  486. qemu_log("NETLINK_CRYPTO");
  487. break;
  488. default:
  489. qemu_log("%d", protocol);
  490. break;
  491. }
  492. return;
  493. }
  494. switch (protocol) {
  495. case IPPROTO_IP:
  496. qemu_log("IPPROTO_IP");
  497. break;
  498. case IPPROTO_TCP:
  499. qemu_log("IPPROTO_TCP");
  500. break;
  501. case IPPROTO_UDP:
  502. qemu_log("IPPROTO_UDP");
  503. break;
  504. case IPPROTO_RAW:
  505. qemu_log("IPPROTO_RAW");
  506. break;
  507. default:
  508. qemu_log("%d", protocol);
  509. break;
  510. }
  511. }
  512. #ifdef TARGET_NR__newselect
  513. static void
  514. print_fdset(int n, abi_ulong target_fds_addr)
  515. {
  516. int i;
  517. int first = 1;
  518. qemu_log("[");
  519. if( target_fds_addr ) {
  520. abi_long *target_fds;
  521. target_fds = lock_user(VERIFY_READ,
  522. target_fds_addr,
  523. sizeof(*target_fds)*(n / TARGET_ABI_BITS + 1),
  524. 1);
  525. if (!target_fds)
  526. return;
  527. for (i=n; i>=0; i--) {
  528. if ((tswapal(target_fds[i / TARGET_ABI_BITS]) >>
  529. (i & (TARGET_ABI_BITS - 1))) & 1) {
  530. qemu_log("%s%d", get_comma(first), i);
  531. first = 0;
  532. }
  533. }
  534. unlock_user(target_fds, target_fds_addr, 0);
  535. }
  536. qemu_log("]");
  537. }
  538. #endif
  539. /*
  540. * Sysycall specific output functions
  541. */
  542. /* select */
  543. #ifdef TARGET_NR__newselect
  544. static void
  545. print_newselect(CPUArchState *cpu_env, const struct syscallname *name,
  546. abi_long arg1, abi_long arg2, abi_long arg3,
  547. abi_long arg4, abi_long arg5, abi_long arg6)
  548. {
  549. print_syscall_prologue(name);
  550. print_fdset(arg1, arg2);
  551. qemu_log(",");
  552. print_fdset(arg1, arg3);
  553. qemu_log(",");
  554. print_fdset(arg1, arg4);
  555. qemu_log(",");
  556. print_timeval(arg5, 1);
  557. print_syscall_epilogue(name);
  558. }
  559. #endif
  560. #ifdef TARGET_NR_semctl
  561. static void
  562. print_semctl(CPUArchState *cpu_env, const struct syscallname *name,
  563. abi_long arg1, abi_long arg2, abi_long arg3,
  564. abi_long arg4, abi_long arg5, abi_long arg6)
  565. {
  566. qemu_log("%s(" TARGET_ABI_FMT_ld "," TARGET_ABI_FMT_ld ",",
  567. name->name, arg1, arg2);
  568. print_ipc_cmd(arg3);
  569. qemu_log(",0x" TARGET_ABI_FMT_lx ")", arg4);
  570. }
  571. #endif
  572. static void
  573. print_execve(CPUArchState *cpu_env, const struct syscallname *name,
  574. abi_long arg1, abi_long arg2, abi_long arg3,
  575. abi_long arg4, abi_long arg5, abi_long arg6)
  576. {
  577. abi_ulong arg_ptr_addr;
  578. char *s;
  579. if (!(s = lock_user_string(arg1)))
  580. return;
  581. qemu_log("%s(\"%s\",{", name->name, s);
  582. unlock_user(s, arg1, 0);
  583. for (arg_ptr_addr = arg2; ; arg_ptr_addr += sizeof(abi_ulong)) {
  584. abi_ulong *arg_ptr, arg_addr;
  585. arg_ptr = lock_user(VERIFY_READ, arg_ptr_addr, sizeof(abi_ulong), 1);
  586. if (!arg_ptr)
  587. return;
  588. arg_addr = tswapal(*arg_ptr);
  589. unlock_user(arg_ptr, arg_ptr_addr, 0);
  590. if (!arg_addr)
  591. break;
  592. if ((s = lock_user_string(arg_addr))) {
  593. qemu_log("\"%s\",", s);
  594. unlock_user(s, arg_addr, 0);
  595. }
  596. }
  597. qemu_log("NULL})");
  598. }
  599. #ifdef TARGET_NR_ipc
  600. static void
  601. print_ipc(CPUArchState *cpu_env, const struct syscallname *name,
  602. abi_long arg1, abi_long arg2, abi_long arg3,
  603. abi_long arg4, abi_long arg5, abi_long arg6)
  604. {
  605. switch(arg1) {
  606. case IPCOP_semctl:
  607. qemu_log("semctl(" TARGET_ABI_FMT_ld "," TARGET_ABI_FMT_ld ",",
  608. arg1, arg2);
  609. print_ipc_cmd(arg3);
  610. qemu_log(",0x" TARGET_ABI_FMT_lx ")", arg4);
  611. break;
  612. default:
  613. qemu_log(("%s("
  614. TARGET_ABI_FMT_ld ","
  615. TARGET_ABI_FMT_ld ","
  616. TARGET_ABI_FMT_ld ","
  617. TARGET_ABI_FMT_ld
  618. ")"),
  619. name->name, arg1, arg2, arg3, arg4);
  620. }
  621. }
  622. #endif
  623. /*
  624. * Variants for the return value output function
  625. */
  626. static bool
  627. print_syscall_err(abi_long ret)
  628. {
  629. const char *errstr;
  630. qemu_log(" = ");
  631. if (is_error(ret)) {
  632. errstr = target_strerror(-ret);
  633. if (errstr) {
  634. qemu_log("-1 errno=%d (%s)", (int)-ret, errstr);
  635. return true;
  636. }
  637. }
  638. return false;
  639. }
  640. static void
  641. print_syscall_ret_addr(CPUArchState *cpu_env, const struct syscallname *name,
  642. abi_long ret, abi_long arg0, abi_long arg1,
  643. abi_long arg2, abi_long arg3, abi_long arg4,
  644. abi_long arg5)
  645. {
  646. if (!print_syscall_err(ret)) {
  647. qemu_log("0x" TARGET_ABI_FMT_lx, ret);
  648. }
  649. qemu_log("\n");
  650. }
  651. #if 0 /* currently unused */
  652. static void
  653. print_syscall_ret_raw(struct syscallname *name, abi_long ret)
  654. {
  655. qemu_log(" = 0x" TARGET_ABI_FMT_lx "\n", ret);
  656. }
  657. #endif
  658. #ifdef TARGET_NR__newselect
  659. static void
  660. print_syscall_ret_newselect(CPUArchState *cpu_env, const struct syscallname *name,
  661. abi_long ret, abi_long arg0, abi_long arg1,
  662. abi_long arg2, abi_long arg3, abi_long arg4,
  663. abi_long arg5)
  664. {
  665. if (!print_syscall_err(ret)) {
  666. qemu_log(" = 0x" TARGET_ABI_FMT_lx " (", ret);
  667. print_fdset(arg0, arg1);
  668. qemu_log(",");
  669. print_fdset(arg0, arg2);
  670. qemu_log(",");
  671. print_fdset(arg0, arg3);
  672. qemu_log(",");
  673. print_timeval(arg4, 1);
  674. qemu_log(")");
  675. }
  676. qemu_log("\n");
  677. }
  678. #endif
  679. /* special meanings of adjtimex()' non-negative return values */
  680. #define TARGET_TIME_OK 0 /* clock synchronized, no leap second */
  681. #define TARGET_TIME_INS 1 /* insert leap second */
  682. #define TARGET_TIME_DEL 2 /* delete leap second */
  683. #define TARGET_TIME_OOP 3 /* leap second in progress */
  684. #define TARGET_TIME_WAIT 4 /* leap second has occurred */
  685. #define TARGET_TIME_ERROR 5 /* clock not synchronized */
  686. #ifdef TARGET_NR_adjtimex
  687. static void
  688. print_syscall_ret_adjtimex(CPUArchState *cpu_env, const struct syscallname *name,
  689. abi_long ret, abi_long arg0, abi_long arg1,
  690. abi_long arg2, abi_long arg3, abi_long arg4,
  691. abi_long arg5)
  692. {
  693. if (!print_syscall_err(ret)) {
  694. qemu_log(TARGET_ABI_FMT_ld, ret);
  695. switch (ret) {
  696. case TARGET_TIME_OK:
  697. qemu_log(" TIME_OK (clock synchronized, no leap second)");
  698. break;
  699. case TARGET_TIME_INS:
  700. qemu_log(" TIME_INS (insert leap second)");
  701. break;
  702. case TARGET_TIME_DEL:
  703. qemu_log(" TIME_DEL (delete leap second)");
  704. break;
  705. case TARGET_TIME_OOP:
  706. qemu_log(" TIME_OOP (leap second in progress)");
  707. break;
  708. case TARGET_TIME_WAIT:
  709. qemu_log(" TIME_WAIT (leap second has occurred)");
  710. break;
  711. case TARGET_TIME_ERROR:
  712. qemu_log(" TIME_ERROR (clock not synchronized)");
  713. break;
  714. }
  715. }
  716. qemu_log("\n");
  717. }
  718. #endif
  719. #if defined(TARGET_NR_clock_gettime) || defined(TARGET_NR_clock_getres)
  720. static void
  721. print_syscall_ret_clock_gettime(CPUArchState *cpu_env, const struct syscallname *name,
  722. abi_long ret, abi_long arg0, abi_long arg1,
  723. abi_long arg2, abi_long arg3, abi_long arg4,
  724. abi_long arg5)
  725. {
  726. if (!print_syscall_err(ret)) {
  727. qemu_log(TARGET_ABI_FMT_ld, ret);
  728. qemu_log(" (");
  729. print_timespec(arg1, 1);
  730. qemu_log(")");
  731. }
  732. qemu_log("\n");
  733. }
  734. #define print_syscall_ret_clock_getres print_syscall_ret_clock_gettime
  735. #endif
  736. #if defined(TARGET_NR_clock_gettime64)
  737. static void
  738. print_syscall_ret_clock_gettime64(CPUArchState *cpu_env, const struct syscallname *name,
  739. abi_long ret, abi_long arg0, abi_long arg1,
  740. abi_long arg2, abi_long arg3, abi_long arg4,
  741. abi_long arg5)
  742. {
  743. if (!print_syscall_err(ret)) {
  744. qemu_log(TARGET_ABI_FMT_ld, ret);
  745. qemu_log(" (");
  746. print_timespec64(arg1, 1);
  747. qemu_log(")");
  748. }
  749. qemu_log("\n");
  750. }
  751. #endif
  752. #ifdef TARGET_NR_gettimeofday
  753. static void
  754. print_syscall_ret_gettimeofday(CPUArchState *cpu_env, const struct syscallname *name,
  755. abi_long ret, abi_long arg0, abi_long arg1,
  756. abi_long arg2, abi_long arg3, abi_long arg4,
  757. abi_long arg5)
  758. {
  759. if (!print_syscall_err(ret)) {
  760. qemu_log(TARGET_ABI_FMT_ld, ret);
  761. qemu_log(" (");
  762. print_timeval(arg0, 0);
  763. print_timezone(arg1, 1);
  764. qemu_log(")");
  765. }
  766. qemu_log("\n");
  767. }
  768. #endif
  769. #ifdef TARGET_NR_getitimer
  770. static void
  771. print_syscall_ret_getitimer(CPUArchState *cpu_env, const struct syscallname *name,
  772. abi_long ret, abi_long arg0, abi_long arg1,
  773. abi_long arg2, abi_long arg3, abi_long arg4,
  774. abi_long arg5)
  775. {
  776. if (!print_syscall_err(ret)) {
  777. qemu_log(TARGET_ABI_FMT_ld, ret);
  778. qemu_log(" (");
  779. print_itimerval(arg1, 1);
  780. qemu_log(")");
  781. }
  782. qemu_log("\n");
  783. }
  784. #endif
  785. #ifdef TARGET_NR_getitimer
  786. static void
  787. print_syscall_ret_setitimer(CPUArchState *cpu_env, const struct syscallname *name,
  788. abi_long ret, abi_long arg0, abi_long arg1,
  789. abi_long arg2, abi_long arg3, abi_long arg4,
  790. abi_long arg5)
  791. {
  792. if (!print_syscall_err(ret)) {
  793. qemu_log(TARGET_ABI_FMT_ld, ret);
  794. qemu_log(" (old_value = ");
  795. print_itimerval(arg2, 1);
  796. qemu_log(")");
  797. }
  798. qemu_log("\n");
  799. }
  800. #endif
  801. #if defined(TARGET_NR_listxattr) || defined(TARGET_NR_llistxattr) \
  802. || defined(TARGGET_NR_flistxattr)
  803. static void
  804. print_syscall_ret_listxattr(CPUArchState *cpu_env, const struct syscallname *name,
  805. abi_long ret, abi_long arg0, abi_long arg1,
  806. abi_long arg2, abi_long arg3, abi_long arg4,
  807. abi_long arg5)
  808. {
  809. if (!print_syscall_err(ret)) {
  810. qemu_log(TARGET_ABI_FMT_ld, ret);
  811. qemu_log(" (list = ");
  812. if (arg1 != 0) {
  813. abi_long attr = arg1;
  814. while (ret) {
  815. if (attr != arg1) {
  816. qemu_log(",");
  817. }
  818. print_string(attr, 1);
  819. ret -= target_strlen(attr) + 1;
  820. attr += target_strlen(attr) + 1;
  821. }
  822. } else {
  823. qemu_log("NULL");
  824. }
  825. qemu_log(")");
  826. }
  827. qemu_log("\n");
  828. }
  829. #define print_syscall_ret_llistxattr print_syscall_ret_listxattr
  830. #define print_syscall_ret_flistxattr print_syscall_ret_listxattr
  831. #endif
  832. #ifdef TARGET_NR_ioctl
  833. static void
  834. print_syscall_ret_ioctl(CPUArchState *cpu_env, const struct syscallname *name,
  835. abi_long ret, abi_long arg0, abi_long arg1,
  836. abi_long arg2, abi_long arg3, abi_long arg4,
  837. abi_long arg5)
  838. {
  839. if (!print_syscall_err(ret)) {
  840. qemu_log(TARGET_ABI_FMT_ld, ret);
  841. const IOCTLEntry *ie;
  842. const argtype *arg_type;
  843. void *argptr;
  844. int target_size;
  845. for (ie = ioctl_entries; ie->target_cmd != 0; ie++) {
  846. if (ie->target_cmd == arg1) {
  847. break;
  848. }
  849. }
  850. if (ie->target_cmd == arg1 &&
  851. (ie->access == IOC_R || ie->access == IOC_RW)) {
  852. arg_type = ie->arg_type;
  853. qemu_log(" (");
  854. arg_type++;
  855. target_size = thunk_type_size(arg_type, 0);
  856. argptr = lock_user(VERIFY_READ, arg2, target_size, 1);
  857. if (argptr) {
  858. thunk_print(argptr, arg_type);
  859. unlock_user(argptr, arg2, target_size);
  860. } else {
  861. print_pointer(arg2, 1);
  862. }
  863. qemu_log(")");
  864. }
  865. }
  866. qemu_log("\n");
  867. }
  868. #endif
  869. UNUSED static struct flags access_flags[] = {
  870. FLAG_GENERIC(F_OK),
  871. FLAG_GENERIC(R_OK),
  872. FLAG_GENERIC(W_OK),
  873. FLAG_GENERIC(X_OK),
  874. FLAG_END,
  875. };
  876. UNUSED static struct flags at_file_flags[] = {
  877. #ifdef AT_EACCESS
  878. FLAG_GENERIC(AT_EACCESS),
  879. #endif
  880. #ifdef AT_SYMLINK_NOFOLLOW
  881. FLAG_GENERIC(AT_SYMLINK_NOFOLLOW),
  882. #endif
  883. FLAG_END,
  884. };
  885. UNUSED static struct flags unlinkat_flags[] = {
  886. #ifdef AT_REMOVEDIR
  887. FLAG_GENERIC(AT_REMOVEDIR),
  888. #endif
  889. FLAG_END,
  890. };
  891. UNUSED static struct flags mode_flags[] = {
  892. FLAG_GENERIC(S_IFSOCK),
  893. FLAG_GENERIC(S_IFLNK),
  894. FLAG_GENERIC(S_IFREG),
  895. FLAG_GENERIC(S_IFBLK),
  896. FLAG_GENERIC(S_IFDIR),
  897. FLAG_GENERIC(S_IFCHR),
  898. FLAG_GENERIC(S_IFIFO),
  899. FLAG_END,
  900. };
  901. UNUSED static struct flags open_access_flags[] = {
  902. FLAG_TARGET(O_RDONLY),
  903. FLAG_TARGET(O_WRONLY),
  904. FLAG_TARGET(O_RDWR),
  905. FLAG_END,
  906. };
  907. UNUSED static struct flags open_flags[] = {
  908. FLAG_TARGET(O_APPEND),
  909. FLAG_TARGET(O_CREAT),
  910. FLAG_TARGET(O_DIRECTORY),
  911. FLAG_TARGET(O_EXCL),
  912. FLAG_TARGET(O_LARGEFILE),
  913. FLAG_TARGET(O_NOCTTY),
  914. FLAG_TARGET(O_NOFOLLOW),
  915. FLAG_TARGET(O_NONBLOCK), /* also O_NDELAY */
  916. FLAG_TARGET(O_DSYNC),
  917. FLAG_TARGET(__O_SYNC),
  918. FLAG_TARGET(O_TRUNC),
  919. #ifdef O_DIRECT
  920. FLAG_TARGET(O_DIRECT),
  921. #endif
  922. #ifdef O_NOATIME
  923. FLAG_TARGET(O_NOATIME),
  924. #endif
  925. #ifdef O_CLOEXEC
  926. FLAG_TARGET(O_CLOEXEC),
  927. #endif
  928. #ifdef O_PATH
  929. FLAG_TARGET(O_PATH),
  930. #endif
  931. #ifdef O_TMPFILE
  932. FLAG_TARGET(O_TMPFILE),
  933. FLAG_TARGET(__O_TMPFILE),
  934. #endif
  935. FLAG_END,
  936. };
  937. UNUSED static struct flags mount_flags[] = {
  938. #ifdef MS_BIND
  939. FLAG_GENERIC(MS_BIND),
  940. #endif
  941. #ifdef MS_DIRSYNC
  942. FLAG_GENERIC(MS_DIRSYNC),
  943. #endif
  944. FLAG_GENERIC(MS_MANDLOCK),
  945. #ifdef MS_MOVE
  946. FLAG_GENERIC(MS_MOVE),
  947. #endif
  948. FLAG_GENERIC(MS_NOATIME),
  949. FLAG_GENERIC(MS_NODEV),
  950. FLAG_GENERIC(MS_NODIRATIME),
  951. FLAG_GENERIC(MS_NOEXEC),
  952. FLAG_GENERIC(MS_NOSUID),
  953. FLAG_GENERIC(MS_RDONLY),
  954. #ifdef MS_RELATIME
  955. FLAG_GENERIC(MS_RELATIME),
  956. #endif
  957. FLAG_GENERIC(MS_REMOUNT),
  958. FLAG_GENERIC(MS_SYNCHRONOUS),
  959. FLAG_END,
  960. };
  961. UNUSED static struct flags umount2_flags[] = {
  962. #ifdef MNT_FORCE
  963. FLAG_GENERIC(MNT_FORCE),
  964. #endif
  965. #ifdef MNT_DETACH
  966. FLAG_GENERIC(MNT_DETACH),
  967. #endif
  968. #ifdef MNT_EXPIRE
  969. FLAG_GENERIC(MNT_EXPIRE),
  970. #endif
  971. FLAG_END,
  972. };
  973. UNUSED static struct flags mmap_prot_flags[] = {
  974. FLAG_GENERIC(PROT_NONE),
  975. FLAG_GENERIC(PROT_EXEC),
  976. FLAG_GENERIC(PROT_READ),
  977. FLAG_GENERIC(PROT_WRITE),
  978. FLAG_TARGET(PROT_SEM),
  979. FLAG_GENERIC(PROT_GROWSDOWN),
  980. FLAG_GENERIC(PROT_GROWSUP),
  981. FLAG_END,
  982. };
  983. UNUSED static struct flags mmap_flags[] = {
  984. FLAG_TARGET(MAP_SHARED),
  985. FLAG_TARGET(MAP_PRIVATE),
  986. FLAG_TARGET(MAP_ANONYMOUS),
  987. FLAG_TARGET(MAP_DENYWRITE),
  988. FLAG_TARGET(MAP_FIXED),
  989. FLAG_TARGET(MAP_GROWSDOWN),
  990. FLAG_TARGET(MAP_EXECUTABLE),
  991. #ifdef MAP_LOCKED
  992. FLAG_TARGET(MAP_LOCKED),
  993. #endif
  994. #ifdef MAP_NONBLOCK
  995. FLAG_TARGET(MAP_NONBLOCK),
  996. #endif
  997. FLAG_TARGET(MAP_NORESERVE),
  998. #ifdef MAP_POPULATE
  999. FLAG_TARGET(MAP_POPULATE),
  1000. #endif
  1001. #ifdef TARGET_MAP_UNINITIALIZED
  1002. FLAG_TARGET(MAP_UNINITIALIZED),
  1003. #endif
  1004. FLAG_END,
  1005. };
  1006. UNUSED static struct flags clone_flags[] = {
  1007. FLAG_GENERIC(CLONE_VM),
  1008. FLAG_GENERIC(CLONE_FS),
  1009. FLAG_GENERIC(CLONE_FILES),
  1010. FLAG_GENERIC(CLONE_SIGHAND),
  1011. FLAG_GENERIC(CLONE_PTRACE),
  1012. FLAG_GENERIC(CLONE_VFORK),
  1013. FLAG_GENERIC(CLONE_PARENT),
  1014. FLAG_GENERIC(CLONE_THREAD),
  1015. FLAG_GENERIC(CLONE_NEWNS),
  1016. FLAG_GENERIC(CLONE_SYSVSEM),
  1017. FLAG_GENERIC(CLONE_SETTLS),
  1018. FLAG_GENERIC(CLONE_PARENT_SETTID),
  1019. FLAG_GENERIC(CLONE_CHILD_CLEARTID),
  1020. FLAG_GENERIC(CLONE_DETACHED),
  1021. FLAG_GENERIC(CLONE_UNTRACED),
  1022. FLAG_GENERIC(CLONE_CHILD_SETTID),
  1023. #if defined(CLONE_NEWUTS)
  1024. FLAG_GENERIC(CLONE_NEWUTS),
  1025. #endif
  1026. #if defined(CLONE_NEWIPC)
  1027. FLAG_GENERIC(CLONE_NEWIPC),
  1028. #endif
  1029. #if defined(CLONE_NEWUSER)
  1030. FLAG_GENERIC(CLONE_NEWUSER),
  1031. #endif
  1032. #if defined(CLONE_NEWPID)
  1033. FLAG_GENERIC(CLONE_NEWPID),
  1034. #endif
  1035. #if defined(CLONE_NEWNET)
  1036. FLAG_GENERIC(CLONE_NEWNET),
  1037. #endif
  1038. #if defined(CLONE_NEWCGROUP)
  1039. FLAG_GENERIC(CLONE_NEWCGROUP),
  1040. #endif
  1041. #if defined(CLONE_NEWTIME)
  1042. FLAG_GENERIC(CLONE_NEWTIME),
  1043. #endif
  1044. #if defined(CLONE_IO)
  1045. FLAG_GENERIC(CLONE_IO),
  1046. #endif
  1047. FLAG_END,
  1048. };
  1049. UNUSED static struct flags msg_flags[] = {
  1050. /* send */
  1051. FLAG_GENERIC(MSG_CONFIRM),
  1052. FLAG_GENERIC(MSG_DONTROUTE),
  1053. FLAG_GENERIC(MSG_DONTWAIT),
  1054. FLAG_GENERIC(MSG_EOR),
  1055. FLAG_GENERIC(MSG_MORE),
  1056. FLAG_GENERIC(MSG_NOSIGNAL),
  1057. FLAG_GENERIC(MSG_OOB),
  1058. /* recv */
  1059. FLAG_GENERIC(MSG_CMSG_CLOEXEC),
  1060. FLAG_GENERIC(MSG_ERRQUEUE),
  1061. FLAG_GENERIC(MSG_PEEK),
  1062. FLAG_GENERIC(MSG_TRUNC),
  1063. FLAG_GENERIC(MSG_WAITALL),
  1064. /* recvmsg */
  1065. FLAG_GENERIC(MSG_CTRUNC),
  1066. FLAG_END,
  1067. };
  1068. UNUSED static struct flags statx_flags[] = {
  1069. #ifdef AT_EMPTY_PATH
  1070. FLAG_GENERIC(AT_EMPTY_PATH),
  1071. #endif
  1072. #ifdef AT_NO_AUTOMOUNT
  1073. FLAG_GENERIC(AT_NO_AUTOMOUNT),
  1074. #endif
  1075. #ifdef AT_SYMLINK_NOFOLLOW
  1076. FLAG_GENERIC(AT_SYMLINK_NOFOLLOW),
  1077. #endif
  1078. #ifdef AT_STATX_SYNC_AS_STAT
  1079. FLAG_GENERIC(AT_STATX_SYNC_AS_STAT),
  1080. #endif
  1081. #ifdef AT_STATX_FORCE_SYNC
  1082. FLAG_GENERIC(AT_STATX_FORCE_SYNC),
  1083. #endif
  1084. #ifdef AT_STATX_DONT_SYNC
  1085. FLAG_GENERIC(AT_STATX_DONT_SYNC),
  1086. #endif
  1087. FLAG_END,
  1088. };
  1089. UNUSED static struct flags statx_mask[] = {
  1090. /* This must come first, because it includes everything. */
  1091. #ifdef STATX_ALL
  1092. FLAG_GENERIC(STATX_ALL),
  1093. #endif
  1094. /* This must come second; it includes everything except STATX_BTIME. */
  1095. #ifdef STATX_BASIC_STATS
  1096. FLAG_GENERIC(STATX_BASIC_STATS),
  1097. #endif
  1098. #ifdef STATX_TYPE
  1099. FLAG_GENERIC(STATX_TYPE),
  1100. #endif
  1101. #ifdef STATX_MODE
  1102. FLAG_GENERIC(STATX_MODE),
  1103. #endif
  1104. #ifdef STATX_NLINK
  1105. FLAG_GENERIC(STATX_NLINK),
  1106. #endif
  1107. #ifdef STATX_UID
  1108. FLAG_GENERIC(STATX_UID),
  1109. #endif
  1110. #ifdef STATX_GID
  1111. FLAG_GENERIC(STATX_GID),
  1112. #endif
  1113. #ifdef STATX_ATIME
  1114. FLAG_GENERIC(STATX_ATIME),
  1115. #endif
  1116. #ifdef STATX_MTIME
  1117. FLAG_GENERIC(STATX_MTIME),
  1118. #endif
  1119. #ifdef STATX_CTIME
  1120. FLAG_GENERIC(STATX_CTIME),
  1121. #endif
  1122. #ifdef STATX_INO
  1123. FLAG_GENERIC(STATX_INO),
  1124. #endif
  1125. #ifdef STATX_SIZE
  1126. FLAG_GENERIC(STATX_SIZE),
  1127. #endif
  1128. #ifdef STATX_BLOCKS
  1129. FLAG_GENERIC(STATX_BLOCKS),
  1130. #endif
  1131. #ifdef STATX_BTIME
  1132. FLAG_GENERIC(STATX_BTIME),
  1133. #endif
  1134. FLAG_END,
  1135. };
  1136. UNUSED static struct flags falloc_flags[] = {
  1137. FLAG_GENERIC(FALLOC_FL_KEEP_SIZE),
  1138. FLAG_GENERIC(FALLOC_FL_PUNCH_HOLE),
  1139. #ifdef FALLOC_FL_NO_HIDE_STALE
  1140. FLAG_GENERIC(FALLOC_FL_NO_HIDE_STALE),
  1141. #endif
  1142. #ifdef FALLOC_FL_COLLAPSE_RANGE
  1143. FLAG_GENERIC(FALLOC_FL_COLLAPSE_RANGE),
  1144. #endif
  1145. #ifdef FALLOC_FL_ZERO_RANGE
  1146. FLAG_GENERIC(FALLOC_FL_ZERO_RANGE),
  1147. #endif
  1148. #ifdef FALLOC_FL_INSERT_RANGE
  1149. FLAG_GENERIC(FALLOC_FL_INSERT_RANGE),
  1150. #endif
  1151. #ifdef FALLOC_FL_UNSHARE_RANGE
  1152. FLAG_GENERIC(FALLOC_FL_UNSHARE_RANGE),
  1153. #endif
  1154. };
  1155. UNUSED static struct flags termios_iflags[] = {
  1156. FLAG_TARGET(IGNBRK),
  1157. FLAG_TARGET(BRKINT),
  1158. FLAG_TARGET(IGNPAR),
  1159. FLAG_TARGET(PARMRK),
  1160. FLAG_TARGET(INPCK),
  1161. FLAG_TARGET(ISTRIP),
  1162. FLAG_TARGET(INLCR),
  1163. FLAG_TARGET(IGNCR),
  1164. FLAG_TARGET(ICRNL),
  1165. FLAG_TARGET(IUCLC),
  1166. FLAG_TARGET(IXON),
  1167. FLAG_TARGET(IXANY),
  1168. FLAG_TARGET(IXOFF),
  1169. FLAG_TARGET(IMAXBEL),
  1170. FLAG_TARGET(IUTF8),
  1171. FLAG_END,
  1172. };
  1173. UNUSED static struct flags termios_oflags[] = {
  1174. FLAG_TARGET(OPOST),
  1175. FLAG_TARGET(OLCUC),
  1176. FLAG_TARGET(ONLCR),
  1177. FLAG_TARGET(OCRNL),
  1178. FLAG_TARGET(ONOCR),
  1179. FLAG_TARGET(ONLRET),
  1180. FLAG_TARGET(OFILL),
  1181. FLAG_TARGET(OFDEL),
  1182. FLAG_END,
  1183. };
  1184. UNUSED static struct enums termios_oflags_NLDLY[] = {
  1185. ENUM_TARGET(NL0),
  1186. ENUM_TARGET(NL1),
  1187. ENUM_END,
  1188. };
  1189. UNUSED static struct enums termios_oflags_CRDLY[] = {
  1190. ENUM_TARGET(CR0),
  1191. ENUM_TARGET(CR1),
  1192. ENUM_TARGET(CR2),
  1193. ENUM_TARGET(CR3),
  1194. ENUM_END,
  1195. };
  1196. UNUSED static struct enums termios_oflags_TABDLY[] = {
  1197. ENUM_TARGET(TAB0),
  1198. ENUM_TARGET(TAB1),
  1199. ENUM_TARGET(TAB2),
  1200. ENUM_TARGET(TAB3),
  1201. ENUM_END,
  1202. };
  1203. UNUSED static struct enums termios_oflags_VTDLY[] = {
  1204. ENUM_TARGET(VT0),
  1205. ENUM_TARGET(VT1),
  1206. ENUM_END,
  1207. };
  1208. UNUSED static struct enums termios_oflags_FFDLY[] = {
  1209. ENUM_TARGET(FF0),
  1210. ENUM_TARGET(FF1),
  1211. ENUM_END,
  1212. };
  1213. UNUSED static struct enums termios_oflags_BSDLY[] = {
  1214. ENUM_TARGET(BS0),
  1215. ENUM_TARGET(BS1),
  1216. ENUM_END,
  1217. };
  1218. UNUSED static struct enums termios_cflags_CBAUD[] = {
  1219. ENUM_TARGET(B0),
  1220. ENUM_TARGET(B50),
  1221. ENUM_TARGET(B75),
  1222. ENUM_TARGET(B110),
  1223. ENUM_TARGET(B134),
  1224. ENUM_TARGET(B150),
  1225. ENUM_TARGET(B200),
  1226. ENUM_TARGET(B300),
  1227. ENUM_TARGET(B600),
  1228. ENUM_TARGET(B1200),
  1229. ENUM_TARGET(B1800),
  1230. ENUM_TARGET(B2400),
  1231. ENUM_TARGET(B4800),
  1232. ENUM_TARGET(B9600),
  1233. ENUM_TARGET(B19200),
  1234. ENUM_TARGET(B38400),
  1235. ENUM_TARGET(B57600),
  1236. ENUM_TARGET(B115200),
  1237. ENUM_TARGET(B230400),
  1238. ENUM_TARGET(B460800),
  1239. ENUM_END,
  1240. };
  1241. UNUSED static struct enums termios_cflags_CSIZE[] = {
  1242. ENUM_TARGET(CS5),
  1243. ENUM_TARGET(CS6),
  1244. ENUM_TARGET(CS7),
  1245. ENUM_TARGET(CS8),
  1246. ENUM_END,
  1247. };
  1248. UNUSED static struct flags termios_cflags[] = {
  1249. FLAG_TARGET(CSTOPB),
  1250. FLAG_TARGET(CREAD),
  1251. FLAG_TARGET(PARENB),
  1252. FLAG_TARGET(PARODD),
  1253. FLAG_TARGET(HUPCL),
  1254. FLAG_TARGET(CLOCAL),
  1255. FLAG_TARGET(CRTSCTS),
  1256. FLAG_END,
  1257. };
  1258. UNUSED static struct flags termios_lflags[] = {
  1259. FLAG_TARGET(ISIG),
  1260. FLAG_TARGET(ICANON),
  1261. FLAG_TARGET(XCASE),
  1262. FLAG_TARGET(ECHO),
  1263. FLAG_TARGET(ECHOE),
  1264. FLAG_TARGET(ECHOK),
  1265. FLAG_TARGET(ECHONL),
  1266. FLAG_TARGET(NOFLSH),
  1267. FLAG_TARGET(TOSTOP),
  1268. FLAG_TARGET(ECHOCTL),
  1269. FLAG_TARGET(ECHOPRT),
  1270. FLAG_TARGET(ECHOKE),
  1271. FLAG_TARGET(FLUSHO),
  1272. FLAG_TARGET(PENDIN),
  1273. FLAG_TARGET(IEXTEN),
  1274. FLAG_TARGET(EXTPROC),
  1275. FLAG_END,
  1276. };
  1277. UNUSED static struct flags mlockall_flags[] = {
  1278. FLAG_TARGET(MCL_CURRENT),
  1279. FLAG_TARGET(MCL_FUTURE),
  1280. #ifdef MCL_ONFAULT
  1281. FLAG_TARGET(MCL_ONFAULT),
  1282. #endif
  1283. FLAG_END,
  1284. };
  1285. /* IDs of the various system clocks */
  1286. #define TARGET_CLOCK_REALTIME 0
  1287. #define TARGET_CLOCK_MONOTONIC 1
  1288. #define TARGET_CLOCK_PROCESS_CPUTIME_ID 2
  1289. #define TARGET_CLOCK_THREAD_CPUTIME_ID 3
  1290. #define TARGET_CLOCK_MONOTONIC_RAW 4
  1291. #define TARGET_CLOCK_REALTIME_COARSE 5
  1292. #define TARGET_CLOCK_MONOTONIC_COARSE 6
  1293. #define TARGET_CLOCK_BOOTTIME 7
  1294. #define TARGET_CLOCK_REALTIME_ALARM 8
  1295. #define TARGET_CLOCK_BOOTTIME_ALARM 9
  1296. #define TARGET_CLOCK_SGI_CYCLE 10
  1297. #define TARGET_CLOCK_TAI 11
  1298. UNUSED static struct enums clockids[] = {
  1299. ENUM_TARGET(CLOCK_REALTIME),
  1300. ENUM_TARGET(CLOCK_MONOTONIC),
  1301. ENUM_TARGET(CLOCK_PROCESS_CPUTIME_ID),
  1302. ENUM_TARGET(CLOCK_THREAD_CPUTIME_ID),
  1303. ENUM_TARGET(CLOCK_MONOTONIC_RAW),
  1304. ENUM_TARGET(CLOCK_REALTIME_COARSE),
  1305. ENUM_TARGET(CLOCK_MONOTONIC_COARSE),
  1306. ENUM_TARGET(CLOCK_BOOTTIME),
  1307. ENUM_TARGET(CLOCK_REALTIME_ALARM),
  1308. ENUM_TARGET(CLOCK_BOOTTIME_ALARM),
  1309. ENUM_TARGET(CLOCK_SGI_CYCLE),
  1310. ENUM_TARGET(CLOCK_TAI),
  1311. ENUM_END,
  1312. };
  1313. UNUSED static struct enums itimer_types[] = {
  1314. ENUM_GENERIC(ITIMER_REAL),
  1315. ENUM_GENERIC(ITIMER_VIRTUAL),
  1316. ENUM_GENERIC(ITIMER_PROF),
  1317. ENUM_END,
  1318. };
  1319. /*
  1320. * print_xxx utility functions. These are used to print syscall
  1321. * parameters in certain format. All of these have parameter
  1322. * named 'last'. This parameter is used to add comma to output
  1323. * when last == 0.
  1324. */
  1325. static const char *
  1326. get_comma(int last)
  1327. {
  1328. return ((last) ? "" : ",");
  1329. }
  1330. static void
  1331. print_flags(const struct flags *f, abi_long flags, int last)
  1332. {
  1333. const char *sep = "";
  1334. int n;
  1335. if ((flags == 0) && (f->f_value == 0)) {
  1336. qemu_log("%s%s", f->f_string, get_comma(last));
  1337. return;
  1338. }
  1339. for (n = 0; f->f_string != NULL; f++) {
  1340. if ((f->f_value != 0) && ((flags & f->f_value) == f->f_value)) {
  1341. qemu_log("%s%s", sep, f->f_string);
  1342. flags &= ~f->f_value;
  1343. sep = "|";
  1344. n++;
  1345. }
  1346. }
  1347. if (n > 0) {
  1348. /* print rest of the flags as numeric */
  1349. if (flags != 0) {
  1350. qemu_log("%s%#x%s", sep, (unsigned int)flags, get_comma(last));
  1351. } else {
  1352. qemu_log("%s", get_comma(last));
  1353. }
  1354. } else {
  1355. /* no string version of flags found, print them in hex then */
  1356. qemu_log("%#x%s", (unsigned int)flags, get_comma(last));
  1357. }
  1358. }
  1359. static void
  1360. print_enums(const struct enums *e, abi_long enum_arg, int last)
  1361. {
  1362. for (; e->e_string != NULL; e++) {
  1363. if (e->e_value == enum_arg) {
  1364. qemu_log("%s", e->e_string);
  1365. break;
  1366. }
  1367. }
  1368. if (e->e_string == NULL) {
  1369. qemu_log("%#x", (unsigned int)enum_arg);
  1370. }
  1371. qemu_log("%s", get_comma(last));
  1372. }
  1373. static void
  1374. print_at_dirfd(abi_long dirfd, int last)
  1375. {
  1376. #ifdef AT_FDCWD
  1377. if (dirfd == AT_FDCWD) {
  1378. qemu_log("AT_FDCWD%s", get_comma(last));
  1379. return;
  1380. }
  1381. #endif
  1382. qemu_log("%d%s", (int)dirfd, get_comma(last));
  1383. }
  1384. static void
  1385. print_file_mode(abi_long mode, int last)
  1386. {
  1387. const char *sep = "";
  1388. const struct flags *m;
  1389. if (mode == 0) {
  1390. qemu_log("000%s", get_comma(last));
  1391. return;
  1392. }
  1393. for (m = &mode_flags[0]; m->f_string != NULL; m++) {
  1394. if ((m->f_value & mode) == m->f_value) {
  1395. qemu_log("%s%s", m->f_string, sep);
  1396. sep = "|";
  1397. mode &= ~m->f_value;
  1398. break;
  1399. }
  1400. }
  1401. mode &= ~S_IFMT;
  1402. /* print rest of the mode as octal */
  1403. if (mode != 0)
  1404. qemu_log("%s%#o", sep, (unsigned int)mode);
  1405. qemu_log("%s", get_comma(last));
  1406. }
  1407. static void
  1408. print_open_flags(abi_long flags, int last)
  1409. {
  1410. print_flags(open_access_flags, flags & TARGET_O_ACCMODE, 1);
  1411. flags &= ~TARGET_O_ACCMODE;
  1412. if (flags == 0) {
  1413. qemu_log("%s", get_comma(last));
  1414. return;
  1415. }
  1416. qemu_log("|");
  1417. print_flags(open_flags, flags, last);
  1418. }
  1419. static void
  1420. print_syscall_prologue(const struct syscallname *sc)
  1421. {
  1422. qemu_log("%s(", sc->name);
  1423. }
  1424. /*ARGSUSED*/
  1425. static void
  1426. print_syscall_epilogue(const struct syscallname *sc)
  1427. {
  1428. (void)sc;
  1429. qemu_log(")");
  1430. }
  1431. static void
  1432. print_string(abi_long addr, int last)
  1433. {
  1434. char *s;
  1435. if ((s = lock_user_string(addr)) != NULL) {
  1436. qemu_log("\"%s\"%s", s, get_comma(last));
  1437. unlock_user(s, addr, 0);
  1438. } else {
  1439. /* can't get string out of it, so print it as pointer */
  1440. print_pointer(addr, last);
  1441. }
  1442. }
  1443. #define MAX_PRINT_BUF 40
  1444. static void
  1445. print_buf(abi_long addr, abi_long len, int last)
  1446. {
  1447. uint8_t *s;
  1448. int i;
  1449. s = lock_user(VERIFY_READ, addr, len, 1);
  1450. if (s) {
  1451. qemu_log("\"");
  1452. for (i = 0; i < MAX_PRINT_BUF && i < len; i++) {
  1453. if (isprint(s[i])) {
  1454. qemu_log("%c", s[i]);
  1455. } else {
  1456. qemu_log("\\%o", s[i]);
  1457. }
  1458. }
  1459. qemu_log("\"");
  1460. if (i != len) {
  1461. qemu_log("...");
  1462. }
  1463. if (!last) {
  1464. qemu_log(",");
  1465. }
  1466. unlock_user(s, addr, 0);
  1467. } else {
  1468. print_pointer(addr, last);
  1469. }
  1470. }
  1471. /*
  1472. * Prints out raw parameter using given format. Caller needs
  1473. * to do byte swapping if needed.
  1474. */
  1475. static void
  1476. print_raw_param(const char *fmt, abi_long param, int last)
  1477. {
  1478. char format[64];
  1479. (void) snprintf(format, sizeof (format), "%s%s", fmt, get_comma(last));
  1480. qemu_log(format, param);
  1481. }
  1482. static void
  1483. print_pointer(abi_long p, int last)
  1484. {
  1485. if (p == 0)
  1486. qemu_log("NULL%s", get_comma(last));
  1487. else
  1488. qemu_log("0x" TARGET_ABI_FMT_lx "%s", p, get_comma(last));
  1489. }
  1490. /*
  1491. * Reads 32-bit (int) number from guest address space from
  1492. * address 'addr' and prints it.
  1493. */
  1494. static void
  1495. print_number(abi_long addr, int last)
  1496. {
  1497. if (addr == 0) {
  1498. qemu_log("NULL%s", get_comma(last));
  1499. } else {
  1500. int num;
  1501. get_user_s32(num, addr);
  1502. qemu_log("[%d]%s", num, get_comma(last));
  1503. }
  1504. }
  1505. static void
  1506. print_timeval(abi_ulong tv_addr, int last)
  1507. {
  1508. if( tv_addr ) {
  1509. struct target_timeval *tv;
  1510. tv = lock_user(VERIFY_READ, tv_addr, sizeof(*tv), 1);
  1511. if (!tv) {
  1512. print_pointer(tv_addr, last);
  1513. return;
  1514. }
  1515. qemu_log("{tv_sec = " TARGET_ABI_FMT_ld
  1516. ",tv_usec = " TARGET_ABI_FMT_ld "}%s",
  1517. tswapal(tv->tv_sec), tswapal(tv->tv_usec), get_comma(last));
  1518. unlock_user(tv, tv_addr, 0);
  1519. } else
  1520. qemu_log("NULL%s", get_comma(last));
  1521. }
  1522. static void
  1523. print_timespec(abi_ulong ts_addr, int last)
  1524. {
  1525. if (ts_addr) {
  1526. struct target_timespec *ts;
  1527. ts = lock_user(VERIFY_READ, ts_addr, sizeof(*ts), 1);
  1528. if (!ts) {
  1529. print_pointer(ts_addr, last);
  1530. return;
  1531. }
  1532. qemu_log("{tv_sec = " TARGET_ABI_FMT_ld
  1533. ",tv_nsec = " TARGET_ABI_FMT_ld "}%s",
  1534. tswapal(ts->tv_sec), tswapal(ts->tv_nsec), get_comma(last));
  1535. unlock_user(ts, ts_addr, 0);
  1536. } else {
  1537. qemu_log("NULL%s", get_comma(last));
  1538. }
  1539. }
  1540. static void
  1541. print_timespec64(abi_ulong ts_addr, int last)
  1542. {
  1543. if (ts_addr) {
  1544. struct target__kernel_timespec *ts;
  1545. ts = lock_user(VERIFY_READ, ts_addr, sizeof(*ts), 1);
  1546. if (!ts) {
  1547. print_pointer(ts_addr, last);
  1548. return;
  1549. }
  1550. qemu_log("{tv_sec = %lld"
  1551. ",tv_nsec = %lld}%s",
  1552. (long long)tswap64(ts->tv_sec), (long long)tswap64(ts->tv_nsec),
  1553. get_comma(last));
  1554. unlock_user(ts, ts_addr, 0);
  1555. } else {
  1556. qemu_log("NULL%s", get_comma(last));
  1557. }
  1558. }
  1559. static void
  1560. print_timezone(abi_ulong tz_addr, int last)
  1561. {
  1562. if (tz_addr) {
  1563. struct target_timezone *tz;
  1564. tz = lock_user(VERIFY_READ, tz_addr, sizeof(*tz), 1);
  1565. if (!tz) {
  1566. print_pointer(tz_addr, last);
  1567. return;
  1568. }
  1569. qemu_log("{%d,%d}%s", tswap32(tz->tz_minuteswest),
  1570. tswap32(tz->tz_dsttime), get_comma(last));
  1571. unlock_user(tz, tz_addr, 0);
  1572. } else {
  1573. qemu_log("NULL%s", get_comma(last));
  1574. }
  1575. }
  1576. static void
  1577. print_itimerval(abi_ulong it_addr, int last)
  1578. {
  1579. if (it_addr) {
  1580. qemu_log("{it_interval=");
  1581. print_timeval(it_addr +
  1582. offsetof(struct target_itimerval, it_interval), 0);
  1583. qemu_log("it_value=");
  1584. print_timeval(it_addr +
  1585. offsetof(struct target_itimerval, it_value), 0);
  1586. qemu_log("}%s", get_comma(last));
  1587. } else {
  1588. qemu_log("NULL%s", get_comma(last));
  1589. }
  1590. }
  1591. void
  1592. print_termios(void *arg)
  1593. {
  1594. const struct target_termios *target = arg;
  1595. target_tcflag_t iflags = tswap32(target->c_iflag);
  1596. target_tcflag_t oflags = tswap32(target->c_oflag);
  1597. target_tcflag_t cflags = tswap32(target->c_cflag);
  1598. target_tcflag_t lflags = tswap32(target->c_lflag);
  1599. qemu_log("{");
  1600. qemu_log("c_iflag = ");
  1601. print_flags(termios_iflags, iflags, 0);
  1602. qemu_log("c_oflag = ");
  1603. target_tcflag_t oflags_clean = oflags & ~(TARGET_NLDLY | TARGET_CRDLY |
  1604. TARGET_TABDLY | TARGET_BSDLY |
  1605. TARGET_VTDLY | TARGET_FFDLY);
  1606. print_flags(termios_oflags, oflags_clean, 0);
  1607. if (oflags & TARGET_NLDLY) {
  1608. print_enums(termios_oflags_NLDLY, oflags & TARGET_NLDLY, 0);
  1609. }
  1610. if (oflags & TARGET_CRDLY) {
  1611. print_enums(termios_oflags_CRDLY, oflags & TARGET_CRDLY, 0);
  1612. }
  1613. if (oflags & TARGET_TABDLY) {
  1614. print_enums(termios_oflags_TABDLY, oflags & TARGET_TABDLY, 0);
  1615. }
  1616. if (oflags & TARGET_BSDLY) {
  1617. print_enums(termios_oflags_BSDLY, oflags & TARGET_BSDLY, 0);
  1618. }
  1619. if (oflags & TARGET_VTDLY) {
  1620. print_enums(termios_oflags_VTDLY, oflags & TARGET_VTDLY, 0);
  1621. }
  1622. if (oflags & TARGET_FFDLY) {
  1623. print_enums(termios_oflags_FFDLY, oflags & TARGET_FFDLY, 0);
  1624. }
  1625. qemu_log("c_cflag = ");
  1626. if (cflags & TARGET_CBAUD) {
  1627. print_enums(termios_cflags_CBAUD, cflags & TARGET_CBAUD, 0);
  1628. }
  1629. if (cflags & TARGET_CSIZE) {
  1630. print_enums(termios_cflags_CSIZE, cflags & TARGET_CSIZE, 0);
  1631. }
  1632. target_tcflag_t cflags_clean = cflags & ~(TARGET_CBAUD | TARGET_CSIZE);
  1633. print_flags(termios_cflags, cflags_clean, 0);
  1634. qemu_log("c_lflag = ");
  1635. print_flags(termios_lflags, lflags, 0);
  1636. qemu_log("c_cc = ");
  1637. qemu_log("\"%s\",", target->c_cc);
  1638. qemu_log("c_line = ");
  1639. print_raw_param("\'%c\'", target->c_line, 1);
  1640. qemu_log("}");
  1641. }
  1642. #undef UNUSED
  1643. #ifdef TARGET_NR_accept
  1644. static void
  1645. print_accept(CPUArchState *cpu_env, const struct syscallname *name,
  1646. abi_long arg0, abi_long arg1, abi_long arg2,
  1647. abi_long arg3, abi_long arg4, abi_long arg5)
  1648. {
  1649. print_syscall_prologue(name);
  1650. print_raw_param("%d", arg0, 0);
  1651. print_pointer(arg1, 0);
  1652. print_number(arg2, 1);
  1653. print_syscall_epilogue(name);
  1654. }
  1655. #endif
  1656. #ifdef TARGET_NR_access
  1657. static void
  1658. print_access(CPUArchState *cpu_env, const struct syscallname *name,
  1659. abi_long arg0, abi_long arg1, abi_long arg2,
  1660. abi_long arg3, abi_long arg4, abi_long arg5)
  1661. {
  1662. print_syscall_prologue(name);
  1663. print_string(arg0, 0);
  1664. print_flags(access_flags, arg1, 1);
  1665. print_syscall_epilogue(name);
  1666. }
  1667. #endif
  1668. #ifdef TARGET_NR_acct
  1669. static void
  1670. print_acct(CPUArchState *cpu_env, const struct syscallname *name,
  1671. abi_long arg0, abi_long arg1, abi_long arg2,
  1672. abi_long arg3, abi_long arg4, abi_long arg5)
  1673. {
  1674. print_syscall_prologue(name);
  1675. print_string(arg0, 1);
  1676. print_syscall_epilogue(name);
  1677. }
  1678. #endif
  1679. #ifdef TARGET_NR_brk
  1680. static void
  1681. print_brk(CPUArchState *cpu_env, const struct syscallname *name,
  1682. abi_long arg0, abi_long arg1, abi_long arg2,
  1683. abi_long arg3, abi_long arg4, abi_long arg5)
  1684. {
  1685. print_syscall_prologue(name);
  1686. print_pointer(arg0, 1);
  1687. print_syscall_epilogue(name);
  1688. }
  1689. #endif
  1690. #ifdef TARGET_NR_chdir
  1691. static void
  1692. print_chdir(CPUArchState *cpu_env, const struct syscallname *name,
  1693. abi_long arg0, abi_long arg1, abi_long arg2,
  1694. abi_long arg3, abi_long arg4, abi_long arg5)
  1695. {
  1696. print_syscall_prologue(name);
  1697. print_string(arg0, 1);
  1698. print_syscall_epilogue(name);
  1699. }
  1700. #endif
  1701. #ifdef TARGET_NR_chroot
  1702. static void
  1703. print_chroot(CPUArchState *cpu_env, const struct syscallname *name,
  1704. abi_long arg0, abi_long arg1, abi_long arg2,
  1705. abi_long arg3, abi_long arg4, abi_long arg5)
  1706. {
  1707. print_syscall_prologue(name);
  1708. print_string(arg0, 1);
  1709. print_syscall_epilogue(name);
  1710. }
  1711. #endif
  1712. #ifdef TARGET_NR_chmod
  1713. static void
  1714. print_chmod(CPUArchState *cpu_env, const struct syscallname *name,
  1715. abi_long arg0, abi_long arg1, abi_long arg2,
  1716. abi_long arg3, abi_long arg4, abi_long arg5)
  1717. {
  1718. print_syscall_prologue(name);
  1719. print_string(arg0, 0);
  1720. print_file_mode(arg1, 1);
  1721. print_syscall_epilogue(name);
  1722. }
  1723. #endif
  1724. #if defined(TARGET_NR_chown) || defined(TARGET_NR_lchown)
  1725. static void
  1726. print_chown(CPUArchState *cpu_env, const struct syscallname *name,
  1727. abi_long arg0, abi_long arg1, abi_long arg2,
  1728. abi_long arg3, abi_long arg4, abi_long arg5)
  1729. {
  1730. print_syscall_prologue(name);
  1731. print_string(arg0, 0);
  1732. print_raw_param("%d", arg1, 0);
  1733. print_raw_param("%d", arg2, 1);
  1734. print_syscall_epilogue(name);
  1735. }
  1736. #define print_lchown print_chown
  1737. #endif
  1738. #ifdef TARGET_NR_clock_adjtime
  1739. static void
  1740. print_clock_adjtime(CPUArchState *cpu_env, const struct syscallname *name,
  1741. abi_long arg0, abi_long arg1, abi_long arg2,
  1742. abi_long arg3, abi_long arg4, abi_long arg5)
  1743. {
  1744. print_syscall_prologue(name);
  1745. print_enums(clockids, arg0, 0);
  1746. print_pointer(arg1, 1);
  1747. print_syscall_epilogue(name);
  1748. }
  1749. #endif
  1750. #ifdef TARGET_NR_clone
  1751. static void do_print_clone(unsigned int flags, abi_ulong newsp,
  1752. abi_ulong parent_tidptr, target_ulong newtls,
  1753. abi_ulong child_tidptr)
  1754. {
  1755. print_flags(clone_flags, flags, 0);
  1756. print_raw_param("child_stack=0x" TARGET_ABI_FMT_lx, newsp, 0);
  1757. print_raw_param("parent_tidptr=0x" TARGET_ABI_FMT_lx, parent_tidptr, 0);
  1758. print_raw_param("tls=0x" TARGET_ABI_FMT_lx, newtls, 0);
  1759. print_raw_param("child_tidptr=0x" TARGET_ABI_FMT_lx, child_tidptr, 1);
  1760. }
  1761. static void
  1762. print_clone(CPUArchState *cpu_env, const struct syscallname *name,
  1763. abi_long arg1, abi_long arg2, abi_long arg3,
  1764. abi_long arg4, abi_long arg5, abi_long arg6)
  1765. {
  1766. print_syscall_prologue(name);
  1767. #if defined(TARGET_MICROBLAZE)
  1768. do_print_clone(arg1, arg2, arg4, arg6, arg5);
  1769. #elif defined(TARGET_CLONE_BACKWARDS)
  1770. do_print_clone(arg1, arg2, arg3, arg4, arg5);
  1771. #elif defined(TARGET_CLONE_BACKWARDS2)
  1772. do_print_clone(arg2, arg1, arg3, arg5, arg4);
  1773. #else
  1774. do_print_clone(arg1, arg2, arg3, arg5, arg4);
  1775. #endif
  1776. print_syscall_epilogue(name);
  1777. }
  1778. #endif
  1779. #ifdef TARGET_NR_creat
  1780. static void
  1781. print_creat(CPUArchState *cpu_env, const struct syscallname *name,
  1782. abi_long arg0, abi_long arg1, abi_long arg2,
  1783. abi_long arg3, abi_long arg4, abi_long arg5)
  1784. {
  1785. print_syscall_prologue(name);
  1786. print_string(arg0, 0);
  1787. print_file_mode(arg1, 1);
  1788. print_syscall_epilogue(name);
  1789. }
  1790. #endif
  1791. #ifdef TARGET_NR_execv
  1792. static void
  1793. print_execv(CPUArchState *cpu_env, const struct syscallname *name,
  1794. abi_long arg0, abi_long arg1, abi_long arg2,
  1795. abi_long arg3, abi_long arg4, abi_long arg5)
  1796. {
  1797. print_syscall_prologue(name);
  1798. print_string(arg0, 0);
  1799. print_raw_param("0x" TARGET_ABI_FMT_lx, arg1, 1);
  1800. print_syscall_epilogue(name);
  1801. }
  1802. #endif
  1803. #if defined(TARGET_NR_faccessat) || defined(TARGET_NR_faccessat2)
  1804. static void
  1805. print_faccessat(CPUArchState *cpu_env, const struct syscallname *name,
  1806. abi_long arg0, abi_long arg1, abi_long arg2,
  1807. abi_long arg3, abi_long arg4, abi_long arg5)
  1808. {
  1809. print_syscall_prologue(name);
  1810. print_at_dirfd(arg0, 0);
  1811. print_string(arg1, 0);
  1812. print_flags(access_flags, arg2, 0);
  1813. print_flags(at_file_flags, arg3, 1);
  1814. print_syscall_epilogue(name);
  1815. }
  1816. #endif
  1817. #ifdef TARGET_NR_fallocate
  1818. static void
  1819. print_fallocate(CPUArchState *cpu_env, const struct syscallname *name,
  1820. abi_long arg0, abi_long arg1, abi_long arg2,
  1821. abi_long arg3, abi_long arg4, abi_long arg5)
  1822. {
  1823. print_syscall_prologue(name);
  1824. print_raw_param("%d", arg0, 0);
  1825. print_flags(falloc_flags, arg1, 0);
  1826. #if TARGET_ABI_BITS == 32
  1827. print_raw_param("%" PRIu64, target_offset64(arg2, arg3), 0);
  1828. print_raw_param("%" PRIu64, target_offset64(arg4, arg5), 1);
  1829. #else
  1830. print_raw_param(TARGET_ABI_FMT_ld, arg2, 0);
  1831. print_raw_param(TARGET_ABI_FMT_ld, arg3, 1);
  1832. #endif
  1833. print_syscall_epilogue(name);
  1834. }
  1835. #endif
  1836. #ifdef TARGET_NR_fchmodat
  1837. static void
  1838. print_fchmodat(CPUArchState *cpu_env, const struct syscallname *name,
  1839. abi_long arg0, abi_long arg1, abi_long arg2,
  1840. abi_long arg3, abi_long arg4, abi_long arg5)
  1841. {
  1842. print_syscall_prologue(name);
  1843. print_at_dirfd(arg0, 0);
  1844. print_string(arg1, 0);
  1845. print_file_mode(arg2, 0);
  1846. print_flags(at_file_flags, arg3, 1);
  1847. print_syscall_epilogue(name);
  1848. }
  1849. #endif
  1850. #ifdef TARGET_NR_fchownat
  1851. static void
  1852. print_fchownat(CPUArchState *cpu_env, const struct syscallname *name,
  1853. abi_long arg0, abi_long arg1, abi_long arg2,
  1854. abi_long arg3, abi_long arg4, abi_long arg5)
  1855. {
  1856. print_syscall_prologue(name);
  1857. print_at_dirfd(arg0, 0);
  1858. print_string(arg1, 0);
  1859. print_raw_param("%d", arg2, 0);
  1860. print_raw_param("%d", arg3, 0);
  1861. print_flags(at_file_flags, arg4, 1);
  1862. print_syscall_epilogue(name);
  1863. }
  1864. #endif
  1865. #if defined(TARGET_NR_fcntl) || defined(TARGET_NR_fcntl64)
  1866. static void
  1867. print_fcntl(CPUArchState *cpu_env, const struct syscallname *name,
  1868. abi_long arg0, abi_long arg1, abi_long arg2,
  1869. abi_long arg3, abi_long arg4, abi_long arg5)
  1870. {
  1871. print_syscall_prologue(name);
  1872. print_raw_param("%d", arg0, 0);
  1873. switch(arg1) {
  1874. case TARGET_F_DUPFD:
  1875. qemu_log("F_DUPFD,");
  1876. print_raw_param(TARGET_ABI_FMT_ld, arg2, 1);
  1877. break;
  1878. case TARGET_F_GETFD:
  1879. qemu_log("F_GETFD");
  1880. break;
  1881. case TARGET_F_SETFD:
  1882. qemu_log("F_SETFD,");
  1883. print_raw_param(TARGET_ABI_FMT_ld, arg2, 1);
  1884. break;
  1885. case TARGET_F_GETFL:
  1886. qemu_log("F_GETFL");
  1887. break;
  1888. case TARGET_F_SETFL:
  1889. qemu_log("F_SETFL,");
  1890. print_open_flags(arg2, 1);
  1891. break;
  1892. case TARGET_F_GETLK:
  1893. qemu_log("F_GETLK,");
  1894. print_pointer(arg2, 1);
  1895. break;
  1896. case TARGET_F_SETLK:
  1897. qemu_log("F_SETLK,");
  1898. print_pointer(arg2, 1);
  1899. break;
  1900. case TARGET_F_SETLKW:
  1901. qemu_log("F_SETLKW,");
  1902. print_pointer(arg2, 1);
  1903. break;
  1904. case TARGET_F_GETOWN:
  1905. qemu_log("F_GETOWN");
  1906. break;
  1907. case TARGET_F_SETOWN:
  1908. qemu_log("F_SETOWN,");
  1909. print_raw_param(TARGET_ABI_FMT_ld, arg2, 0);
  1910. break;
  1911. case TARGET_F_GETSIG:
  1912. qemu_log("F_GETSIG");
  1913. break;
  1914. case TARGET_F_SETSIG:
  1915. qemu_log("F_SETSIG,");
  1916. print_raw_param(TARGET_ABI_FMT_ld, arg2, 0);
  1917. break;
  1918. #if TARGET_ABI_BITS == 32
  1919. case TARGET_F_GETLK64:
  1920. qemu_log("F_GETLK64,");
  1921. print_pointer(arg2, 1);
  1922. break;
  1923. case TARGET_F_SETLK64:
  1924. qemu_log("F_SETLK64,");
  1925. print_pointer(arg2, 1);
  1926. break;
  1927. case TARGET_F_SETLKW64:
  1928. qemu_log("F_SETLKW64,");
  1929. print_pointer(arg2, 1);
  1930. break;
  1931. #endif
  1932. case TARGET_F_OFD_GETLK:
  1933. qemu_log("F_OFD_GETLK,");
  1934. print_pointer(arg2, 1);
  1935. break;
  1936. case TARGET_F_OFD_SETLK:
  1937. qemu_log("F_OFD_SETLK,");
  1938. print_pointer(arg2, 1);
  1939. break;
  1940. case TARGET_F_OFD_SETLKW:
  1941. qemu_log("F_OFD_SETLKW,");
  1942. print_pointer(arg2, 1);
  1943. break;
  1944. case TARGET_F_SETLEASE:
  1945. qemu_log("F_SETLEASE,");
  1946. print_raw_param(TARGET_ABI_FMT_ld, arg2, 1);
  1947. break;
  1948. case TARGET_F_GETLEASE:
  1949. qemu_log("F_GETLEASE");
  1950. break;
  1951. #ifdef F_DUPFD_CLOEXEC
  1952. case TARGET_F_DUPFD_CLOEXEC:
  1953. qemu_log("F_DUPFD_CLOEXEC,");
  1954. print_raw_param(TARGET_ABI_FMT_ld, arg2, 1);
  1955. break;
  1956. #endif
  1957. case TARGET_F_NOTIFY:
  1958. qemu_log("F_NOTIFY,");
  1959. print_raw_param(TARGET_ABI_FMT_ld, arg2, 1);
  1960. break;
  1961. #ifdef F_GETOWN_EX
  1962. case TARGET_F_GETOWN_EX:
  1963. qemu_log("F_GETOWN_EX,");
  1964. print_pointer(arg2, 1);
  1965. break;
  1966. #endif
  1967. #ifdef F_SETOWN_EX
  1968. case TARGET_F_SETOWN_EX:
  1969. qemu_log("F_SETOWN_EX,");
  1970. print_pointer(arg2, 1);
  1971. break;
  1972. #endif
  1973. #ifdef F_SETPIPE_SZ
  1974. case TARGET_F_SETPIPE_SZ:
  1975. qemu_log("F_SETPIPE_SZ,");
  1976. print_raw_param(TARGET_ABI_FMT_ld, arg2, 1);
  1977. break;
  1978. case TARGET_F_GETPIPE_SZ:
  1979. qemu_log("F_GETPIPE_SZ");
  1980. break;
  1981. #endif
  1982. #ifdef F_ADD_SEALS
  1983. case TARGET_F_ADD_SEALS:
  1984. qemu_log("F_ADD_SEALS,");
  1985. print_raw_param("0x"TARGET_ABI_FMT_lx, arg2, 1);
  1986. break;
  1987. case TARGET_F_GET_SEALS:
  1988. qemu_log("F_GET_SEALS");
  1989. break;
  1990. #endif
  1991. default:
  1992. print_raw_param(TARGET_ABI_FMT_ld, arg1, 0);
  1993. print_pointer(arg2, 1);
  1994. break;
  1995. }
  1996. print_syscall_epilogue(name);
  1997. }
  1998. #define print_fcntl64 print_fcntl
  1999. #endif
  2000. #ifdef TARGET_NR_fgetxattr
  2001. static void
  2002. print_fgetxattr(CPUArchState *cpu_env, const struct syscallname *name,
  2003. abi_long arg0, abi_long arg1, abi_long arg2,
  2004. abi_long arg3, abi_long arg4, abi_long arg5)
  2005. {
  2006. print_syscall_prologue(name);
  2007. print_raw_param("%d", arg0, 0);
  2008. print_string(arg1, 0);
  2009. print_pointer(arg2, 0);
  2010. print_raw_param(TARGET_FMT_lu, arg3, 1);
  2011. print_syscall_epilogue(name);
  2012. }
  2013. #endif
  2014. #ifdef TARGET_NR_flistxattr
  2015. static void
  2016. print_flistxattr(CPUArchState *cpu_env, const struct syscallname *name,
  2017. abi_long arg0, abi_long arg1, abi_long arg2,
  2018. abi_long arg3, abi_long arg4, abi_long arg5)
  2019. {
  2020. print_syscall_prologue(name);
  2021. print_raw_param("%d", arg0, 0);
  2022. print_pointer(arg1, 0);
  2023. print_raw_param(TARGET_FMT_lu, arg2, 1);
  2024. print_syscall_epilogue(name);
  2025. }
  2026. #endif
  2027. #if defined(TARGET_NR_getxattr) || defined(TARGET_NR_lgetxattr)
  2028. static void
  2029. print_getxattr(CPUArchState *cpu_env, const struct syscallname *name,
  2030. abi_long arg0, abi_long arg1, abi_long arg2,
  2031. abi_long arg3, abi_long arg4, abi_long arg5)
  2032. {
  2033. print_syscall_prologue(name);
  2034. print_string(arg0, 0);
  2035. print_string(arg1, 0);
  2036. print_pointer(arg2, 0);
  2037. print_raw_param(TARGET_FMT_lu, arg3, 1);
  2038. print_syscall_epilogue(name);
  2039. }
  2040. #define print_lgetxattr print_getxattr
  2041. #endif
  2042. #if defined(TARGET_NR_listxattr) || defined(TARGET_NR_llistxattr)
  2043. static void
  2044. print_listxattr(CPUArchState *cpu_env, const struct syscallname *name,
  2045. abi_long arg0, abi_long arg1, abi_long arg2,
  2046. abi_long arg3, abi_long arg4, abi_long arg5)
  2047. {
  2048. print_syscall_prologue(name);
  2049. print_string(arg0, 0);
  2050. print_pointer(arg1, 0);
  2051. print_raw_param(TARGET_FMT_lu, arg2, 1);
  2052. print_syscall_epilogue(name);
  2053. }
  2054. #define print_llistxattr print_listxattr
  2055. #endif
  2056. #if defined(TARGET_NR_fremovexattr)
  2057. static void
  2058. print_fremovexattr(CPUArchState *cpu_env, const struct syscallname *name,
  2059. abi_long arg0, abi_long arg1, abi_long arg2,
  2060. abi_long arg3, abi_long arg4, abi_long arg5)
  2061. {
  2062. print_syscall_prologue(name);
  2063. print_raw_param("%d", arg0, 0);
  2064. print_string(arg1, 1);
  2065. print_syscall_epilogue(name);
  2066. }
  2067. #endif
  2068. #if defined(TARGET_NR_removexattr) || defined(TARGET_NR_lremovexattr)
  2069. static void
  2070. print_removexattr(CPUArchState *cpu_env, const struct syscallname *name,
  2071. abi_long arg0, abi_long arg1, abi_long arg2,
  2072. abi_long arg3, abi_long arg4, abi_long arg5)
  2073. {
  2074. print_syscall_prologue(name);
  2075. print_string(arg0, 0);
  2076. print_string(arg1, 1);
  2077. print_syscall_epilogue(name);
  2078. }
  2079. #define print_lremovexattr print_removexattr
  2080. #endif
  2081. #ifdef TARGET_NR_futimesat
  2082. static void
  2083. print_futimesat(CPUArchState *cpu_env, const struct syscallname *name,
  2084. abi_long arg0, abi_long arg1, abi_long arg2,
  2085. abi_long arg3, abi_long arg4, abi_long arg5)
  2086. {
  2087. print_syscall_prologue(name);
  2088. print_at_dirfd(arg0, 0);
  2089. print_string(arg1, 0);
  2090. print_timeval(arg2, 0);
  2091. print_timeval(arg2 + sizeof (struct target_timeval), 1);
  2092. print_syscall_epilogue(name);
  2093. }
  2094. #endif
  2095. #ifdef TARGET_NR_gettimeofday
  2096. static void
  2097. print_gettimeofday(CPUArchState *cpu_env, const struct syscallname *name,
  2098. abi_long arg0, abi_long arg1, abi_long arg2,
  2099. abi_long arg3, abi_long arg4, abi_long arg5)
  2100. {
  2101. print_syscall_prologue(name);
  2102. print_pointer(arg0, 0);
  2103. print_pointer(arg1, 1);
  2104. print_syscall_epilogue(name);
  2105. }
  2106. #endif
  2107. #ifdef TARGET_NR_settimeofday
  2108. static void
  2109. print_settimeofday(CPUArchState *cpu_env, const struct syscallname *name,
  2110. abi_long arg0, abi_long arg1, abi_long arg2,
  2111. abi_long arg3, abi_long arg4, abi_long arg5)
  2112. {
  2113. print_syscall_prologue(name);
  2114. print_timeval(arg0, 0);
  2115. print_timezone(arg1, 1);
  2116. print_syscall_epilogue(name);
  2117. }
  2118. #endif
  2119. #if defined(TARGET_NR_clock_gettime) || defined(TARGET_NR_clock_getres)
  2120. static void
  2121. print_clock_gettime(CPUArchState *cpu_env, const struct syscallname *name,
  2122. abi_long arg0, abi_long arg1, abi_long arg2,
  2123. abi_long arg3, abi_long arg4, abi_long arg5)
  2124. {
  2125. print_syscall_prologue(name);
  2126. print_enums(clockids, arg0, 0);
  2127. print_pointer(arg1, 1);
  2128. print_syscall_epilogue(name);
  2129. }
  2130. #define print_clock_getres print_clock_gettime
  2131. #endif
  2132. #if defined(TARGET_NR_clock_gettime64)
  2133. static void
  2134. print_clock_gettime64(CPUArchState *cpu_env, const struct syscallname *name,
  2135. abi_long arg0, abi_long arg1, abi_long arg2,
  2136. abi_long arg3, abi_long arg4, abi_long arg5)
  2137. {
  2138. print_syscall_prologue(name);
  2139. print_enums(clockids, arg0, 0);
  2140. print_pointer(arg1, 1);
  2141. print_syscall_epilogue(name);
  2142. }
  2143. #endif
  2144. #ifdef TARGET_NR_clock_settime
  2145. static void
  2146. print_clock_settime(CPUArchState *cpu_env, const struct syscallname *name,
  2147. abi_long arg0, abi_long arg1, abi_long arg2,
  2148. abi_long arg3, abi_long arg4, abi_long arg5)
  2149. {
  2150. print_syscall_prologue(name);
  2151. print_enums(clockids, arg0, 0);
  2152. print_timespec(arg1, 1);
  2153. print_syscall_epilogue(name);
  2154. }
  2155. #endif
  2156. #ifdef TARGET_NR_getitimer
  2157. static void
  2158. print_getitimer(CPUArchState *cpu_env, const struct syscallname *name,
  2159. abi_long arg0, abi_long arg1, abi_long arg2,
  2160. abi_long arg3, abi_long arg4, abi_long arg5)
  2161. {
  2162. print_syscall_prologue(name);
  2163. print_enums(itimer_types, arg0, 0);
  2164. print_pointer(arg1, 1);
  2165. print_syscall_epilogue(name);
  2166. }
  2167. #endif
  2168. #ifdef TARGET_NR_setitimer
  2169. static void
  2170. print_setitimer(CPUArchState *cpu_env, const struct syscallname *name,
  2171. abi_long arg0, abi_long arg1, abi_long arg2,
  2172. abi_long arg3, abi_long arg4, abi_long arg5)
  2173. {
  2174. print_syscall_prologue(name);
  2175. print_enums(itimer_types, arg0, 0);
  2176. print_itimerval(arg1, 0);
  2177. print_pointer(arg2, 1);
  2178. print_syscall_epilogue(name);
  2179. }
  2180. #endif
  2181. #ifdef TARGET_NR_link
  2182. static void
  2183. print_link(CPUArchState *cpu_env, const struct syscallname *name,
  2184. abi_long arg0, abi_long arg1, abi_long arg2,
  2185. abi_long arg3, abi_long arg4, abi_long arg5)
  2186. {
  2187. print_syscall_prologue(name);
  2188. print_string(arg0, 0);
  2189. print_string(arg1, 1);
  2190. print_syscall_epilogue(name);
  2191. }
  2192. #endif
  2193. #ifdef TARGET_NR_linkat
  2194. static void
  2195. print_linkat(CPUArchState *cpu_env, const struct syscallname *name,
  2196. abi_long arg0, abi_long arg1, abi_long arg2,
  2197. abi_long arg3, abi_long arg4, abi_long arg5)
  2198. {
  2199. print_syscall_prologue(name);
  2200. print_at_dirfd(arg0, 0);
  2201. print_string(arg1, 0);
  2202. print_at_dirfd(arg2, 0);
  2203. print_string(arg3, 0);
  2204. print_flags(at_file_flags, arg4, 1);
  2205. print_syscall_epilogue(name);
  2206. }
  2207. #endif
  2208. #if defined(TARGET_NR__llseek) || defined(TARGET_NR_llseek)
  2209. static void
  2210. print__llseek(CPUArchState *cpu_env, const struct syscallname *name,
  2211. abi_long arg0, abi_long arg1, abi_long arg2,
  2212. abi_long arg3, abi_long arg4, abi_long arg5)
  2213. {
  2214. const char *whence = "UNKNOWN";
  2215. print_syscall_prologue(name);
  2216. print_raw_param("%d", arg0, 0);
  2217. print_raw_param("%ld", arg1, 0);
  2218. print_raw_param("%ld", arg2, 0);
  2219. print_pointer(arg3, 0);
  2220. switch(arg4) {
  2221. case SEEK_SET: whence = "SEEK_SET"; break;
  2222. case SEEK_CUR: whence = "SEEK_CUR"; break;
  2223. case SEEK_END: whence = "SEEK_END"; break;
  2224. }
  2225. qemu_log("%s", whence);
  2226. print_syscall_epilogue(name);
  2227. }
  2228. #define print_llseek print__llseek
  2229. #endif
  2230. #ifdef TARGET_NR_lseek
  2231. static void
  2232. print_lseek(CPUArchState *cpu_env, const struct syscallname *name,
  2233. abi_long arg0, abi_long arg1, abi_long arg2,
  2234. abi_long arg3, abi_long arg4, abi_long arg5)
  2235. {
  2236. print_syscall_prologue(name);
  2237. print_raw_param("%d", arg0, 0);
  2238. print_raw_param(TARGET_ABI_FMT_ld, arg1, 0);
  2239. switch (arg2) {
  2240. case SEEK_SET:
  2241. qemu_log("SEEK_SET"); break;
  2242. case SEEK_CUR:
  2243. qemu_log("SEEK_CUR"); break;
  2244. case SEEK_END:
  2245. qemu_log("SEEK_END"); break;
  2246. #ifdef SEEK_DATA
  2247. case SEEK_DATA:
  2248. qemu_log("SEEK_DATA"); break;
  2249. #endif
  2250. #ifdef SEEK_HOLE
  2251. case SEEK_HOLE:
  2252. qemu_log("SEEK_HOLE"); break;
  2253. #endif
  2254. default:
  2255. print_raw_param("%#x", arg2, 1);
  2256. }
  2257. print_syscall_epilogue(name);
  2258. }
  2259. #endif
  2260. #ifdef TARGET_NR_truncate
  2261. static void
  2262. print_truncate(CPUArchState *cpu_env, const struct syscallname *name,
  2263. abi_long arg0, abi_long arg1, abi_long arg2,
  2264. abi_long arg3, abi_long arg4, abi_long arg5)
  2265. {
  2266. print_syscall_prologue(name);
  2267. print_string(arg0, 0);
  2268. print_raw_param(TARGET_ABI_FMT_ld, arg1, 1);
  2269. print_syscall_epilogue(name);
  2270. }
  2271. #endif
  2272. #ifdef TARGET_NR_truncate64
  2273. static void
  2274. print_truncate64(CPUArchState *cpu_env, const struct syscallname *name,
  2275. abi_long arg0, abi_long arg1, abi_long arg2,
  2276. abi_long arg3, abi_long arg4, abi_long arg5)
  2277. {
  2278. print_syscall_prologue(name);
  2279. print_string(arg0, 0);
  2280. if (regpairs_aligned(cpu_env, TARGET_NR_truncate64)) {
  2281. arg1 = arg2;
  2282. arg2 = arg3;
  2283. }
  2284. print_raw_param("%" PRIu64, target_offset64(arg1, arg2), 1);
  2285. print_syscall_epilogue(name);
  2286. }
  2287. #endif
  2288. #ifdef TARGET_NR_ftruncate64
  2289. static void
  2290. print_ftruncate64(CPUArchState *cpu_env, const struct syscallname *name,
  2291. abi_long arg0, abi_long arg1, abi_long arg2,
  2292. abi_long arg3, abi_long arg4, abi_long arg5)
  2293. {
  2294. print_syscall_prologue(name);
  2295. print_raw_param("%d", arg0, 0);
  2296. if (regpairs_aligned(cpu_env, TARGET_NR_ftruncate64)) {
  2297. arg1 = arg2;
  2298. arg2 = arg3;
  2299. }
  2300. print_raw_param("%" PRIu64, target_offset64(arg1, arg2), 1);
  2301. print_syscall_epilogue(name);
  2302. }
  2303. #endif
  2304. #ifdef TARGET_NR_mlockall
  2305. static void
  2306. print_mlockall(CPUArchState *cpu_env, const struct syscallname *name,
  2307. abi_long arg0, abi_long arg1, abi_long arg2,
  2308. abi_long arg3, abi_long arg4, abi_long arg5)
  2309. {
  2310. print_syscall_prologue(name);
  2311. print_flags(mlockall_flags, arg0, 1);
  2312. print_syscall_epilogue(name);
  2313. }
  2314. #endif
  2315. #if defined(TARGET_NR_socket)
  2316. static void
  2317. print_socket(CPUArchState *cpu_env, const struct syscallname *name,
  2318. abi_long arg0, abi_long arg1, abi_long arg2,
  2319. abi_long arg3, abi_long arg4, abi_long arg5)
  2320. {
  2321. abi_ulong domain = arg0, type = arg1, protocol = arg2;
  2322. print_syscall_prologue(name);
  2323. print_socket_domain(domain);
  2324. qemu_log(",");
  2325. print_socket_type(type);
  2326. qemu_log(",");
  2327. if (domain == AF_PACKET ||
  2328. (domain == AF_INET && type == TARGET_SOCK_PACKET)) {
  2329. protocol = tswap16(protocol);
  2330. }
  2331. print_socket_protocol(domain, type, protocol);
  2332. print_syscall_epilogue(name);
  2333. }
  2334. #endif
  2335. #if defined(TARGET_NR_socketcall) || defined(TARGET_NR_bind)
  2336. static void print_sockfd(abi_long sockfd, int last)
  2337. {
  2338. print_raw_param(TARGET_ABI_FMT_ld, sockfd, last);
  2339. }
  2340. #endif
  2341. #if defined(TARGET_NR_socketcall)
  2342. #define get_user_ualx(x, gaddr, idx) \
  2343. get_user_ual(x, (gaddr) + (idx) * sizeof(abi_long))
  2344. static void do_print_socket(const char *name, abi_long arg1)
  2345. {
  2346. abi_ulong domain, type, protocol;
  2347. get_user_ualx(domain, arg1, 0);
  2348. get_user_ualx(type, arg1, 1);
  2349. get_user_ualx(protocol, arg1, 2);
  2350. qemu_log("%s(", name);
  2351. print_socket_domain(domain);
  2352. qemu_log(",");
  2353. print_socket_type(type);
  2354. qemu_log(",");
  2355. if (domain == AF_PACKET ||
  2356. (domain == AF_INET && type == TARGET_SOCK_PACKET)) {
  2357. protocol = tswap16(protocol);
  2358. }
  2359. print_socket_protocol(domain, type, protocol);
  2360. qemu_log(")");
  2361. }
  2362. static void do_print_sockaddr(const char *name, abi_long arg1)
  2363. {
  2364. abi_ulong sockfd, addr, addrlen;
  2365. get_user_ualx(sockfd, arg1, 0);
  2366. get_user_ualx(addr, arg1, 1);
  2367. get_user_ualx(addrlen, arg1, 2);
  2368. qemu_log("%s(", name);
  2369. print_sockfd(sockfd, 0);
  2370. print_sockaddr(addr, addrlen, 0);
  2371. qemu_log(")");
  2372. }
  2373. static void do_print_listen(const char *name, abi_long arg1)
  2374. {
  2375. abi_ulong sockfd, backlog;
  2376. get_user_ualx(sockfd, arg1, 0);
  2377. get_user_ualx(backlog, arg1, 1);
  2378. qemu_log("%s(", name);
  2379. print_sockfd(sockfd, 0);
  2380. print_raw_param(TARGET_ABI_FMT_ld, backlog, 1);
  2381. qemu_log(")");
  2382. }
  2383. static void do_print_socketpair(const char *name, abi_long arg1)
  2384. {
  2385. abi_ulong domain, type, protocol, tab;
  2386. get_user_ualx(domain, arg1, 0);
  2387. get_user_ualx(type, arg1, 1);
  2388. get_user_ualx(protocol, arg1, 2);
  2389. get_user_ualx(tab, arg1, 3);
  2390. qemu_log("%s(", name);
  2391. print_socket_domain(domain);
  2392. qemu_log(",");
  2393. print_socket_type(type);
  2394. qemu_log(",");
  2395. print_socket_protocol(domain, type, protocol);
  2396. qemu_log(",");
  2397. print_raw_param(TARGET_ABI_FMT_lx, tab, 1);
  2398. qemu_log(")");
  2399. }
  2400. static void do_print_sendrecv(const char *name, abi_long arg1)
  2401. {
  2402. abi_ulong sockfd, msg, len, flags;
  2403. get_user_ualx(sockfd, arg1, 0);
  2404. get_user_ualx(msg, arg1, 1);
  2405. get_user_ualx(len, arg1, 2);
  2406. get_user_ualx(flags, arg1, 3);
  2407. qemu_log("%s(", name);
  2408. print_sockfd(sockfd, 0);
  2409. print_buf(msg, len, 0);
  2410. print_raw_param(TARGET_ABI_FMT_ld, len, 0);
  2411. print_flags(msg_flags, flags, 1);
  2412. qemu_log(")");
  2413. }
  2414. static void do_print_msgaddr(const char *name, abi_long arg1)
  2415. {
  2416. abi_ulong sockfd, msg, len, flags, addr, addrlen;
  2417. get_user_ualx(sockfd, arg1, 0);
  2418. get_user_ualx(msg, arg1, 1);
  2419. get_user_ualx(len, arg1, 2);
  2420. get_user_ualx(flags, arg1, 3);
  2421. get_user_ualx(addr, arg1, 4);
  2422. get_user_ualx(addrlen, arg1, 5);
  2423. qemu_log("%s(", name);
  2424. print_sockfd(sockfd, 0);
  2425. print_buf(msg, len, 0);
  2426. print_raw_param(TARGET_ABI_FMT_ld, len, 0);
  2427. print_flags(msg_flags, flags, 0);
  2428. print_sockaddr(addr, addrlen, 0);
  2429. qemu_log(")");
  2430. }
  2431. static void do_print_shutdown(const char *name, abi_long arg1)
  2432. {
  2433. abi_ulong sockfd, how;
  2434. get_user_ualx(sockfd, arg1, 0);
  2435. get_user_ualx(how, arg1, 1);
  2436. qemu_log("shutdown(");
  2437. print_sockfd(sockfd, 0);
  2438. switch (how) {
  2439. case SHUT_RD:
  2440. qemu_log("SHUT_RD");
  2441. break;
  2442. case SHUT_WR:
  2443. qemu_log("SHUT_WR");
  2444. break;
  2445. case SHUT_RDWR:
  2446. qemu_log("SHUT_RDWR");
  2447. break;
  2448. default:
  2449. print_raw_param(TARGET_ABI_FMT_ld, how, 1);
  2450. break;
  2451. }
  2452. qemu_log(")");
  2453. }
  2454. static void do_print_msg(const char *name, abi_long arg1)
  2455. {
  2456. abi_ulong sockfd, msg, flags;
  2457. get_user_ualx(sockfd, arg1, 0);
  2458. get_user_ualx(msg, arg1, 1);
  2459. get_user_ualx(flags, arg1, 2);
  2460. qemu_log("%s(", name);
  2461. print_sockfd(sockfd, 0);
  2462. print_pointer(msg, 0);
  2463. print_flags(msg_flags, flags, 1);
  2464. qemu_log(")");
  2465. }
  2466. static void do_print_sockopt(const char *name, abi_long arg1)
  2467. {
  2468. abi_ulong sockfd, level, optname, optval, optlen;
  2469. get_user_ualx(sockfd, arg1, 0);
  2470. get_user_ualx(level, arg1, 1);
  2471. get_user_ualx(optname, arg1, 2);
  2472. get_user_ualx(optval, arg1, 3);
  2473. get_user_ualx(optlen, arg1, 4);
  2474. qemu_log("%s(", name);
  2475. print_sockfd(sockfd, 0);
  2476. switch (level) {
  2477. case SOL_TCP:
  2478. qemu_log("SOL_TCP,");
  2479. print_raw_param(TARGET_ABI_FMT_ld, optname, 0);
  2480. print_pointer(optval, 0);
  2481. break;
  2482. case SOL_UDP:
  2483. qemu_log("SOL_UDP,");
  2484. print_raw_param(TARGET_ABI_FMT_ld, optname, 0);
  2485. print_pointer(optval, 0);
  2486. break;
  2487. case SOL_IP:
  2488. qemu_log("SOL_IP,");
  2489. print_raw_param(TARGET_ABI_FMT_ld, optname, 0);
  2490. print_pointer(optval, 0);
  2491. break;
  2492. case SOL_RAW:
  2493. qemu_log("SOL_RAW,");
  2494. print_raw_param(TARGET_ABI_FMT_ld, optname, 0);
  2495. print_pointer(optval, 0);
  2496. break;
  2497. case TARGET_SOL_SOCKET:
  2498. qemu_log("SOL_SOCKET,");
  2499. switch (optname) {
  2500. case TARGET_SO_DEBUG:
  2501. qemu_log("SO_DEBUG,");
  2502. print_optint:
  2503. print_number(optval, 0);
  2504. break;
  2505. case TARGET_SO_REUSEADDR:
  2506. qemu_log("SO_REUSEADDR,");
  2507. goto print_optint;
  2508. case TARGET_SO_REUSEPORT:
  2509. qemu_log("SO_REUSEPORT,");
  2510. goto print_optint;
  2511. case TARGET_SO_TYPE:
  2512. qemu_log("SO_TYPE,");
  2513. goto print_optint;
  2514. case TARGET_SO_ERROR:
  2515. qemu_log("SO_ERROR,");
  2516. goto print_optint;
  2517. case TARGET_SO_DONTROUTE:
  2518. qemu_log("SO_DONTROUTE,");
  2519. goto print_optint;
  2520. case TARGET_SO_BROADCAST:
  2521. qemu_log("SO_BROADCAST,");
  2522. goto print_optint;
  2523. case TARGET_SO_SNDBUF:
  2524. qemu_log("SO_SNDBUF,");
  2525. goto print_optint;
  2526. case TARGET_SO_RCVBUF:
  2527. qemu_log("SO_RCVBUF,");
  2528. goto print_optint;
  2529. case TARGET_SO_KEEPALIVE:
  2530. qemu_log("SO_KEEPALIVE,");
  2531. goto print_optint;
  2532. case TARGET_SO_OOBINLINE:
  2533. qemu_log("SO_OOBINLINE,");
  2534. goto print_optint;
  2535. case TARGET_SO_NO_CHECK:
  2536. qemu_log("SO_NO_CHECK,");
  2537. goto print_optint;
  2538. case TARGET_SO_PRIORITY:
  2539. qemu_log("SO_PRIORITY,");
  2540. goto print_optint;
  2541. case TARGET_SO_BSDCOMPAT:
  2542. qemu_log("SO_BSDCOMPAT,");
  2543. goto print_optint;
  2544. case TARGET_SO_PASSCRED:
  2545. qemu_log("SO_PASSCRED,");
  2546. goto print_optint;
  2547. case TARGET_SO_TIMESTAMP:
  2548. qemu_log("SO_TIMESTAMP,");
  2549. goto print_optint;
  2550. case TARGET_SO_RCVLOWAT:
  2551. qemu_log("SO_RCVLOWAT,");
  2552. goto print_optint;
  2553. case TARGET_SO_RCVTIMEO:
  2554. qemu_log("SO_RCVTIMEO,");
  2555. print_timeval(optval, 0);
  2556. break;
  2557. case TARGET_SO_SNDTIMEO:
  2558. qemu_log("SO_SNDTIMEO,");
  2559. print_timeval(optval, 0);
  2560. break;
  2561. case TARGET_SO_ATTACH_FILTER: {
  2562. struct target_sock_fprog *fprog;
  2563. qemu_log("SO_ATTACH_FILTER,");
  2564. if (lock_user_struct(VERIFY_READ, fprog, optval, 0)) {
  2565. struct target_sock_filter *filter;
  2566. qemu_log("{");
  2567. if (lock_user_struct(VERIFY_READ, filter,
  2568. tswapal(fprog->filter), 0)) {
  2569. int i;
  2570. for (i = 0; i < tswap16(fprog->len) - 1; i++) {
  2571. qemu_log("[%d]{0x%x,%d,%d,0x%x},",
  2572. i, tswap16(filter[i].code),
  2573. filter[i].jt, filter[i].jf,
  2574. tswap32(filter[i].k));
  2575. }
  2576. qemu_log("[%d]{0x%x,%d,%d,0x%x}",
  2577. i, tswap16(filter[i].code),
  2578. filter[i].jt, filter[i].jf,
  2579. tswap32(filter[i].k));
  2580. } else {
  2581. qemu_log(TARGET_ABI_FMT_lx, tswapal(fprog->filter));
  2582. }
  2583. qemu_log(",%d},", tswap16(fprog->len));
  2584. unlock_user(fprog, optval, 0);
  2585. } else {
  2586. print_pointer(optval, 0);
  2587. }
  2588. break;
  2589. }
  2590. default:
  2591. print_raw_param(TARGET_ABI_FMT_ld, optname, 0);
  2592. print_pointer(optval, 0);
  2593. break;
  2594. }
  2595. break;
  2596. case SOL_IPV6:
  2597. qemu_log("SOL_IPV6,");
  2598. switch (optname) {
  2599. case IPV6_MTU_DISCOVER:
  2600. qemu_log("IPV6_MTU_DISCOVER,");
  2601. goto print_optint;
  2602. case IPV6_MTU:
  2603. qemu_log("IPV6_MTU,");
  2604. goto print_optint;
  2605. case IPV6_V6ONLY:
  2606. qemu_log("IPV6_V6ONLY,");
  2607. goto print_optint;
  2608. case IPV6_RECVPKTINFO:
  2609. qemu_log("IPV6_RECVPKTINFO,");
  2610. goto print_optint;
  2611. case IPV6_UNICAST_HOPS:
  2612. qemu_log("IPV6_UNICAST_HOPS,");
  2613. goto print_optint;
  2614. case IPV6_MULTICAST_HOPS:
  2615. qemu_log("IPV6_MULTICAST_HOPS,");
  2616. goto print_optint;
  2617. case IPV6_MULTICAST_LOOP:
  2618. qemu_log("IPV6_MULTICAST_LOOP,");
  2619. goto print_optint;
  2620. case IPV6_RECVERR:
  2621. qemu_log("IPV6_RECVERR,");
  2622. goto print_optint;
  2623. case IPV6_RECVHOPLIMIT:
  2624. qemu_log("IPV6_RECVHOPLIMIT,");
  2625. goto print_optint;
  2626. case IPV6_2292HOPLIMIT:
  2627. qemu_log("IPV6_2292HOPLIMIT,");
  2628. goto print_optint;
  2629. case IPV6_CHECKSUM:
  2630. qemu_log("IPV6_CHECKSUM,");
  2631. goto print_optint;
  2632. case IPV6_ADDRFORM:
  2633. qemu_log("IPV6_ADDRFORM,");
  2634. goto print_optint;
  2635. case IPV6_2292PKTINFO:
  2636. qemu_log("IPV6_2292PKTINFO,");
  2637. goto print_optint;
  2638. case IPV6_RECVTCLASS:
  2639. qemu_log("IPV6_RECVTCLASS,");
  2640. goto print_optint;
  2641. case IPV6_RECVRTHDR:
  2642. qemu_log("IPV6_RECVRTHDR,");
  2643. goto print_optint;
  2644. case IPV6_2292RTHDR:
  2645. qemu_log("IPV6_2292RTHDR,");
  2646. goto print_optint;
  2647. case IPV6_RECVHOPOPTS:
  2648. qemu_log("IPV6_RECVHOPOPTS,");
  2649. goto print_optint;
  2650. case IPV6_2292HOPOPTS:
  2651. qemu_log("IPV6_2292HOPOPTS,");
  2652. goto print_optint;
  2653. case IPV6_RECVDSTOPTS:
  2654. qemu_log("IPV6_RECVDSTOPTS,");
  2655. goto print_optint;
  2656. case IPV6_2292DSTOPTS:
  2657. qemu_log("IPV6_2292DSTOPTS,");
  2658. goto print_optint;
  2659. case IPV6_TCLASS:
  2660. qemu_log("IPV6_TCLASS,");
  2661. goto print_optint;
  2662. case IPV6_ADDR_PREFERENCES:
  2663. qemu_log("IPV6_ADDR_PREFERENCES,");
  2664. goto print_optint;
  2665. #ifdef IPV6_RECVPATHMTU
  2666. case IPV6_RECVPATHMTU:
  2667. qemu_log("IPV6_RECVPATHMTU,");
  2668. goto print_optint;
  2669. #endif
  2670. #ifdef IPV6_TRANSPARENT
  2671. case IPV6_TRANSPARENT:
  2672. qemu_log("IPV6_TRANSPARENT,");
  2673. goto print_optint;
  2674. #endif
  2675. #ifdef IPV6_FREEBIND
  2676. case IPV6_FREEBIND:
  2677. qemu_log("IPV6_FREEBIND,");
  2678. goto print_optint;
  2679. #endif
  2680. #ifdef IPV6_RECVORIGDSTADDR
  2681. case IPV6_RECVORIGDSTADDR:
  2682. qemu_log("IPV6_RECVORIGDSTADDR,");
  2683. goto print_optint;
  2684. #endif
  2685. case IPV6_PKTINFO:
  2686. qemu_log("IPV6_PKTINFO,");
  2687. print_pointer(optval, 0);
  2688. break;
  2689. case IPV6_ADD_MEMBERSHIP:
  2690. qemu_log("IPV6_ADD_MEMBERSHIP,");
  2691. print_pointer(optval, 0);
  2692. break;
  2693. case IPV6_DROP_MEMBERSHIP:
  2694. qemu_log("IPV6_DROP_MEMBERSHIP,");
  2695. print_pointer(optval, 0);
  2696. break;
  2697. default:
  2698. print_raw_param(TARGET_ABI_FMT_ld, optname, 0);
  2699. print_pointer(optval, 0);
  2700. break;
  2701. }
  2702. break;
  2703. default:
  2704. print_raw_param(TARGET_ABI_FMT_ld, level, 0);
  2705. print_raw_param(TARGET_ABI_FMT_ld, optname, 0);
  2706. print_pointer(optval, 0);
  2707. break;
  2708. }
  2709. print_raw_param(TARGET_ABI_FMT_ld, optlen, 1);
  2710. qemu_log(")");
  2711. }
  2712. #define PRINT_SOCKOP(name, func) \
  2713. [TARGET_SYS_##name] = { #name, func }
  2714. static struct {
  2715. const char *name;
  2716. void (*print)(const char *, abi_long);
  2717. } scall[] = {
  2718. PRINT_SOCKOP(SOCKET, do_print_socket),
  2719. PRINT_SOCKOP(BIND, do_print_sockaddr),
  2720. PRINT_SOCKOP(CONNECT, do_print_sockaddr),
  2721. PRINT_SOCKOP(LISTEN, do_print_listen),
  2722. PRINT_SOCKOP(ACCEPT, do_print_sockaddr),
  2723. PRINT_SOCKOP(GETSOCKNAME, do_print_sockaddr),
  2724. PRINT_SOCKOP(GETPEERNAME, do_print_sockaddr),
  2725. PRINT_SOCKOP(SOCKETPAIR, do_print_socketpair),
  2726. PRINT_SOCKOP(SEND, do_print_sendrecv),
  2727. PRINT_SOCKOP(RECV, do_print_sendrecv),
  2728. PRINT_SOCKOP(SENDTO, do_print_msgaddr),
  2729. PRINT_SOCKOP(RECVFROM, do_print_msgaddr),
  2730. PRINT_SOCKOP(SHUTDOWN, do_print_shutdown),
  2731. PRINT_SOCKOP(SETSOCKOPT, do_print_sockopt),
  2732. PRINT_SOCKOP(GETSOCKOPT, do_print_sockopt),
  2733. PRINT_SOCKOP(SENDMSG, do_print_msg),
  2734. PRINT_SOCKOP(RECVMSG, do_print_msg),
  2735. PRINT_SOCKOP(ACCEPT4, NULL),
  2736. PRINT_SOCKOP(RECVMMSG, NULL),
  2737. PRINT_SOCKOP(SENDMMSG, NULL),
  2738. };
  2739. static void
  2740. print_socketcall(CPUArchState *cpu_env, const struct syscallname *name,
  2741. abi_long arg0, abi_long arg1, abi_long arg2,
  2742. abi_long arg3, abi_long arg4, abi_long arg5)
  2743. {
  2744. if (arg0 >= 0 && arg0 < ARRAY_SIZE(scall) && scall[arg0].print) {
  2745. scall[arg0].print(scall[arg0].name, arg1);
  2746. return;
  2747. }
  2748. print_syscall_prologue(name);
  2749. print_raw_param(TARGET_ABI_FMT_ld, arg0, 0);
  2750. print_raw_param(TARGET_ABI_FMT_ld, arg1, 0);
  2751. print_raw_param(TARGET_ABI_FMT_ld, arg2, 0);
  2752. print_raw_param(TARGET_ABI_FMT_ld, arg3, 0);
  2753. print_raw_param(TARGET_ABI_FMT_ld, arg4, 0);
  2754. print_raw_param(TARGET_ABI_FMT_ld, arg5, 0);
  2755. print_syscall_epilogue(name);
  2756. }
  2757. #endif
  2758. #if defined(TARGET_NR_bind)
  2759. static void
  2760. print_bind(CPUArchState *cpu_env, const struct syscallname *name,
  2761. abi_long arg0, abi_long arg1, abi_long arg2,
  2762. abi_long arg3, abi_long arg4, abi_long arg5)
  2763. {
  2764. print_syscall_prologue(name);
  2765. print_sockfd(arg0, 0);
  2766. print_sockaddr(arg1, arg2, 1);
  2767. print_syscall_epilogue(name);
  2768. }
  2769. #endif
  2770. #if defined(TARGET_NR_stat) || defined(TARGET_NR_stat64) || \
  2771. defined(TARGET_NR_lstat) || defined(TARGET_NR_lstat64)
  2772. static void
  2773. print_stat(CPUArchState *cpu_env, const struct syscallname *name,
  2774. abi_long arg0, abi_long arg1, abi_long arg2,
  2775. abi_long arg3, abi_long arg4, abi_long arg5)
  2776. {
  2777. print_syscall_prologue(name);
  2778. print_string(arg0, 0);
  2779. print_pointer(arg1, 1);
  2780. print_syscall_epilogue(name);
  2781. }
  2782. #define print_lstat print_stat
  2783. #define print_stat64 print_stat
  2784. #define print_lstat64 print_stat
  2785. #endif
  2786. #if defined(TARGET_NR_madvise)
  2787. static struct enums madvise_advice[] = {
  2788. ENUM_TARGET(MADV_NORMAL),
  2789. ENUM_TARGET(MADV_RANDOM),
  2790. ENUM_TARGET(MADV_SEQUENTIAL),
  2791. ENUM_TARGET(MADV_WILLNEED),
  2792. ENUM_TARGET(MADV_DONTNEED),
  2793. ENUM_TARGET(MADV_FREE),
  2794. ENUM_TARGET(MADV_REMOVE),
  2795. ENUM_TARGET(MADV_DONTFORK),
  2796. ENUM_TARGET(MADV_DOFORK),
  2797. ENUM_TARGET(MADV_MERGEABLE),
  2798. ENUM_TARGET(MADV_UNMERGEABLE),
  2799. ENUM_TARGET(MADV_HUGEPAGE),
  2800. ENUM_TARGET(MADV_NOHUGEPAGE),
  2801. ENUM_TARGET(MADV_DONTDUMP),
  2802. ENUM_TARGET(MADV_DODUMP),
  2803. ENUM_TARGET(MADV_WIPEONFORK),
  2804. ENUM_TARGET(MADV_KEEPONFORK),
  2805. ENUM_TARGET(MADV_COLD),
  2806. ENUM_TARGET(MADV_PAGEOUT),
  2807. ENUM_TARGET(MADV_POPULATE_READ),
  2808. ENUM_TARGET(MADV_POPULATE_WRITE),
  2809. ENUM_TARGET(MADV_DONTNEED_LOCKED),
  2810. ENUM_END,
  2811. };
  2812. static void
  2813. print_madvise(CPUArchState *cpu_env, const struct syscallname *name,
  2814. abi_long arg0, abi_long arg1, abi_long arg2,
  2815. abi_long arg3, abi_long arg4, abi_long arg5)
  2816. {
  2817. print_syscall_prologue(name);
  2818. print_pointer(arg0, 0);
  2819. print_raw_param("%d", arg1, 0);
  2820. print_enums(madvise_advice, arg2, 1);
  2821. print_syscall_epilogue(name);
  2822. }
  2823. #endif
  2824. #if defined(TARGET_NR_fstat) || defined(TARGET_NR_fstat64)
  2825. static void
  2826. print_fstat(CPUArchState *cpu_env, const struct syscallname *name,
  2827. abi_long arg0, abi_long arg1, abi_long arg2,
  2828. abi_long arg3, abi_long arg4, abi_long arg5)
  2829. {
  2830. print_syscall_prologue(name);
  2831. print_raw_param("%d", arg0, 0);
  2832. print_pointer(arg1, 1);
  2833. print_syscall_epilogue(name);
  2834. }
  2835. #define print_fstat64 print_fstat
  2836. #endif
  2837. #ifdef TARGET_NR_mkdir
  2838. static void
  2839. print_mkdir(CPUArchState *cpu_env, const struct syscallname *name,
  2840. abi_long arg0, abi_long arg1, abi_long arg2,
  2841. abi_long arg3, abi_long arg4, abi_long arg5)
  2842. {
  2843. print_syscall_prologue(name);
  2844. print_string(arg0, 0);
  2845. print_file_mode(arg1, 1);
  2846. print_syscall_epilogue(name);
  2847. }
  2848. #endif
  2849. #ifdef TARGET_NR_mkdirat
  2850. static void
  2851. print_mkdirat(CPUArchState *cpu_env, const struct syscallname *name,
  2852. abi_long arg0, abi_long arg1, abi_long arg2,
  2853. abi_long arg3, abi_long arg4, abi_long arg5)
  2854. {
  2855. print_syscall_prologue(name);
  2856. print_at_dirfd(arg0, 0);
  2857. print_string(arg1, 0);
  2858. print_file_mode(arg2, 1);
  2859. print_syscall_epilogue(name);
  2860. }
  2861. #endif
  2862. #ifdef TARGET_NR_rmdir
  2863. static void
  2864. print_rmdir(CPUArchState *cpu_env, const struct syscallname *name,
  2865. abi_long arg0, abi_long arg1, abi_long arg2,
  2866. abi_long arg3, abi_long arg4, abi_long arg5)
  2867. {
  2868. print_syscall_prologue(name);
  2869. print_string(arg0, 0);
  2870. print_syscall_epilogue(name);
  2871. }
  2872. #endif
  2873. #ifdef TARGET_NR_rt_sigaction
  2874. static void
  2875. print_rt_sigaction(CPUArchState *cpu_env, const struct syscallname *name,
  2876. abi_long arg0, abi_long arg1, abi_long arg2,
  2877. abi_long arg3, abi_long arg4, abi_long arg5)
  2878. {
  2879. print_syscall_prologue(name);
  2880. print_signal(arg0, 0);
  2881. print_pointer(arg1, 0);
  2882. print_pointer(arg2, 1);
  2883. print_syscall_epilogue(name);
  2884. }
  2885. #endif
  2886. #ifdef TARGET_NR_rt_sigprocmask
  2887. static void
  2888. print_rt_sigprocmask(CPUArchState *cpu_env, const struct syscallname *name,
  2889. abi_long arg0, abi_long arg1, abi_long arg2,
  2890. abi_long arg3, abi_long arg4, abi_long arg5)
  2891. {
  2892. const char *how = "UNKNOWN";
  2893. print_syscall_prologue(name);
  2894. switch(arg0) {
  2895. case TARGET_SIG_BLOCK: how = "SIG_BLOCK"; break;
  2896. case TARGET_SIG_UNBLOCK: how = "SIG_UNBLOCK"; break;
  2897. case TARGET_SIG_SETMASK: how = "SIG_SETMASK"; break;
  2898. }
  2899. qemu_log("%s,", how);
  2900. print_pointer(arg1, 0);
  2901. print_pointer(arg2, 1);
  2902. print_syscall_epilogue(name);
  2903. }
  2904. #endif
  2905. #ifdef TARGET_NR_rt_sigqueueinfo
  2906. static void
  2907. print_rt_sigqueueinfo(CPUArchState *cpu_env, const struct syscallname *name,
  2908. abi_long arg0, abi_long arg1, abi_long arg2,
  2909. abi_long arg3, abi_long arg4, abi_long arg5)
  2910. {
  2911. void *p;
  2912. target_siginfo_t uinfo;
  2913. print_syscall_prologue(name);
  2914. print_raw_param("%d", arg0, 0);
  2915. print_signal(arg1, 0);
  2916. p = lock_user(VERIFY_READ, arg2, sizeof(target_siginfo_t), 1);
  2917. if (p) {
  2918. get_target_siginfo(&uinfo, p);
  2919. print_siginfo(&uinfo);
  2920. unlock_user(p, arg2, 0);
  2921. } else {
  2922. print_pointer(arg2, 1);
  2923. }
  2924. print_syscall_epilogue(name);
  2925. }
  2926. #endif
  2927. #ifdef TARGET_NR_rt_tgsigqueueinfo
  2928. static void
  2929. print_rt_tgsigqueueinfo(CPUArchState *cpu_env, const struct syscallname *name,
  2930. abi_long arg0, abi_long arg1, abi_long arg2,
  2931. abi_long arg3, abi_long arg4, abi_long arg5)
  2932. {
  2933. void *p;
  2934. target_siginfo_t uinfo;
  2935. print_syscall_prologue(name);
  2936. print_raw_param("%d", arg0, 0);
  2937. print_raw_param("%d", arg1, 0);
  2938. print_signal(arg2, 0);
  2939. p = lock_user(VERIFY_READ, arg3, sizeof(target_siginfo_t), 1);
  2940. if (p) {
  2941. get_target_siginfo(&uinfo, p);
  2942. print_siginfo(&uinfo);
  2943. unlock_user(p, arg3, 0);
  2944. } else {
  2945. print_pointer(arg3, 1);
  2946. }
  2947. print_syscall_epilogue(name);
  2948. }
  2949. #endif
  2950. #ifdef TARGET_NR_syslog
  2951. static void
  2952. print_syslog_action(abi_ulong arg, int last)
  2953. {
  2954. const char *type;
  2955. switch (arg) {
  2956. case TARGET_SYSLOG_ACTION_CLOSE: {
  2957. type = "SYSLOG_ACTION_CLOSE";
  2958. break;
  2959. }
  2960. case TARGET_SYSLOG_ACTION_OPEN: {
  2961. type = "SYSLOG_ACTION_OPEN";
  2962. break;
  2963. }
  2964. case TARGET_SYSLOG_ACTION_READ: {
  2965. type = "SYSLOG_ACTION_READ";
  2966. break;
  2967. }
  2968. case TARGET_SYSLOG_ACTION_READ_ALL: {
  2969. type = "SYSLOG_ACTION_READ_ALL";
  2970. break;
  2971. }
  2972. case TARGET_SYSLOG_ACTION_READ_CLEAR: {
  2973. type = "SYSLOG_ACTION_READ_CLEAR";
  2974. break;
  2975. }
  2976. case TARGET_SYSLOG_ACTION_CLEAR: {
  2977. type = "SYSLOG_ACTION_CLEAR";
  2978. break;
  2979. }
  2980. case TARGET_SYSLOG_ACTION_CONSOLE_OFF: {
  2981. type = "SYSLOG_ACTION_CONSOLE_OFF";
  2982. break;
  2983. }
  2984. case TARGET_SYSLOG_ACTION_CONSOLE_ON: {
  2985. type = "SYSLOG_ACTION_CONSOLE_ON";
  2986. break;
  2987. }
  2988. case TARGET_SYSLOG_ACTION_CONSOLE_LEVEL: {
  2989. type = "SYSLOG_ACTION_CONSOLE_LEVEL";
  2990. break;
  2991. }
  2992. case TARGET_SYSLOG_ACTION_SIZE_UNREAD: {
  2993. type = "SYSLOG_ACTION_SIZE_UNREAD";
  2994. break;
  2995. }
  2996. case TARGET_SYSLOG_ACTION_SIZE_BUFFER: {
  2997. type = "SYSLOG_ACTION_SIZE_BUFFER";
  2998. break;
  2999. }
  3000. default: {
  3001. print_raw_param("%ld", arg, last);
  3002. return;
  3003. }
  3004. }
  3005. qemu_log("%s%s", type, get_comma(last));
  3006. }
  3007. static void
  3008. print_syslog(CPUArchState *cpu_env, const struct syscallname *name,
  3009. abi_long arg0, abi_long arg1, abi_long arg2,
  3010. abi_long arg3, abi_long arg4, abi_long arg5)
  3011. {
  3012. print_syscall_prologue(name);
  3013. print_syslog_action(arg0, 0);
  3014. print_pointer(arg1, 0);
  3015. print_raw_param("%d", arg2, 1);
  3016. print_syscall_epilogue(name);
  3017. }
  3018. #endif
  3019. #ifdef TARGET_NR_mknod
  3020. static void
  3021. print_mknod(CPUArchState *cpu_env, const struct syscallname *name,
  3022. abi_long arg0, abi_long arg1, abi_long arg2,
  3023. abi_long arg3, abi_long arg4, abi_long arg5)
  3024. {
  3025. int hasdev = (arg1 & (S_IFCHR|S_IFBLK));
  3026. print_syscall_prologue(name);
  3027. print_string(arg0, 0);
  3028. print_file_mode(arg1, (hasdev == 0));
  3029. if (hasdev) {
  3030. print_raw_param("makedev(%d", major(arg2), 0);
  3031. print_raw_param("%d)", minor(arg2), 1);
  3032. }
  3033. print_syscall_epilogue(name);
  3034. }
  3035. #endif
  3036. #ifdef TARGET_NR_mknodat
  3037. static void
  3038. print_mknodat(CPUArchState *cpu_env, const struct syscallname *name,
  3039. abi_long arg0, abi_long arg1, abi_long arg2,
  3040. abi_long arg3, abi_long arg4, abi_long arg5)
  3041. {
  3042. int hasdev = (arg2 & (S_IFCHR|S_IFBLK));
  3043. print_syscall_prologue(name);
  3044. print_at_dirfd(arg0, 0);
  3045. print_string(arg1, 0);
  3046. print_file_mode(arg2, (hasdev == 0));
  3047. if (hasdev) {
  3048. print_raw_param("makedev(%d", major(arg3), 0);
  3049. print_raw_param("%d)", minor(arg3), 1);
  3050. }
  3051. print_syscall_epilogue(name);
  3052. }
  3053. #endif
  3054. #ifdef TARGET_NR_mq_open
  3055. static void
  3056. print_mq_open(CPUArchState *cpu_env, const struct syscallname *name,
  3057. abi_long arg0, abi_long arg1, abi_long arg2,
  3058. abi_long arg3, abi_long arg4, abi_long arg5)
  3059. {
  3060. int is_creat = (arg1 & TARGET_O_CREAT);
  3061. print_syscall_prologue(name);
  3062. print_string(arg0, 0);
  3063. print_open_flags(arg1, (is_creat == 0));
  3064. if (is_creat) {
  3065. print_file_mode(arg2, 0);
  3066. print_pointer(arg3, 1);
  3067. }
  3068. print_syscall_epilogue(name);
  3069. }
  3070. #endif
  3071. #ifdef TARGET_NR_open
  3072. static void
  3073. print_open(CPUArchState *cpu_env, const struct syscallname *name,
  3074. abi_long arg0, abi_long arg1, abi_long arg2,
  3075. abi_long arg3, abi_long arg4, abi_long arg5)
  3076. {
  3077. int is_creat = (arg1 & TARGET_O_CREAT);
  3078. print_syscall_prologue(name);
  3079. print_string(arg0, 0);
  3080. print_open_flags(arg1, (is_creat == 0));
  3081. if (is_creat)
  3082. print_file_mode(arg2, 1);
  3083. print_syscall_epilogue(name);
  3084. }
  3085. #endif
  3086. #ifdef TARGET_NR_openat
  3087. static void
  3088. print_openat(CPUArchState *cpu_env, const struct syscallname *name,
  3089. abi_long arg0, abi_long arg1, abi_long arg2,
  3090. abi_long arg3, abi_long arg4, abi_long arg5)
  3091. {
  3092. int is_creat = (arg2 & TARGET_O_CREAT);
  3093. print_syscall_prologue(name);
  3094. print_at_dirfd(arg0, 0);
  3095. print_string(arg1, 0);
  3096. print_open_flags(arg2, (is_creat == 0));
  3097. if (is_creat)
  3098. print_file_mode(arg3, 1);
  3099. print_syscall_epilogue(name);
  3100. }
  3101. #endif
  3102. #ifdef TARGET_NR_pidfd_send_signal
  3103. static void
  3104. print_pidfd_send_signal(CPUArchState *cpu_env, const struct syscallname *name,
  3105. abi_long arg0, abi_long arg1, abi_long arg2,
  3106. abi_long arg3, abi_long arg4, abi_long arg5)
  3107. {
  3108. void *p;
  3109. target_siginfo_t uinfo;
  3110. print_syscall_prologue(name);
  3111. print_raw_param("%d", arg0, 0);
  3112. print_signal(arg1, 0);
  3113. p = lock_user(VERIFY_READ, arg2, sizeof(target_siginfo_t), 1);
  3114. if (p) {
  3115. get_target_siginfo(&uinfo, p);
  3116. print_siginfo(&uinfo);
  3117. unlock_user(p, arg2, 0);
  3118. } else {
  3119. print_pointer(arg2, 0);
  3120. }
  3121. print_raw_param("%u", arg3, 1);
  3122. print_syscall_epilogue(name);
  3123. }
  3124. #endif
  3125. #ifdef TARGET_NR_mq_unlink
  3126. static void
  3127. print_mq_unlink(CPUArchState *cpu_env, const struct syscallname *name,
  3128. abi_long arg0, abi_long arg1, abi_long arg2,
  3129. abi_long arg3, abi_long arg4, abi_long arg5)
  3130. {
  3131. print_syscall_prologue(name);
  3132. print_string(arg0, 1);
  3133. print_syscall_epilogue(name);
  3134. }
  3135. #endif
  3136. #if defined(TARGET_NR_fstatat64) || defined(TARGET_NR_newfstatat)
  3137. static void
  3138. print_fstatat64(CPUArchState *cpu_env, const struct syscallname *name,
  3139. abi_long arg0, abi_long arg1, abi_long arg2,
  3140. abi_long arg3, abi_long arg4, abi_long arg5)
  3141. {
  3142. print_syscall_prologue(name);
  3143. print_at_dirfd(arg0, 0);
  3144. print_string(arg1, 0);
  3145. print_pointer(arg2, 0);
  3146. print_flags(at_file_flags, arg3, 1);
  3147. print_syscall_epilogue(name);
  3148. }
  3149. #define print_newfstatat print_fstatat64
  3150. #endif
  3151. #ifdef TARGET_NR_readlink
  3152. static void
  3153. print_readlink(CPUArchState *cpu_env, const struct syscallname *name,
  3154. abi_long arg0, abi_long arg1, abi_long arg2,
  3155. abi_long arg3, abi_long arg4, abi_long arg5)
  3156. {
  3157. print_syscall_prologue(name);
  3158. print_string(arg0, 0);
  3159. print_pointer(arg1, 0);
  3160. print_raw_param("%u", arg2, 1);
  3161. print_syscall_epilogue(name);
  3162. }
  3163. #endif
  3164. #ifdef TARGET_NR_readlinkat
  3165. static void
  3166. print_readlinkat(CPUArchState *cpu_env, const struct syscallname *name,
  3167. abi_long arg0, abi_long arg1, abi_long arg2,
  3168. abi_long arg3, abi_long arg4, abi_long arg5)
  3169. {
  3170. print_syscall_prologue(name);
  3171. print_at_dirfd(arg0, 0);
  3172. print_string(arg1, 0);
  3173. print_pointer(arg2, 0);
  3174. print_raw_param("%u", arg3, 1);
  3175. print_syscall_epilogue(name);
  3176. }
  3177. #endif
  3178. #ifdef TARGET_NR_rename
  3179. static void
  3180. print_rename(CPUArchState *cpu_env, const struct syscallname *name,
  3181. abi_long arg0, abi_long arg1, abi_long arg2,
  3182. abi_long arg3, abi_long arg4, abi_long arg5)
  3183. {
  3184. print_syscall_prologue(name);
  3185. print_string(arg0, 0);
  3186. print_string(arg1, 1);
  3187. print_syscall_epilogue(name);
  3188. }
  3189. #endif
  3190. #ifdef TARGET_NR_renameat
  3191. static void
  3192. print_renameat(CPUArchState *cpu_env, const struct syscallname *name,
  3193. abi_long arg0, abi_long arg1, abi_long arg2,
  3194. abi_long arg3, abi_long arg4, abi_long arg5)
  3195. {
  3196. print_syscall_prologue(name);
  3197. print_at_dirfd(arg0, 0);
  3198. print_string(arg1, 0);
  3199. print_at_dirfd(arg2, 0);
  3200. print_string(arg3, 1);
  3201. print_syscall_epilogue(name);
  3202. }
  3203. #endif
  3204. #ifdef TARGET_NR_statfs
  3205. static void
  3206. print_statfs(CPUArchState *cpu_env, const struct syscallname *name,
  3207. abi_long arg0, abi_long arg1, abi_long arg2,
  3208. abi_long arg3, abi_long arg4, abi_long arg5)
  3209. {
  3210. print_syscall_prologue(name);
  3211. print_string(arg0, 0);
  3212. print_pointer(arg1, 1);
  3213. print_syscall_epilogue(name);
  3214. }
  3215. #endif
  3216. #ifdef TARGET_NR_statfs64
  3217. static void
  3218. print_statfs64(CPUArchState *cpu_env, const struct syscallname *name,
  3219. abi_long arg0, abi_long arg1, abi_long arg2,
  3220. abi_long arg3, abi_long arg4, abi_long arg5)
  3221. {
  3222. print_syscall_prologue(name);
  3223. print_string(arg0, 0);
  3224. print_pointer(arg1, 1);
  3225. print_syscall_epilogue(name);
  3226. }
  3227. #endif
  3228. #ifdef TARGET_NR_symlink
  3229. static void
  3230. print_symlink(CPUArchState *cpu_env, const struct syscallname *name,
  3231. abi_long arg0, abi_long arg1, abi_long arg2,
  3232. abi_long arg3, abi_long arg4, abi_long arg5)
  3233. {
  3234. print_syscall_prologue(name);
  3235. print_string(arg0, 0);
  3236. print_string(arg1, 1);
  3237. print_syscall_epilogue(name);
  3238. }
  3239. #endif
  3240. #ifdef TARGET_NR_symlinkat
  3241. static void
  3242. print_symlinkat(CPUArchState *cpu_env, const struct syscallname *name,
  3243. abi_long arg0, abi_long arg1, abi_long arg2,
  3244. abi_long arg3, abi_long arg4, abi_long arg5)
  3245. {
  3246. print_syscall_prologue(name);
  3247. print_string(arg0, 0);
  3248. print_at_dirfd(arg1, 0);
  3249. print_string(arg2, 1);
  3250. print_syscall_epilogue(name);
  3251. }
  3252. #endif
  3253. #ifdef TARGET_NR_mount
  3254. static void
  3255. print_mount(CPUArchState *cpu_env, const struct syscallname *name,
  3256. abi_long arg0, abi_long arg1, abi_long arg2,
  3257. abi_long arg3, abi_long arg4, abi_long arg5)
  3258. {
  3259. print_syscall_prologue(name);
  3260. print_string(arg0, 0);
  3261. print_string(arg1, 0);
  3262. print_string(arg2, 0);
  3263. print_flags(mount_flags, arg3, 0);
  3264. print_pointer(arg4, 1);
  3265. print_syscall_epilogue(name);
  3266. }
  3267. #endif
  3268. #ifdef TARGET_NR_umount
  3269. static void
  3270. print_umount(CPUArchState *cpu_env, const struct syscallname *name,
  3271. abi_long arg0, abi_long arg1, abi_long arg2,
  3272. abi_long arg3, abi_long arg4, abi_long arg5)
  3273. {
  3274. print_syscall_prologue(name);
  3275. print_string(arg0, 1);
  3276. print_syscall_epilogue(name);
  3277. }
  3278. #endif
  3279. #ifdef TARGET_NR_umount2
  3280. static void
  3281. print_umount2(CPUArchState *cpu_env, const struct syscallname *name,
  3282. abi_long arg0, abi_long arg1, abi_long arg2,
  3283. abi_long arg3, abi_long arg4, abi_long arg5)
  3284. {
  3285. print_syscall_prologue(name);
  3286. print_string(arg0, 0);
  3287. print_flags(umount2_flags, arg1, 1);
  3288. print_syscall_epilogue(name);
  3289. }
  3290. #endif
  3291. #ifdef TARGET_NR_unlink
  3292. static void
  3293. print_unlink(CPUArchState *cpu_env, const struct syscallname *name,
  3294. abi_long arg0, abi_long arg1, abi_long arg2,
  3295. abi_long arg3, abi_long arg4, abi_long arg5)
  3296. {
  3297. print_syscall_prologue(name);
  3298. print_string(arg0, 1);
  3299. print_syscall_epilogue(name);
  3300. }
  3301. #endif
  3302. #ifdef TARGET_NR_unlinkat
  3303. static void
  3304. print_unlinkat(CPUArchState *cpu_env, const struct syscallname *name,
  3305. abi_long arg0, abi_long arg1, abi_long arg2,
  3306. abi_long arg3, abi_long arg4, abi_long arg5)
  3307. {
  3308. print_syscall_prologue(name);
  3309. print_at_dirfd(arg0, 0);
  3310. print_string(arg1, 0);
  3311. print_flags(unlinkat_flags, arg2, 1);
  3312. print_syscall_epilogue(name);
  3313. }
  3314. #endif
  3315. #ifdef TARGET_NR_unshare
  3316. static void
  3317. print_unshare(CPUArchState *cpu_env, const struct syscallname *name,
  3318. abi_long arg0, abi_long arg1, abi_long arg2,
  3319. abi_long arg3, abi_long arg4, abi_long arg5)
  3320. {
  3321. print_syscall_prologue(name);
  3322. print_flags(clone_flags, arg0, 1);
  3323. print_syscall_epilogue(name);
  3324. }
  3325. #endif
  3326. #ifdef TARGET_NR_clock_nanosleep
  3327. static void
  3328. print_clock_nanosleep(CPUArchState *cpu_env, const struct syscallname *name,
  3329. abi_long arg0, abi_long arg1, abi_long arg2,
  3330. abi_long arg3, abi_long arg4, abi_long arg5)
  3331. {
  3332. print_syscall_prologue(name);
  3333. print_enums(clockids, arg0, 0);
  3334. print_raw_param("%d", arg1, 0);
  3335. print_timespec(arg2, 0);
  3336. print_timespec(arg3, 1);
  3337. print_syscall_epilogue(name);
  3338. }
  3339. #endif
  3340. #ifdef TARGET_NR_utime
  3341. static void
  3342. print_utime(CPUArchState *cpu_env, const struct syscallname *name,
  3343. abi_long arg0, abi_long arg1, abi_long arg2,
  3344. abi_long arg3, abi_long arg4, abi_long arg5)
  3345. {
  3346. print_syscall_prologue(name);
  3347. print_string(arg0, 0);
  3348. print_pointer(arg1, 1);
  3349. print_syscall_epilogue(name);
  3350. }
  3351. #endif
  3352. #ifdef TARGET_NR_utimes
  3353. static void
  3354. print_utimes(CPUArchState *cpu_env, const struct syscallname *name,
  3355. abi_long arg0, abi_long arg1, abi_long arg2,
  3356. abi_long arg3, abi_long arg4, abi_long arg5)
  3357. {
  3358. print_syscall_prologue(name);
  3359. print_string(arg0, 0);
  3360. print_pointer(arg1, 1);
  3361. print_syscall_epilogue(name);
  3362. }
  3363. #endif
  3364. #ifdef TARGET_NR_utimensat
  3365. static void
  3366. print_utimensat(CPUArchState *cpu_env, const struct syscallname *name,
  3367. abi_long arg0, abi_long arg1, abi_long arg2,
  3368. abi_long arg3, abi_long arg4, abi_long arg5)
  3369. {
  3370. print_syscall_prologue(name);
  3371. print_at_dirfd(arg0, 0);
  3372. print_string(arg1, 0);
  3373. print_pointer(arg2, 0);
  3374. print_flags(at_file_flags, arg3, 1);
  3375. print_syscall_epilogue(name);
  3376. }
  3377. #endif
  3378. #if defined(TARGET_NR_mmap) || defined(TARGET_NR_mmap2)
  3379. static void
  3380. print_mmap(CPUArchState *cpu_env, const struct syscallname *name,
  3381. abi_long arg0, abi_long arg1, abi_long arg2,
  3382. abi_long arg3, abi_long arg4, abi_long arg5)
  3383. {
  3384. print_syscall_prologue(name);
  3385. print_pointer(arg0, 0);
  3386. print_raw_param("%d", arg1, 0);
  3387. print_flags(mmap_prot_flags, arg2, 0);
  3388. print_flags(mmap_flags, arg3, 0);
  3389. print_raw_param("%d", arg4, 0);
  3390. print_raw_param("%#x", arg5, 1);
  3391. print_syscall_epilogue(name);
  3392. }
  3393. #define print_mmap2 print_mmap
  3394. #endif
  3395. #ifdef TARGET_NR_mprotect
  3396. static void
  3397. print_mprotect(CPUArchState *cpu_env, const struct syscallname *name,
  3398. abi_long arg0, abi_long arg1, abi_long arg2,
  3399. abi_long arg3, abi_long arg4, abi_long arg5)
  3400. {
  3401. print_syscall_prologue(name);
  3402. print_pointer(arg0, 0);
  3403. print_raw_param("%d", arg1, 0);
  3404. print_flags(mmap_prot_flags, arg2, 1);
  3405. print_syscall_epilogue(name);
  3406. }
  3407. #endif
  3408. #ifdef TARGET_NR_munmap
  3409. static void
  3410. print_munmap(CPUArchState *cpu_env, const struct syscallname *name,
  3411. abi_long arg0, abi_long arg1, abi_long arg2,
  3412. abi_long arg3, abi_long arg4, abi_long arg5)
  3413. {
  3414. print_syscall_prologue(name);
  3415. print_pointer(arg0, 0);
  3416. print_raw_param("%d", arg1, 1);
  3417. print_syscall_epilogue(name);
  3418. }
  3419. #endif
  3420. #ifdef TARGET_NR_futex
  3421. static void print_futex_op(int cmd, int last)
  3422. {
  3423. static const char * const futex_names[] = {
  3424. #define NAME(X) [X] = #X
  3425. NAME(FUTEX_WAIT),
  3426. NAME(FUTEX_WAKE),
  3427. NAME(FUTEX_FD),
  3428. NAME(FUTEX_REQUEUE),
  3429. NAME(FUTEX_CMP_REQUEUE),
  3430. NAME(FUTEX_WAKE_OP),
  3431. NAME(FUTEX_LOCK_PI),
  3432. NAME(FUTEX_UNLOCK_PI),
  3433. NAME(FUTEX_TRYLOCK_PI),
  3434. NAME(FUTEX_WAIT_BITSET),
  3435. NAME(FUTEX_WAKE_BITSET),
  3436. NAME(FUTEX_WAIT_REQUEUE_PI),
  3437. NAME(FUTEX_CMP_REQUEUE_PI),
  3438. NAME(FUTEX_LOCK_PI2),
  3439. #undef NAME
  3440. };
  3441. unsigned base_cmd = cmd & FUTEX_CMD_MASK;
  3442. if (base_cmd < ARRAY_SIZE(futex_names)) {
  3443. qemu_log("%s%s%s",
  3444. (cmd & FUTEX_PRIVATE_FLAG ? "FUTEX_PRIVATE_FLAG|" : ""),
  3445. (cmd & FUTEX_CLOCK_REALTIME ? "FUTEX_CLOCK_REALTIME|" : ""),
  3446. futex_names[base_cmd]);
  3447. } else {
  3448. qemu_log("0x%x", cmd);
  3449. }
  3450. }
  3451. static void
  3452. print_futex(CPUArchState *cpu_env, const struct syscallname *name,
  3453. abi_long arg0, abi_long arg1, abi_long arg2,
  3454. abi_long arg3, abi_long arg4, abi_long arg5)
  3455. {
  3456. abi_long op = arg1 & FUTEX_CMD_MASK;
  3457. print_syscall_prologue(name);
  3458. print_pointer(arg0, 0);
  3459. print_futex_op(arg1, 0);
  3460. print_raw_param(",%d", arg2, 0);
  3461. switch (op) {
  3462. case FUTEX_WAIT:
  3463. case FUTEX_WAIT_BITSET:
  3464. case FUTEX_LOCK_PI:
  3465. case FUTEX_LOCK_PI2:
  3466. case FUTEX_WAIT_REQUEUE_PI:
  3467. print_timespec(arg3, 0);
  3468. break;
  3469. default:
  3470. print_pointer(arg3, 0);
  3471. break;
  3472. }
  3473. print_pointer(arg4, 0);
  3474. print_raw_param("%d", arg4, 1);
  3475. print_syscall_epilogue(name);
  3476. }
  3477. #endif
  3478. #ifdef TARGET_NR_kill
  3479. static void
  3480. print_kill(CPUArchState *cpu_env, const struct syscallname *name,
  3481. abi_long arg0, abi_long arg1, abi_long arg2,
  3482. abi_long arg3, abi_long arg4, abi_long arg5)
  3483. {
  3484. print_syscall_prologue(name);
  3485. print_raw_param("%d", arg0, 0);
  3486. print_signal(arg1, 1);
  3487. print_syscall_epilogue(name);
  3488. }
  3489. #endif
  3490. #ifdef TARGET_NR_tkill
  3491. static void
  3492. print_tkill(CPUArchState *cpu_env, const struct syscallname *name,
  3493. abi_long arg0, abi_long arg1, abi_long arg2,
  3494. abi_long arg3, abi_long arg4, abi_long arg5)
  3495. {
  3496. print_syscall_prologue(name);
  3497. print_raw_param("%d", arg0, 0);
  3498. print_signal(arg1, 1);
  3499. print_syscall_epilogue(name);
  3500. }
  3501. #endif
  3502. #ifdef TARGET_NR_tgkill
  3503. static void
  3504. print_tgkill(CPUArchState *cpu_env, const struct syscallname *name,
  3505. abi_long arg0, abi_long arg1, abi_long arg2,
  3506. abi_long arg3, abi_long arg4, abi_long arg5)
  3507. {
  3508. print_syscall_prologue(name);
  3509. print_raw_param("%d", arg0, 0);
  3510. print_raw_param("%d", arg1, 0);
  3511. print_signal(arg2, 1);
  3512. print_syscall_epilogue(name);
  3513. }
  3514. #endif
  3515. #ifdef TARGET_NR_statx
  3516. static void
  3517. print_statx(CPUArchState *cpu_env, const struct syscallname *name,
  3518. abi_long arg0, abi_long arg1, abi_long arg2,
  3519. abi_long arg3, abi_long arg4, abi_long arg5)
  3520. {
  3521. print_syscall_prologue(name);
  3522. print_at_dirfd(arg0, 0);
  3523. print_string(arg1, 0);
  3524. print_flags(statx_flags, arg2, 0);
  3525. print_flags(statx_mask, arg3, 0);
  3526. print_pointer(arg4, 1);
  3527. print_syscall_epilogue(name);
  3528. }
  3529. #endif
  3530. #ifdef TARGET_NR_ioctl
  3531. static void
  3532. print_ioctl(CPUArchState *cpu_env, const struct syscallname *name,
  3533. abi_long arg0, abi_long arg1, abi_long arg2,
  3534. abi_long arg3, abi_long arg4, abi_long arg5)
  3535. {
  3536. print_syscall_prologue(name);
  3537. print_raw_param("%d", arg0, 0);
  3538. const IOCTLEntry *ie;
  3539. const argtype *arg_type;
  3540. void *argptr;
  3541. int target_size;
  3542. for (ie = ioctl_entries; ie->target_cmd != 0; ie++) {
  3543. if (ie->target_cmd == arg1) {
  3544. break;
  3545. }
  3546. }
  3547. if (ie->target_cmd == 0) {
  3548. print_raw_param("%#x", arg1, 0);
  3549. print_raw_param("%#x", arg2, 1);
  3550. } else {
  3551. qemu_log("%s", ie->name);
  3552. arg_type = ie->arg_type;
  3553. if (arg_type[0] != TYPE_NULL) {
  3554. qemu_log(",");
  3555. switch (arg_type[0]) {
  3556. case TYPE_PTRVOID:
  3557. print_pointer(arg2, 1);
  3558. break;
  3559. case TYPE_CHAR:
  3560. case TYPE_SHORT:
  3561. case TYPE_INT:
  3562. print_raw_param("%d", arg2, 1);
  3563. break;
  3564. case TYPE_LONG:
  3565. print_raw_param(TARGET_ABI_FMT_ld, arg2, 1);
  3566. break;
  3567. case TYPE_ULONG:
  3568. print_raw_param(TARGET_ABI_FMT_lu, arg2, 1);
  3569. break;
  3570. case TYPE_PTR:
  3571. switch (ie->access) {
  3572. case IOC_R:
  3573. print_pointer(arg2, 1);
  3574. break;
  3575. case IOC_W:
  3576. case IOC_RW:
  3577. arg_type++;
  3578. target_size = thunk_type_size(arg_type, 0);
  3579. argptr = lock_user(VERIFY_READ, arg2, target_size, 1);
  3580. if (argptr) {
  3581. thunk_print(argptr, arg_type);
  3582. unlock_user(argptr, arg2, target_size);
  3583. } else {
  3584. print_pointer(arg2, 1);
  3585. }
  3586. break;
  3587. }
  3588. break;
  3589. default:
  3590. g_assert_not_reached();
  3591. }
  3592. }
  3593. }
  3594. print_syscall_epilogue(name);
  3595. }
  3596. #endif
  3597. /*
  3598. * An array of all of the syscalls we know about
  3599. */
  3600. static const struct syscallname scnames[] = {
  3601. #include "strace.list"
  3602. };
  3603. static int nsyscalls = ARRAY_SIZE(scnames);
  3604. /*
  3605. * The public interface to this module.
  3606. */
  3607. void
  3608. print_syscall(CPUArchState *cpu_env, int num,
  3609. abi_long arg1, abi_long arg2, abi_long arg3,
  3610. abi_long arg4, abi_long arg5, abi_long arg6)
  3611. {
  3612. int i;
  3613. FILE *f;
  3614. const char *format = "%s(" TARGET_ABI_FMT_ld "," TARGET_ABI_FMT_ld ","
  3615. TARGET_ABI_FMT_ld "," TARGET_ABI_FMT_ld ","
  3616. TARGET_ABI_FMT_ld "," TARGET_ABI_FMT_ld ")";
  3617. f = qemu_log_trylock();
  3618. if (!f) {
  3619. return;
  3620. }
  3621. fprintf(f, "%d ", getpid());
  3622. for (i = 0; i < nsyscalls; i++) {
  3623. if (scnames[i].nr == num) {
  3624. if (scnames[i].call != NULL) {
  3625. scnames[i].call(cpu_env, &scnames[i], arg1, arg2, arg3,
  3626. arg4, arg5, arg6);
  3627. } else {
  3628. /* XXX: this format system is broken because it uses
  3629. host types and host pointers for strings */
  3630. if (scnames[i].format != NULL) {
  3631. format = scnames[i].format;
  3632. }
  3633. fprintf(f, format, scnames[i].name, arg1, arg2,
  3634. arg3, arg4, arg5, arg6);
  3635. }
  3636. qemu_log_unlock(f);
  3637. return;
  3638. }
  3639. }
  3640. fprintf(f, "Unknown syscall %d\n", num);
  3641. qemu_log_unlock(f);
  3642. }
  3643. void
  3644. print_syscall_ret(CPUArchState *cpu_env, int num, abi_long ret,
  3645. abi_long arg1, abi_long arg2, abi_long arg3,
  3646. abi_long arg4, abi_long arg5, abi_long arg6)
  3647. {
  3648. int i;
  3649. FILE *f;
  3650. f = qemu_log_trylock();
  3651. if (!f) {
  3652. return;
  3653. }
  3654. for (i = 0; i < nsyscalls; i++) {
  3655. if (scnames[i].nr == num) {
  3656. if (scnames[i].result != NULL) {
  3657. scnames[i].result(cpu_env, &scnames[i], ret,
  3658. arg1, arg2, arg3,
  3659. arg4, arg5, arg6);
  3660. } else {
  3661. if (!print_syscall_err(ret)) {
  3662. fprintf(f, TARGET_ABI_FMT_ld, ret);
  3663. }
  3664. fprintf(f, "\n");
  3665. }
  3666. break;
  3667. }
  3668. }
  3669. qemu_log_unlock(f);
  3670. }
  3671. void print_taken_signal(int target_signum, const target_siginfo_t *tinfo)
  3672. {
  3673. /* Print the strace output for a signal being taken:
  3674. * --- SIGSEGV {si_signo=SIGSEGV, si_code=SI_KERNEL, si_addr=0} ---
  3675. */
  3676. FILE *f;
  3677. f = qemu_log_trylock();
  3678. if (!f) {
  3679. return;
  3680. }
  3681. fprintf(f, "--- ");
  3682. print_signal(target_signum, 1);
  3683. fprintf(f, " ");
  3684. print_siginfo(tinfo);
  3685. fprintf(f, " ---\n");
  3686. qemu_log_unlock(f);
  3687. }