12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193 |
- #include "qemu/osdep.h"
- #include <sys/ipc.h>
- #include <sys/msg.h>
- #include <sys/sem.h>
- #include <sys/shm.h>
- #include <sys/select.h>
- #include <sys/mount.h>
- #include <arpa/inet.h>
- #include <netinet/in.h>
- #include <netinet/tcp.h>
- #include <netinet/udp.h>
- #include <linux/if_packet.h>
- #include <linux/in6.h>
- #include <linux/netlink.h>
- #include <sched.h>
- #include "qemu.h"
- #include "user-internals.h"
- #include "strace.h"
- #include "signal-common.h"
- #include "target_mman.h"
- struct syscallname {
- int nr;
- const char *name;
- const char *format;
- void (*call)(CPUArchState *, const struct syscallname *,
- abi_long, abi_long, abi_long,
- abi_long, abi_long, abi_long);
- void (*result)(CPUArchState *, const struct syscallname *, abi_long,
- abi_long, abi_long, abi_long,
- abi_long, abi_long, abi_long);
- };
- /*
- * It is possible that target doesn't have syscall that uses
- * following flags but we don't want the compiler to warn
- * us about them being unused. Same applies to utility print
- * functions. It is ok to keep them while not used.
- */
- #define UNUSED __attribute__ ((unused))
- /*
- * Structure used to translate flag values into strings. This is
- * similar that is in the actual strace tool.
- */
- struct flags {
- abi_long f_value; /* flag */
- const char *f_string; /* stringified flag */
- };
- /* common flags for all architectures */
- #define FLAG_GENERIC(name) { name, #name }
- /* target specific flags (syscall_defs.h has TARGET_<flag>) */
- #define FLAG_TARGET(name) { TARGET_ ## name, #name }
- /* end of flags array */
- #define FLAG_END { 0, NULL }
- /* Structure used to translate enumerated values into strings */
- struct enums {
- abi_long e_value; /* enum value */
- const char *e_string; /* stringified enum */
- };
- /* common enums for all architectures */
- #define ENUM_GENERIC(name) { name, #name }
- /* target specific enums */
- #define ENUM_TARGET(name) { TARGET_ ## name, #name }
- /* end of enums array */
- #define ENUM_END { 0, NULL }
- UNUSED static const char *get_comma(int);
- UNUSED static void print_pointer(abi_long, int);
- UNUSED static void print_flags(const struct flags *, abi_long, int);
- UNUSED static void print_enums(const struct enums *, abi_long, int);
- UNUSED static void print_at_dirfd(abi_long, int);
- UNUSED static void print_file_mode(abi_long, int);
- UNUSED static void print_open_flags(abi_long, int);
- UNUSED static void print_syscall_prologue(const struct syscallname *);
- UNUSED static void print_syscall_epilogue(const struct syscallname *);
- UNUSED static void print_string(abi_long, int);
- UNUSED static void print_buf(abi_long addr, abi_long len, int last);
- UNUSED static void print_raw_param(const char *, abi_long, int);
- UNUSED static void print_raw_param64(const char *, long long, int last);
- UNUSED static void print_timeval(abi_ulong, int);
- UNUSED static void print_timespec(abi_ulong, int);
- UNUSED static void print_timespec64(abi_ulong, int);
- UNUSED static void print_timezone(abi_ulong, int);
- UNUSED static void print_itimerval(abi_ulong, int);
- UNUSED static void print_number(abi_long, int);
- UNUSED static void print_signal(abi_ulong, int);
- UNUSED static void print_sockaddr(abi_ulong, abi_long, int);
- UNUSED static void print_socket_domain(int domain);
- UNUSED static void print_socket_type(int type);
- UNUSED static void print_socket_protocol(int domain, int type, int protocol);
- /*
- * Utility functions
- */
- static void
- print_ipc_cmd(int cmd)
- {
- #define output_cmd(val) \
- if( cmd == val ) { \
- qemu_log(#val); \
- return; \
- }
- cmd &= 0xff;
- /* General IPC commands */
- output_cmd( IPC_RMID );
- output_cmd( IPC_SET );
- output_cmd( IPC_STAT );
- output_cmd( IPC_INFO );
- /* msgctl() commands */
- output_cmd( MSG_STAT );
- output_cmd( MSG_INFO );
- /* shmctl() commands */
- output_cmd( SHM_LOCK );
- output_cmd( SHM_UNLOCK );
- output_cmd( SHM_STAT );
- output_cmd( SHM_INFO );
- /* semctl() commands */
- output_cmd( GETPID );
- output_cmd( GETVAL );
- output_cmd( GETALL );
- output_cmd( GETNCNT );
- output_cmd( GETZCNT );
- output_cmd( SETVAL );
- output_cmd( SETALL );
- output_cmd( SEM_STAT );
- output_cmd( SEM_INFO );
- output_cmd( IPC_RMID );
- output_cmd( IPC_RMID );
- output_cmd( IPC_RMID );
- output_cmd( IPC_RMID );
- output_cmd( IPC_RMID );
- output_cmd( IPC_RMID );
- output_cmd( IPC_RMID );
- output_cmd( IPC_RMID );
- output_cmd( IPC_RMID );
- /* Some value we don't recognize */
- qemu_log("%d", cmd);
- }
- static const char * const target_signal_name[] = {
- #define MAKE_SIG_ENTRY(sig) [TARGET_##sig] = #sig,
- MAKE_SIGNAL_LIST
- #undef MAKE_SIG_ENTRY
- };
- static void
- print_signal(abi_ulong arg, int last)
- {
- const char *signal_name = NULL;
- if (arg < ARRAY_SIZE(target_signal_name)) {
- signal_name = target_signal_name[arg];
- }
- if (signal_name == NULL) {
- print_raw_param("%ld", arg, last);
- return;
- }
- qemu_log("%s%s", signal_name, get_comma(last));
- }
- static void print_si_code(int arg)
- {
- const char *codename = NULL;
- switch (arg) {
- case SI_USER:
- codename = "SI_USER";
- break;
- case SI_KERNEL:
- codename = "SI_KERNEL";
- break;
- case SI_QUEUE:
- codename = "SI_QUEUE";
- break;
- case SI_TIMER:
- codename = "SI_TIMER";
- break;
- case SI_MESGQ:
- codename = "SI_MESGQ";
- break;
- case SI_ASYNCIO:
- codename = "SI_ASYNCIO";
- break;
- case SI_SIGIO:
- codename = "SI_SIGIO";
- break;
- case SI_TKILL:
- codename = "SI_TKILL";
- break;
- default:
- qemu_log("%d", arg);
- return;
- }
- qemu_log("%s", codename);
- }
- static void get_target_siginfo(target_siginfo_t *tinfo,
- const target_siginfo_t *info)
- {
- abi_ulong sival_ptr;
- int sig;
- int si_errno;
- int si_code;
- int si_type;
- __get_user(sig, &info->si_signo);
- __get_user(si_errno, &tinfo->si_errno);
- __get_user(si_code, &info->si_code);
- tinfo->si_signo = sig;
- tinfo->si_errno = si_errno;
- tinfo->si_code = si_code;
- /* Ensure we don't leak random junk to the guest later */
- memset(tinfo->_sifields._pad, 0, sizeof(tinfo->_sifields._pad));
- /* This is awkward, because we have to use a combination of
- * the si_code and si_signo to figure out which of the union's
- * members are valid. (Within the host kernel it is always possible
- * to tell, but the kernel carefully avoids giving userspace the
- * high 16 bits of si_code, so we don't have the information to
- * do this the easy way...) We therefore make our best guess,
- * bearing in mind that a guest can spoof most of the si_codes
- * via rt_sigqueueinfo() if it likes.
- *
- * Once we have made our guess, we record it in the top 16 bits of
- * the si_code, so that print_siginfo() later can use it.
- * print_siginfo() will strip these top bits out before printing
- * the si_code.
- */
- switch (si_code) {
- case SI_USER:
- case SI_TKILL:
- case SI_KERNEL:
- /* Sent via kill(), tkill() or tgkill(), or direct from the kernel.
- * These are the only unspoofable si_code values.
- */
- __get_user(tinfo->_sifields._kill._pid, &info->_sifields._kill._pid);
- __get_user(tinfo->_sifields._kill._uid, &info->_sifields._kill._uid);
- si_type = QEMU_SI_KILL;
- break;
- default:
- /* Everything else is spoofable. Make best guess based on signal */
- switch (sig) {
- case TARGET_SIGCHLD:
- __get_user(tinfo->_sifields._sigchld._pid,
- &info->_sifields._sigchld._pid);
- __get_user(tinfo->_sifields._sigchld._uid,
- &info->_sifields._sigchld._uid);
- __get_user(tinfo->_sifields._sigchld._status,
- &info->_sifields._sigchld._status);
- __get_user(tinfo->_sifields._sigchld._utime,
- &info->_sifields._sigchld._utime);
- __get_user(tinfo->_sifields._sigchld._stime,
- &info->_sifields._sigchld._stime);
- si_type = QEMU_SI_CHLD;
- break;
- case TARGET_SIGIO:
- __get_user(tinfo->_sifields._sigpoll._band,
- &info->_sifields._sigpoll._band);
- __get_user(tinfo->_sifields._sigpoll._fd,
- &info->_sifields._sigpoll._fd);
- si_type = QEMU_SI_POLL;
- break;
- default:
- /* Assume a sigqueue()/mq_notify()/rt_sigqueueinfo() source. */
- __get_user(tinfo->_sifields._rt._pid, &info->_sifields._rt._pid);
- __get_user(tinfo->_sifields._rt._uid, &info->_sifields._rt._uid);
- /* XXX: potential problem if 64 bit */
- __get_user(sival_ptr, &info->_sifields._rt._sigval.sival_ptr);
- tinfo->_sifields._rt._sigval.sival_ptr = sival_ptr;
- si_type = QEMU_SI_RT;
- break;
- }
- break;
- }
- tinfo->si_code = deposit32(si_code, 16, 16, si_type);
- }
- static void print_siginfo(const target_siginfo_t *tinfo)
- {
- /* Print a target_siginfo_t in the format desired for printing
- * signals being taken. We assume the target_siginfo_t is in the
- * internal form where the top 16 bits of si_code indicate which
- * part of the union is valid, rather than in the guest-visible
- * form where the bottom 16 bits are sign-extended into the top 16.
- */
- int si_type = extract32(tinfo->si_code, 16, 16);
- int si_code = sextract32(tinfo->si_code, 0, 16);
- qemu_log("{si_signo=");
- print_signal(tinfo->si_signo, 1);
- qemu_log(", si_code=");
- print_si_code(si_code);
- switch (si_type) {
- case QEMU_SI_KILL:
- qemu_log(", si_pid=%u, si_uid=%u",
- (unsigned int)tinfo->_sifields._kill._pid,
- (unsigned int)tinfo->_sifields._kill._uid);
- break;
- case QEMU_SI_TIMER:
- qemu_log(", si_timer1=%u, si_timer2=%u",
- tinfo->_sifields._timer._timer1,
- tinfo->_sifields._timer._timer2);
- break;
- case QEMU_SI_POLL:
- qemu_log(", si_band=%d, si_fd=%d",
- tinfo->_sifields._sigpoll._band,
- tinfo->_sifields._sigpoll._fd);
- break;
- case QEMU_SI_FAULT:
- qemu_log(", si_addr=");
- print_pointer(tinfo->_sifields._sigfault._addr, 1);
- break;
- case QEMU_SI_CHLD:
- qemu_log(", si_pid=%u, si_uid=%u, si_status=%d"
- ", si_utime=" TARGET_ABI_FMT_ld
- ", si_stime=" TARGET_ABI_FMT_ld,
- (unsigned int)(tinfo->_sifields._sigchld._pid),
- (unsigned int)(tinfo->_sifields._sigchld._uid),
- tinfo->_sifields._sigchld._status,
- tinfo->_sifields._sigchld._utime,
- tinfo->_sifields._sigchld._stime);
- break;
- case QEMU_SI_RT:
- qemu_log(", si_pid=%u, si_uid=%u, si_sigval=" TARGET_ABI_FMT_ld,
- (unsigned int)tinfo->_sifields._rt._pid,
- (unsigned int)tinfo->_sifields._rt._uid,
- tinfo->_sifields._rt._sigval.sival_ptr);
- break;
- default:
- g_assert_not_reached();
- }
- qemu_log("}");
- }
- static void
- print_sockaddr(abi_ulong addr, abi_long addrlen, int last)
- {
- struct target_sockaddr *sa;
- int i;
- int sa_family;
- sa = lock_user(VERIFY_READ, addr, addrlen, 1);
- if (sa) {
- sa_family = tswap16(sa->sa_family);
- switch (sa_family) {
- case AF_UNIX: {
- struct target_sockaddr_un *un = (struct target_sockaddr_un *)sa;
- int i;
- qemu_log("{sun_family=AF_UNIX,sun_path=\"");
- for (i = 0; i < addrlen -
- offsetof(struct target_sockaddr_un, sun_path) &&
- un->sun_path[i]; i++) {
- qemu_log("%c", un->sun_path[i]);
- }
- qemu_log("\"}");
- break;
- }
- case AF_INET: {
- struct target_sockaddr_in *in = (struct target_sockaddr_in *)sa;
- uint8_t *c = (uint8_t *)&in->sin_addr.s_addr;
- qemu_log("{sin_family=AF_INET,sin_port=htons(%d),",
- ntohs(in->sin_port));
- qemu_log("sin_addr=inet_addr(\"%d.%d.%d.%d\")",
- c[0], c[1], c[2], c[3]);
- qemu_log("}");
- break;
- }
- case AF_PACKET: {
- struct target_sockaddr_ll *ll = (struct target_sockaddr_ll *)sa;
- uint8_t *c = (uint8_t *)&ll->sll_addr;
- qemu_log("{sll_family=AF_PACKET,"
- "sll_protocol=htons(0x%04x),if%d,pkttype=",
- ntohs(ll->sll_protocol), ll->sll_ifindex);
- switch (ll->sll_pkttype) {
- case PACKET_HOST:
- qemu_log("PACKET_HOST");
- break;
- case PACKET_BROADCAST:
- qemu_log("PACKET_BROADCAST");
- break;
- case PACKET_MULTICAST:
- qemu_log("PACKET_MULTICAST");
- break;
- case PACKET_OTHERHOST:
- qemu_log("PACKET_OTHERHOST");
- break;
- case PACKET_OUTGOING:
- qemu_log("PACKET_OUTGOING");
- break;
- default:
- qemu_log("%d", ll->sll_pkttype);
- break;
- }
- qemu_log(",sll_addr=%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x",
- c[0], c[1], c[2], c[3], c[4], c[5], c[6], c[7]);
- qemu_log("}");
- break;
- }
- case AF_NETLINK: {
- struct target_sockaddr_nl *nl = (struct target_sockaddr_nl *)sa;
- qemu_log("{nl_family=AF_NETLINK,nl_pid=%u,nl_groups=%u}",
- tswap32(nl->nl_pid), tswap32(nl->nl_groups));
- break;
- }
- default:
- qemu_log("{sa_family=%d, sa_data={", sa->sa_family);
- for (i = 0; i < 13; i++) {
- qemu_log("%02x, ", sa->sa_data[i]);
- }
- qemu_log("%02x}", sa->sa_data[i]);
- qemu_log("}");
- break;
- }
- unlock_user(sa, addr, 0);
- } else {
- print_raw_param("0x"TARGET_ABI_FMT_lx, addr, 0);
- }
- qemu_log(", "TARGET_ABI_FMT_ld"%s", addrlen, get_comma(last));
- }
- static void
- print_socket_domain(int domain)
- {
- switch (domain) {
- case PF_UNIX:
- qemu_log("PF_UNIX");
- break;
- case PF_INET:
- qemu_log("PF_INET");
- break;
- case PF_NETLINK:
- qemu_log("PF_NETLINK");
- break;
- case PF_PACKET:
- qemu_log("PF_PACKET");
- break;
- default:
- qemu_log("%d", domain);
- break;
- }
- }
- static void
- print_socket_type(int type)
- {
- switch (type & TARGET_SOCK_TYPE_MASK) {
- case TARGET_SOCK_DGRAM:
- qemu_log("SOCK_DGRAM");
- break;
- case TARGET_SOCK_STREAM:
- qemu_log("SOCK_STREAM");
- break;
- case TARGET_SOCK_RAW:
- qemu_log("SOCK_RAW");
- break;
- case TARGET_SOCK_RDM:
- qemu_log("SOCK_RDM");
- break;
- case TARGET_SOCK_SEQPACKET:
- qemu_log("SOCK_SEQPACKET");
- break;
- case TARGET_SOCK_PACKET:
- qemu_log("SOCK_PACKET");
- break;
- }
- if (type & TARGET_SOCK_CLOEXEC) {
- qemu_log("|SOCK_CLOEXEC");
- }
- if (type & TARGET_SOCK_NONBLOCK) {
- qemu_log("|SOCK_NONBLOCK");
- }
- }
- static void
- print_socket_protocol(int domain, int type, int protocol)
- {
- if (domain == AF_PACKET ||
- (domain == AF_INET && type == TARGET_SOCK_PACKET)) {
- switch (protocol) {
- case 0x0003:
- qemu_log("ETH_P_ALL");
- break;
- default:
- qemu_log("%d", protocol);
- }
- return;
- }
- if (domain == PF_NETLINK) {
- switch (protocol) {
- case NETLINK_ROUTE:
- qemu_log("NETLINK_ROUTE");
- break;
- case NETLINK_UNUSED:
- qemu_log("NETLINK_UNUSED");
- break;
- case NETLINK_USERSOCK:
- qemu_log("NETLINK_USERSOCK");
- break;
- case NETLINK_FIREWALL:
- qemu_log("NETLINK_FIREWALL");
- break;
- case NETLINK_SOCK_DIAG:
- qemu_log("NETLINK_SOCK_DIAG");
- break;
- case NETLINK_NFLOG:
- qemu_log("NETLINK_NFLOG");
- break;
- case NETLINK_XFRM:
- qemu_log("NETLINK_XFRM");
- break;
- case NETLINK_SELINUX:
- qemu_log("NETLINK_SELINUX");
- break;
- case NETLINK_ISCSI:
- qemu_log("NETLINK_ISCSI");
- break;
- case NETLINK_AUDIT:
- qemu_log("NETLINK_AUDIT");
- break;
- case NETLINK_FIB_LOOKUP:
- qemu_log("NETLINK_FIB_LOOKUP");
- break;
- case NETLINK_CONNECTOR:
- qemu_log("NETLINK_CONNECTOR");
- break;
- case NETLINK_NETFILTER:
- qemu_log("NETLINK_NETFILTER");
- break;
- case NETLINK_IP6_FW:
- qemu_log("NETLINK_IP6_FW");
- break;
- case NETLINK_DNRTMSG:
- qemu_log("NETLINK_DNRTMSG");
- break;
- case NETLINK_KOBJECT_UEVENT:
- qemu_log("NETLINK_KOBJECT_UEVENT");
- break;
- case NETLINK_GENERIC:
- qemu_log("NETLINK_GENERIC");
- break;
- case NETLINK_SCSITRANSPORT:
- qemu_log("NETLINK_SCSITRANSPORT");
- break;
- case NETLINK_ECRYPTFS:
- qemu_log("NETLINK_ECRYPTFS");
- break;
- case NETLINK_RDMA:
- qemu_log("NETLINK_RDMA");
- break;
- case NETLINK_CRYPTO:
- qemu_log("NETLINK_CRYPTO");
- break;
- case NETLINK_SMC:
- qemu_log("NETLINK_SMC");
- break;
- default:
- qemu_log("%d", protocol);
- break;
- }
- return;
- }
- switch (protocol) {
- case IPPROTO_IP:
- qemu_log("IPPROTO_IP");
- break;
- case IPPROTO_TCP:
- qemu_log("IPPROTO_TCP");
- break;
- case IPPROTO_UDP:
- qemu_log("IPPROTO_UDP");
- break;
- case IPPROTO_RAW:
- qemu_log("IPPROTO_RAW");
- break;
- default:
- qemu_log("%d", protocol);
- break;
- }
- }
- #ifdef TARGET_NR__newselect
- static void
- print_fdset(int n, abi_ulong target_fds_addr)
- {
- int i;
- int first = 1;
- qemu_log("[");
- if( target_fds_addr ) {
- abi_long *target_fds;
- target_fds = lock_user(VERIFY_READ,
- target_fds_addr,
- sizeof(*target_fds)*(n / TARGET_ABI_BITS + 1),
- 1);
- if (!target_fds)
- return;
- for (i=n; i>=0; i--) {
- if ((tswapal(target_fds[i / TARGET_ABI_BITS]) >>
- (i & (TARGET_ABI_BITS - 1))) & 1) {
- qemu_log("%s%d", get_comma(first), i);
- first = 0;
- }
- }
- unlock_user(target_fds, target_fds_addr, 0);
- }
- qemu_log("]");
- }
- #endif
- /*
- * Sysycall specific output functions
- */
- /* select */
- #ifdef TARGET_NR__newselect
- static void
- print_newselect(CPUArchState *cpu_env, const struct syscallname *name,
- abi_long arg1, abi_long arg2, abi_long arg3,
- abi_long arg4, abi_long arg5, abi_long arg6)
- {
- print_syscall_prologue(name);
- print_fdset(arg1, arg2);
- qemu_log(",");
- print_fdset(arg1, arg3);
- qemu_log(",");
- print_fdset(arg1, arg4);
- qemu_log(",");
- print_timeval(arg5, 1);
- print_syscall_epilogue(name);
- }
- #endif
- #ifdef TARGET_NR_semctl
- static void
- print_semctl(CPUArchState *cpu_env, const struct syscallname *name,
- abi_long arg1, abi_long arg2, abi_long arg3,
- abi_long arg4, abi_long arg5, abi_long arg6)
- {
- qemu_log("%s(" TARGET_ABI_FMT_ld "," TARGET_ABI_FMT_ld ",",
- name->name, arg1, arg2);
- print_ipc_cmd(arg3);
- qemu_log(",0x" TARGET_ABI_FMT_lx ")", arg4);
- }
- #endif
- #ifdef TARGET_NR_ipc
- static void
- print_ipc(CPUArchState *cpu_env, const struct syscallname *name,
- abi_long arg1, abi_long arg2, abi_long arg3,
- abi_long arg4, abi_long arg5, abi_long arg6)
- {
- switch(arg1) {
- case IPCOP_semctl:
- qemu_log("semctl(" TARGET_ABI_FMT_ld "," TARGET_ABI_FMT_ld ",",
- arg1, arg2);
- print_ipc_cmd(arg3);
- qemu_log(",0x" TARGET_ABI_FMT_lx ")", arg4);
- break;
- default:
- qemu_log(("%s("
- TARGET_ABI_FMT_ld ","
- TARGET_ABI_FMT_ld ","
- TARGET_ABI_FMT_ld ","
- TARGET_ABI_FMT_ld
- ")"),
- name->name, arg1, arg2, arg3, arg4);
- }
- }
- #endif
- /*
- * Variants for the return value output function
- */
- static bool
- print_syscall_err(abi_long ret)
- {
- const char *errstr;
- qemu_log(" = ");
- if (is_error(ret)) {
- errstr = target_strerror(-ret);
- if (errstr) {
- qemu_log("-1 errno=%d (%s)", (int)-ret, errstr);
- return true;
- }
- }
- return false;
- }
- static void
- print_syscall_ret_addr(CPUArchState *cpu_env, const struct syscallname *name,
- abi_long ret, abi_long arg0, abi_long arg1,
- abi_long arg2, abi_long arg3, abi_long arg4,
- abi_long arg5)
- {
- if (!print_syscall_err(ret)) {
- qemu_log("0x" TARGET_ABI_FMT_lx, ret);
- }
- qemu_log("\n");
- }
- #if 0 /* currently unused */
- static void
- print_syscall_ret_raw(struct syscallname *name, abi_long ret)
- {
- qemu_log(" = 0x" TARGET_ABI_FMT_lx "\n", ret);
- }
- #endif
- #ifdef TARGET_NR__newselect
- static void
- print_syscall_ret_newselect(CPUArchState *cpu_env, const struct syscallname *name,
- abi_long ret, abi_long arg0, abi_long arg1,
- abi_long arg2, abi_long arg3, abi_long arg4,
- abi_long arg5)
- {
- if (!print_syscall_err(ret)) {
- qemu_log(" = 0x" TARGET_ABI_FMT_lx " (", ret);
- print_fdset(arg0, arg1);
- qemu_log(",");
- print_fdset(arg0, arg2);
- qemu_log(",");
- print_fdset(arg0, arg3);
- qemu_log(",");
- print_timeval(arg4, 1);
- qemu_log(")");
- }
- qemu_log("\n");
- }
- #endif
- /* special meanings of adjtimex()' non-negative return values */
- #define TARGET_TIME_OK 0 /* clock synchronized, no leap second */
- #define TARGET_TIME_INS 1 /* insert leap second */
- #define TARGET_TIME_DEL 2 /* delete leap second */
- #define TARGET_TIME_OOP 3 /* leap second in progress */
- #define TARGET_TIME_WAIT 4 /* leap second has occurred */
- #define TARGET_TIME_ERROR 5 /* clock not synchronized */
- #ifdef TARGET_NR_adjtimex
- static void
- print_syscall_ret_adjtimex(CPUArchState *cpu_env, const struct syscallname *name,
- abi_long ret, abi_long arg0, abi_long arg1,
- abi_long arg2, abi_long arg3, abi_long arg4,
- abi_long arg5)
- {
- if (!print_syscall_err(ret)) {
- qemu_log(TARGET_ABI_FMT_ld, ret);
- switch (ret) {
- case TARGET_TIME_OK:
- qemu_log(" TIME_OK (clock synchronized, no leap second)");
- break;
- case TARGET_TIME_INS:
- qemu_log(" TIME_INS (insert leap second)");
- break;
- case TARGET_TIME_DEL:
- qemu_log(" TIME_DEL (delete leap second)");
- break;
- case TARGET_TIME_OOP:
- qemu_log(" TIME_OOP (leap second in progress)");
- break;
- case TARGET_TIME_WAIT:
- qemu_log(" TIME_WAIT (leap second has occurred)");
- break;
- case TARGET_TIME_ERROR:
- qemu_log(" TIME_ERROR (clock not synchronized)");
- break;
- }
- }
- qemu_log("\n");
- }
- #endif
- #if defined(TARGET_NR_clock_gettime) || defined(TARGET_NR_clock_getres)
- static void
- print_syscall_ret_clock_gettime(CPUArchState *cpu_env, const struct syscallname *name,
- abi_long ret, abi_long arg0, abi_long arg1,
- abi_long arg2, abi_long arg3, abi_long arg4,
- abi_long arg5)
- {
- if (!print_syscall_err(ret)) {
- qemu_log(TARGET_ABI_FMT_ld, ret);
- qemu_log(" (");
- print_timespec(arg1, 1);
- qemu_log(")");
- }
- qemu_log("\n");
- }
- #define print_syscall_ret_clock_getres print_syscall_ret_clock_gettime
- #endif
- #if defined(TARGET_NR_clock_gettime64)
- static void
- print_syscall_ret_clock_gettime64(CPUArchState *cpu_env, const struct syscallname *name,
- abi_long ret, abi_long arg0, abi_long arg1,
- abi_long arg2, abi_long arg3, abi_long arg4,
- abi_long arg5)
- {
- if (!print_syscall_err(ret)) {
- qemu_log(TARGET_ABI_FMT_ld, ret);
- qemu_log(" (");
- print_timespec64(arg1, 1);
- qemu_log(")");
- }
- qemu_log("\n");
- }
- #endif
- #ifdef TARGET_NR_gettimeofday
- static void
- print_syscall_ret_gettimeofday(CPUArchState *cpu_env, const struct syscallname *name,
- abi_long ret, abi_long arg0, abi_long arg1,
- abi_long arg2, abi_long arg3, abi_long arg4,
- abi_long arg5)
- {
- if (!print_syscall_err(ret)) {
- qemu_log(TARGET_ABI_FMT_ld, ret);
- qemu_log(" (");
- print_timeval(arg0, 0);
- print_timezone(arg1, 1);
- qemu_log(")");
- }
- qemu_log("\n");
- }
- #endif
- #ifdef TARGET_NR_getitimer
- static void
- print_syscall_ret_getitimer(CPUArchState *cpu_env, const struct syscallname *name,
- abi_long ret, abi_long arg0, abi_long arg1,
- abi_long arg2, abi_long arg3, abi_long arg4,
- abi_long arg5)
- {
- if (!print_syscall_err(ret)) {
- qemu_log(TARGET_ABI_FMT_ld, ret);
- qemu_log(" (");
- print_itimerval(arg1, 1);
- qemu_log(")");
- }
- qemu_log("\n");
- }
- #endif
- #ifdef TARGET_NR_getitimer
- static void
- print_syscall_ret_setitimer(CPUArchState *cpu_env, const struct syscallname *name,
- abi_long ret, abi_long arg0, abi_long arg1,
- abi_long arg2, abi_long arg3, abi_long arg4,
- abi_long arg5)
- {
- if (!print_syscall_err(ret)) {
- qemu_log(TARGET_ABI_FMT_ld, ret);
- qemu_log(" (old_value = ");
- print_itimerval(arg2, 1);
- qemu_log(")");
- }
- qemu_log("\n");
- }
- #endif
- #if defined(TARGET_NR_listxattr) || defined(TARGET_NR_llistxattr) \
- || defined(TARGGET_NR_flistxattr)
- static void
- print_syscall_ret_listxattr(CPUArchState *cpu_env, const struct syscallname *name,
- abi_long ret, abi_long arg0, abi_long arg1,
- abi_long arg2, abi_long arg3, abi_long arg4,
- abi_long arg5)
- {
- if (!print_syscall_err(ret)) {
- qemu_log(TARGET_ABI_FMT_ld, ret);
- qemu_log(" (list = ");
- if (arg1 != 0) {
- abi_long attr = arg1;
- while (ret) {
- if (attr != arg1) {
- qemu_log(",");
- }
- print_string(attr, 1);
- ret -= target_strlen(attr) + 1;
- attr += target_strlen(attr) + 1;
- }
- } else {
- qemu_log("NULL");
- }
- qemu_log(")");
- }
- qemu_log("\n");
- }
- #define print_syscall_ret_llistxattr print_syscall_ret_listxattr
- #define print_syscall_ret_flistxattr print_syscall_ret_listxattr
- #endif
- #ifdef TARGET_NR_ioctl
- static void
- print_syscall_ret_ioctl(CPUArchState *cpu_env, const struct syscallname *name,
- abi_long ret, abi_long arg0, abi_long arg1,
- abi_long arg2, abi_long arg3, abi_long arg4,
- abi_long arg5)
- {
- if (!print_syscall_err(ret)) {
- qemu_log(TARGET_ABI_FMT_ld, ret);
- const IOCTLEntry *ie;
- const argtype *arg_type;
- void *argptr;
- int target_size;
- for (ie = ioctl_entries; ie->target_cmd != 0; ie++) {
- if (ie->target_cmd == arg1) {
- break;
- }
- }
- if (ie->target_cmd == arg1 &&
- (ie->access == IOC_R || ie->access == IOC_RW)) {
- arg_type = ie->arg_type;
- qemu_log(" (");
- arg_type++;
- target_size = thunk_type_size(arg_type, 0);
- argptr = lock_user(VERIFY_READ, arg2, target_size, 1);
- if (argptr) {
- thunk_print(argptr, arg_type);
- unlock_user(argptr, arg2, target_size);
- } else {
- print_pointer(arg2, 1);
- }
- qemu_log(")");
- }
- }
- qemu_log("\n");
- }
- #endif
- UNUSED static const struct flags access_flags[] = {
- FLAG_GENERIC(F_OK),
- FLAG_GENERIC(R_OK),
- FLAG_GENERIC(W_OK),
- FLAG_GENERIC(X_OK),
- FLAG_END,
- };
- UNUSED static const struct flags at_file_flags[] = {
- #ifdef AT_EACCESS
- FLAG_GENERIC(AT_EACCESS),
- #endif
- #ifdef AT_SYMLINK_NOFOLLOW
- FLAG_GENERIC(AT_SYMLINK_NOFOLLOW),
- #endif
- FLAG_END,
- };
- UNUSED static const struct flags unlinkat_flags[] = {
- #ifdef AT_REMOVEDIR
- FLAG_GENERIC(AT_REMOVEDIR),
- #endif
- FLAG_END,
- };
- UNUSED static const struct flags mode_flags[] = {
- FLAG_GENERIC(S_IFSOCK),
- FLAG_GENERIC(S_IFLNK),
- FLAG_GENERIC(S_IFREG),
- FLAG_GENERIC(S_IFBLK),
- FLAG_GENERIC(S_IFDIR),
- FLAG_GENERIC(S_IFCHR),
- FLAG_GENERIC(S_IFIFO),
- FLAG_END,
- };
- UNUSED static const struct flags open_access_flags[] = {
- FLAG_TARGET(O_RDONLY),
- FLAG_TARGET(O_WRONLY),
- FLAG_TARGET(O_RDWR),
- FLAG_END,
- };
- UNUSED static const struct flags open_flags[] = {
- FLAG_TARGET(O_APPEND),
- FLAG_TARGET(O_CREAT),
- FLAG_TARGET(O_DIRECTORY),
- FLAG_TARGET(O_EXCL),
- FLAG_TARGET(O_LARGEFILE),
- FLAG_TARGET(O_NOCTTY),
- FLAG_TARGET(O_NOFOLLOW),
- FLAG_TARGET(O_NONBLOCK), /* also O_NDELAY */
- FLAG_TARGET(O_DSYNC),
- FLAG_TARGET(__O_SYNC),
- FLAG_TARGET(O_TRUNC),
- #ifdef O_DIRECT
- FLAG_TARGET(O_DIRECT),
- #endif
- #ifdef O_NOATIME
- FLAG_TARGET(O_NOATIME),
- #endif
- #ifdef O_CLOEXEC
- FLAG_TARGET(O_CLOEXEC),
- #endif
- #ifdef O_PATH
- FLAG_TARGET(O_PATH),
- #endif
- #ifdef O_TMPFILE
- FLAG_TARGET(O_TMPFILE),
- FLAG_TARGET(__O_TMPFILE),
- #endif
- FLAG_END,
- };
- UNUSED static const struct flags mount_flags[] = {
- #ifdef MS_BIND
- FLAG_GENERIC(MS_BIND),
- #endif
- #ifdef MS_DIRSYNC
- FLAG_GENERIC(MS_DIRSYNC),
- #endif
- FLAG_GENERIC(MS_MANDLOCK),
- #ifdef MS_MOVE
- FLAG_GENERIC(MS_MOVE),
- #endif
- FLAG_GENERIC(MS_NOATIME),
- FLAG_GENERIC(MS_NODEV),
- FLAG_GENERIC(MS_NODIRATIME),
- FLAG_GENERIC(MS_NOEXEC),
- FLAG_GENERIC(MS_NOSUID),
- FLAG_GENERIC(MS_RDONLY),
- #ifdef MS_RELATIME
- FLAG_GENERIC(MS_RELATIME),
- #endif
- FLAG_GENERIC(MS_REMOUNT),
- FLAG_GENERIC(MS_SYNCHRONOUS),
- FLAG_END,
- };
- UNUSED static const struct flags umount2_flags[] = {
- #ifdef MNT_FORCE
- FLAG_GENERIC(MNT_FORCE),
- #endif
- #ifdef MNT_DETACH
- FLAG_GENERIC(MNT_DETACH),
- #endif
- #ifdef MNT_EXPIRE
- FLAG_GENERIC(MNT_EXPIRE),
- #endif
- FLAG_END,
- };
- UNUSED static const struct flags mmap_prot_flags[] = {
- FLAG_GENERIC(PROT_NONE),
- FLAG_GENERIC(PROT_EXEC),
- FLAG_GENERIC(PROT_READ),
- FLAG_GENERIC(PROT_WRITE),
- FLAG_TARGET(PROT_SEM),
- FLAG_GENERIC(PROT_GROWSDOWN),
- FLAG_GENERIC(PROT_GROWSUP),
- FLAG_END,
- };
- UNUSED static const struct flags mmap_flags[] = {
- FLAG_TARGET(MAP_SHARED),
- FLAG_TARGET(MAP_PRIVATE),
- FLAG_TARGET(MAP_ANONYMOUS),
- FLAG_TARGET(MAP_DENYWRITE),
- FLAG_TARGET(MAP_FIXED),
- FLAG_TARGET(MAP_GROWSDOWN),
- FLAG_TARGET(MAP_EXECUTABLE),
- #ifdef MAP_LOCKED
- FLAG_TARGET(MAP_LOCKED),
- #endif
- #ifdef MAP_NONBLOCK
- FLAG_TARGET(MAP_NONBLOCK),
- #endif
- FLAG_TARGET(MAP_NORESERVE),
- #ifdef MAP_POPULATE
- FLAG_TARGET(MAP_POPULATE),
- #endif
- #ifdef TARGET_MAP_UNINITIALIZED
- FLAG_TARGET(MAP_UNINITIALIZED),
- #endif
- FLAG_TARGET(MAP_HUGETLB),
- FLAG_TARGET(MAP_STACK),
- FLAG_END,
- };
- #ifndef CLONE_PIDFD
- # define CLONE_PIDFD 0x00001000
- #endif
- UNUSED static const struct flags clone_flags[] = {
- FLAG_GENERIC(CLONE_VM),
- FLAG_GENERIC(CLONE_FS),
- FLAG_GENERIC(CLONE_FILES),
- FLAG_GENERIC(CLONE_SIGHAND),
- FLAG_GENERIC(CLONE_PIDFD),
- FLAG_GENERIC(CLONE_PTRACE),
- FLAG_GENERIC(CLONE_VFORK),
- FLAG_GENERIC(CLONE_PARENT),
- FLAG_GENERIC(CLONE_THREAD),
- FLAG_GENERIC(CLONE_NEWNS),
- FLAG_GENERIC(CLONE_SYSVSEM),
- FLAG_GENERIC(CLONE_SETTLS),
- FLAG_GENERIC(CLONE_PARENT_SETTID),
- FLAG_GENERIC(CLONE_CHILD_CLEARTID),
- FLAG_GENERIC(CLONE_DETACHED),
- FLAG_GENERIC(CLONE_UNTRACED),
- FLAG_GENERIC(CLONE_CHILD_SETTID),
- #if defined(CLONE_NEWUTS)
- FLAG_GENERIC(CLONE_NEWUTS),
- #endif
- #if defined(CLONE_NEWIPC)
- FLAG_GENERIC(CLONE_NEWIPC),
- #endif
- #if defined(CLONE_NEWUSER)
- FLAG_GENERIC(CLONE_NEWUSER),
- #endif
- #if defined(CLONE_NEWPID)
- FLAG_GENERIC(CLONE_NEWPID),
- #endif
- #if defined(CLONE_NEWNET)
- FLAG_GENERIC(CLONE_NEWNET),
- #endif
- #if defined(CLONE_NEWCGROUP)
- FLAG_GENERIC(CLONE_NEWCGROUP),
- #endif
- #if defined(CLONE_NEWTIME)
- FLAG_GENERIC(CLONE_NEWTIME),
- #endif
- #if defined(CLONE_IO)
- FLAG_GENERIC(CLONE_IO),
- #endif
- FLAG_END,
- };
- UNUSED static const struct flags execveat_flags[] = {
- #ifdef AT_EMPTY_PATH
- FLAG_GENERIC(AT_EMPTY_PATH),
- #endif
- #ifdef AT_SYMLINK_NOFOLLOW
- FLAG_GENERIC(AT_SYMLINK_NOFOLLOW),
- #endif
- FLAG_END,
- };
- UNUSED static const struct flags msg_flags[] = {
- /* send */
- FLAG_GENERIC(MSG_CONFIRM),
- FLAG_GENERIC(MSG_DONTROUTE),
- FLAG_GENERIC(MSG_DONTWAIT),
- FLAG_GENERIC(MSG_EOR),
- FLAG_GENERIC(MSG_MORE),
- FLAG_GENERIC(MSG_NOSIGNAL),
- FLAG_GENERIC(MSG_OOB),
- /* recv */
- FLAG_GENERIC(MSG_CMSG_CLOEXEC),
- FLAG_GENERIC(MSG_ERRQUEUE),
- FLAG_GENERIC(MSG_PEEK),
- FLAG_GENERIC(MSG_TRUNC),
- FLAG_GENERIC(MSG_WAITALL),
- /* recvmsg */
- FLAG_GENERIC(MSG_CTRUNC),
- FLAG_END,
- };
- UNUSED static const struct flags statx_flags[] = {
- #ifdef AT_EMPTY_PATH
- FLAG_GENERIC(AT_EMPTY_PATH),
- #endif
- #ifdef AT_NO_AUTOMOUNT
- FLAG_GENERIC(AT_NO_AUTOMOUNT),
- #endif
- #ifdef AT_SYMLINK_NOFOLLOW
- FLAG_GENERIC(AT_SYMLINK_NOFOLLOW),
- #endif
- #ifdef AT_STATX_SYNC_AS_STAT
- FLAG_GENERIC(AT_STATX_SYNC_AS_STAT),
- #endif
- #ifdef AT_STATX_FORCE_SYNC
- FLAG_GENERIC(AT_STATX_FORCE_SYNC),
- #endif
- #ifdef AT_STATX_DONT_SYNC
- FLAG_GENERIC(AT_STATX_DONT_SYNC),
- #endif
- FLAG_END,
- };
- UNUSED static const struct flags statx_mask[] = {
- /* This must come first, because it includes everything. */
- #ifdef STATX_ALL
- FLAG_GENERIC(STATX_ALL),
- #endif
- /* This must come second; it includes everything except STATX_BTIME. */
- #ifdef STATX_BASIC_STATS
- FLAG_GENERIC(STATX_BASIC_STATS),
- #endif
- #ifdef STATX_TYPE
- FLAG_GENERIC(STATX_TYPE),
- #endif
- #ifdef STATX_MODE
- FLAG_GENERIC(STATX_MODE),
- #endif
- #ifdef STATX_NLINK
- FLAG_GENERIC(STATX_NLINK),
- #endif
- #ifdef STATX_UID
- FLAG_GENERIC(STATX_UID),
- #endif
- #ifdef STATX_GID
- FLAG_GENERIC(STATX_GID),
- #endif
- #ifdef STATX_ATIME
- FLAG_GENERIC(STATX_ATIME),
- #endif
- #ifdef STATX_MTIME
- FLAG_GENERIC(STATX_MTIME),
- #endif
- #ifdef STATX_CTIME
- FLAG_GENERIC(STATX_CTIME),
- #endif
- #ifdef STATX_INO
- FLAG_GENERIC(STATX_INO),
- #endif
- #ifdef STATX_SIZE
- FLAG_GENERIC(STATX_SIZE),
- #endif
- #ifdef STATX_BLOCKS
- FLAG_GENERIC(STATX_BLOCKS),
- #endif
- #ifdef STATX_BTIME
- FLAG_GENERIC(STATX_BTIME),
- #endif
- FLAG_END,
- };
- UNUSED static const struct flags falloc_flags[] = {
- FLAG_GENERIC(FALLOC_FL_KEEP_SIZE),
- FLAG_GENERIC(FALLOC_FL_PUNCH_HOLE),
- #ifdef FALLOC_FL_NO_HIDE_STALE
- FLAG_GENERIC(FALLOC_FL_NO_HIDE_STALE),
- #endif
- #ifdef FALLOC_FL_COLLAPSE_RANGE
- FLAG_GENERIC(FALLOC_FL_COLLAPSE_RANGE),
- #endif
- #ifdef FALLOC_FL_ZERO_RANGE
- FLAG_GENERIC(FALLOC_FL_ZERO_RANGE),
- #endif
- #ifdef FALLOC_FL_INSERT_RANGE
- FLAG_GENERIC(FALLOC_FL_INSERT_RANGE),
- #endif
- #ifdef FALLOC_FL_UNSHARE_RANGE
- FLAG_GENERIC(FALLOC_FL_UNSHARE_RANGE),
- #endif
- };
- UNUSED static const struct flags termios_iflags[] = {
- FLAG_TARGET(IGNBRK),
- FLAG_TARGET(BRKINT),
- FLAG_TARGET(IGNPAR),
- FLAG_TARGET(PARMRK),
- FLAG_TARGET(INPCK),
- FLAG_TARGET(ISTRIP),
- FLAG_TARGET(INLCR),
- FLAG_TARGET(IGNCR),
- FLAG_TARGET(ICRNL),
- FLAG_TARGET(IUCLC),
- FLAG_TARGET(IXON),
- FLAG_TARGET(IXANY),
- FLAG_TARGET(IXOFF),
- FLAG_TARGET(IMAXBEL),
- FLAG_TARGET(IUTF8),
- FLAG_END,
- };
- UNUSED static const struct flags termios_oflags[] = {
- FLAG_TARGET(OPOST),
- FLAG_TARGET(OLCUC),
- FLAG_TARGET(ONLCR),
- FLAG_TARGET(OCRNL),
- FLAG_TARGET(ONOCR),
- FLAG_TARGET(ONLRET),
- FLAG_TARGET(OFILL),
- FLAG_TARGET(OFDEL),
- FLAG_END,
- };
- UNUSED static struct enums termios_oflags_NLDLY[] = {
- ENUM_TARGET(NL0),
- ENUM_TARGET(NL1),
- ENUM_END,
- };
- UNUSED static struct enums termios_oflags_CRDLY[] = {
- ENUM_TARGET(CR0),
- ENUM_TARGET(CR1),
- ENUM_TARGET(CR2),
- ENUM_TARGET(CR3),
- ENUM_END,
- };
- UNUSED static struct enums termios_oflags_TABDLY[] = {
- ENUM_TARGET(TAB0),
- ENUM_TARGET(TAB1),
- ENUM_TARGET(TAB2),
- ENUM_TARGET(TAB3),
- ENUM_END,
- };
- UNUSED static struct enums termios_oflags_VTDLY[] = {
- ENUM_TARGET(VT0),
- ENUM_TARGET(VT1),
- ENUM_END,
- };
- UNUSED static struct enums termios_oflags_FFDLY[] = {
- ENUM_TARGET(FF0),
- ENUM_TARGET(FF1),
- ENUM_END,
- };
- UNUSED static struct enums termios_oflags_BSDLY[] = {
- ENUM_TARGET(BS0),
- ENUM_TARGET(BS1),
- ENUM_END,
- };
- UNUSED static struct enums termios_cflags_CBAUD[] = {
- ENUM_TARGET(B0),
- ENUM_TARGET(B50),
- ENUM_TARGET(B75),
- ENUM_TARGET(B110),
- ENUM_TARGET(B134),
- ENUM_TARGET(B150),
- ENUM_TARGET(B200),
- ENUM_TARGET(B300),
- ENUM_TARGET(B600),
- ENUM_TARGET(B1200),
- ENUM_TARGET(B1800),
- ENUM_TARGET(B2400),
- ENUM_TARGET(B4800),
- ENUM_TARGET(B9600),
- ENUM_TARGET(B19200),
- ENUM_TARGET(B38400),
- ENUM_TARGET(B57600),
- ENUM_TARGET(B115200),
- ENUM_TARGET(B230400),
- ENUM_TARGET(B460800),
- ENUM_END,
- };
- UNUSED static struct enums termios_cflags_CSIZE[] = {
- ENUM_TARGET(CS5),
- ENUM_TARGET(CS6),
- ENUM_TARGET(CS7),
- ENUM_TARGET(CS8),
- ENUM_END,
- };
- UNUSED static const struct flags termios_cflags[] = {
- FLAG_TARGET(CSTOPB),
- FLAG_TARGET(CREAD),
- FLAG_TARGET(PARENB),
- FLAG_TARGET(PARODD),
- FLAG_TARGET(HUPCL),
- FLAG_TARGET(CLOCAL),
- FLAG_TARGET(CRTSCTS),
- FLAG_END,
- };
- UNUSED static const struct flags termios_lflags[] = {
- FLAG_TARGET(ISIG),
- FLAG_TARGET(ICANON),
- FLAG_TARGET(XCASE),
- FLAG_TARGET(ECHO),
- FLAG_TARGET(ECHOE),
- FLAG_TARGET(ECHOK),
- FLAG_TARGET(ECHONL),
- FLAG_TARGET(NOFLSH),
- FLAG_TARGET(TOSTOP),
- FLAG_TARGET(ECHOCTL),
- FLAG_TARGET(ECHOPRT),
- FLAG_TARGET(ECHOKE),
- FLAG_TARGET(FLUSHO),
- FLAG_TARGET(PENDIN),
- FLAG_TARGET(IEXTEN),
- FLAG_TARGET(EXTPROC),
- FLAG_END,
- };
- #ifdef TARGET_NR_mlockall
- static const struct flags mlockall_flags[] = {
- FLAG_TARGET(MCL_CURRENT),
- FLAG_TARGET(MCL_FUTURE),
- #ifdef MCL_ONFAULT
- FLAG_TARGET(MCL_ONFAULT),
- #endif
- FLAG_END,
- };
- #endif
- /* IDs of the various system clocks */
- #define TARGET_CLOCK_REALTIME 0
- #define TARGET_CLOCK_MONOTONIC 1
- #define TARGET_CLOCK_PROCESS_CPUTIME_ID 2
- #define TARGET_CLOCK_THREAD_CPUTIME_ID 3
- #define TARGET_CLOCK_MONOTONIC_RAW 4
- #define TARGET_CLOCK_REALTIME_COARSE 5
- #define TARGET_CLOCK_MONOTONIC_COARSE 6
- #define TARGET_CLOCK_BOOTTIME 7
- #define TARGET_CLOCK_REALTIME_ALARM 8
- #define TARGET_CLOCK_BOOTTIME_ALARM 9
- #define TARGET_CLOCK_SGI_CYCLE 10
- #define TARGET_CLOCK_TAI 11
- UNUSED static struct enums clockids[] = {
- ENUM_TARGET(CLOCK_REALTIME),
- ENUM_TARGET(CLOCK_MONOTONIC),
- ENUM_TARGET(CLOCK_PROCESS_CPUTIME_ID),
- ENUM_TARGET(CLOCK_THREAD_CPUTIME_ID),
- ENUM_TARGET(CLOCK_MONOTONIC_RAW),
- ENUM_TARGET(CLOCK_REALTIME_COARSE),
- ENUM_TARGET(CLOCK_MONOTONIC_COARSE),
- ENUM_TARGET(CLOCK_BOOTTIME),
- ENUM_TARGET(CLOCK_REALTIME_ALARM),
- ENUM_TARGET(CLOCK_BOOTTIME_ALARM),
- ENUM_TARGET(CLOCK_SGI_CYCLE),
- ENUM_TARGET(CLOCK_TAI),
- ENUM_END,
- };
- UNUSED static struct enums itimer_types[] = {
- ENUM_GENERIC(ITIMER_REAL),
- ENUM_GENERIC(ITIMER_VIRTUAL),
- ENUM_GENERIC(ITIMER_PROF),
- ENUM_END,
- };
- /*
- * print_xxx utility functions. These are used to print syscall
- * parameters in certain format. All of these have parameter
- * named 'last'. This parameter is used to add comma to output
- * when last == 0.
- */
- static const char *
- get_comma(int last)
- {
- return ((last) ? "" : ",");
- }
- static void
- print_flags(const struct flags *f, abi_long flags, int last)
- {
- const char *sep = "";
- int n;
- if ((flags == 0) && (f->f_value == 0)) {
- qemu_log("%s%s", f->f_string, get_comma(last));
- return;
- }
- for (n = 0; f->f_string != NULL; f++) {
- if ((f->f_value != 0) && ((flags & f->f_value) == f->f_value)) {
- qemu_log("%s%s", sep, f->f_string);
- flags &= ~f->f_value;
- sep = "|";
- n++;
- }
- }
- if (n > 0) {
- /* print rest of the flags as numeric */
- if (flags != 0) {
- qemu_log("%s%#x%s", sep, (unsigned int)flags, get_comma(last));
- } else {
- qemu_log("%s", get_comma(last));
- }
- } else {
- /* no string version of flags found, print them in hex then */
- qemu_log("%#x%s", (unsigned int)flags, get_comma(last));
- }
- }
- static void
- print_enums(const struct enums *e, abi_long enum_arg, int last)
- {
- for (; e->e_string != NULL; e++) {
- if (e->e_value == enum_arg) {
- qemu_log("%s", e->e_string);
- break;
- }
- }
- if (e->e_string == NULL) {
- qemu_log("%#x", (unsigned int)enum_arg);
- }
- qemu_log("%s", get_comma(last));
- }
- static void
- print_at_dirfd(abi_long dirfd, int last)
- {
- #ifdef AT_FDCWD
- if (dirfd == AT_FDCWD) {
- qemu_log("AT_FDCWD%s", get_comma(last));
- return;
- }
- #endif
- qemu_log("%d%s", (int)dirfd, get_comma(last));
- }
- static void
- print_file_mode(abi_long mode, int last)
- {
- const char *sep = "";
- const struct flags *m;
- if (mode == 0) {
- qemu_log("000%s", get_comma(last));
- return;
- }
- for (m = &mode_flags[0]; m->f_string != NULL; m++) {
- if ((m->f_value & mode) == m->f_value) {
- qemu_log("%s%s", m->f_string, sep);
- sep = "|";
- mode &= ~m->f_value;
- break;
- }
- }
- mode &= ~S_IFMT;
- /* print rest of the mode as octal */
- if (mode != 0)
- qemu_log("%s%#o", sep, (unsigned int)mode);
- qemu_log("%s", get_comma(last));
- }
- static void
- print_open_flags(abi_long flags, int last)
- {
- print_flags(open_access_flags, flags & TARGET_O_ACCMODE, 1);
- flags &= ~TARGET_O_ACCMODE;
- if (flags == 0) {
- qemu_log("%s", get_comma(last));
- return;
- }
- qemu_log("|");
- print_flags(open_flags, flags, last);
- }
- static void
- print_syscall_prologue(const struct syscallname *sc)
- {
- qemu_log("%s(", sc->name);
- }
- /*ARGSUSED*/
- static void
- print_syscall_epilogue(const struct syscallname *sc)
- {
- (void)sc;
- qemu_log(")");
- }
- static void
- print_string(abi_long addr, int last)
- {
- char *s;
- if ((s = lock_user_string(addr)) != NULL) {
- qemu_log("\"%s\"%s", s, get_comma(last));
- unlock_user(s, addr, 0);
- } else {
- /* can't get string out of it, so print it as pointer */
- print_pointer(addr, last);
- }
- }
- #define MAX_PRINT_BUF 40
- static void
- print_buf(abi_long addr, abi_long len, int last)
- {
- uint8_t *s;
- int i;
- s = lock_user(VERIFY_READ, addr, len, 1);
- if (s) {
- qemu_log("\"");
- for (i = 0; i < MAX_PRINT_BUF && i < len; i++) {
- if (isprint(s[i])) {
- qemu_log("%c", s[i]);
- } else {
- qemu_log("\\%o", s[i]);
- }
- }
- qemu_log("\"");
- if (i != len) {
- qemu_log("...");
- }
- if (!last) {
- qemu_log(",");
- }
- unlock_user(s, addr, 0);
- } else {
- print_pointer(addr, last);
- }
- }
- /*
- * Prints out raw parameter using given format. Caller needs
- * to do byte swapping if needed.
- */
- static void
- print_raw_param(const char *fmt, abi_long param, int last)
- {
- char format[64];
- (void) snprintf(format, sizeof (format), "%s%s", fmt, get_comma(last));
- qemu_log(format, param);
- }
- /*
- * Same as print_raw_param() but prints out raw 64-bit parameter.
- */
- static void
- print_raw_param64(const char *fmt, long long param, int last)
- {
- char format[64];
- (void)snprintf(format, sizeof(format), "%s%s", fmt, get_comma(last));
- qemu_log(format, param);
- }
- static void
- print_pointer(abi_long p, int last)
- {
- if (p == 0)
- qemu_log("NULL%s", get_comma(last));
- else
- qemu_log("0x" TARGET_ABI_FMT_lx "%s", p, get_comma(last));
- }
- /*
- * Reads 32-bit (int) number from guest address space from
- * address 'addr' and prints it.
- */
- static void
- print_number(abi_long addr, int last)
- {
- if (addr == 0) {
- qemu_log("NULL%s", get_comma(last));
- } else {
- int num;
- get_user_s32(num, addr);
- qemu_log("[%d]%s", num, get_comma(last));
- }
- }
- static void
- print_timeval(abi_ulong tv_addr, int last)
- {
- if( tv_addr ) {
- struct target_timeval *tv;
- tv = lock_user(VERIFY_READ, tv_addr, sizeof(*tv), 1);
- if (!tv) {
- print_pointer(tv_addr, last);
- return;
- }
- qemu_log("{tv_sec = " TARGET_ABI_FMT_ld
- ",tv_usec = " TARGET_ABI_FMT_ld "}%s",
- tswapal(tv->tv_sec), tswapal(tv->tv_usec), get_comma(last));
- unlock_user(tv, tv_addr, 0);
- } else
- qemu_log("NULL%s", get_comma(last));
- }
- static void
- print_timespec(abi_ulong ts_addr, int last)
- {
- if (ts_addr) {
- struct target_timespec *ts;
- ts = lock_user(VERIFY_READ, ts_addr, sizeof(*ts), 1);
- if (!ts) {
- print_pointer(ts_addr, last);
- return;
- }
- qemu_log("{tv_sec = " TARGET_ABI_FMT_ld
- ",tv_nsec = " TARGET_ABI_FMT_ld "}%s",
- tswapal(ts->tv_sec), tswapal(ts->tv_nsec), get_comma(last));
- unlock_user(ts, ts_addr, 0);
- } else {
- qemu_log("NULL%s", get_comma(last));
- }
- }
- static void
- print_timespec64(abi_ulong ts_addr, int last)
- {
- if (ts_addr) {
- struct target__kernel_timespec *ts;
- ts = lock_user(VERIFY_READ, ts_addr, sizeof(*ts), 1);
- if (!ts) {
- print_pointer(ts_addr, last);
- return;
- }
- print_raw_param64("{tv_sec=%" PRId64, tswap64(ts->tv_sec), 0);
- print_raw_param64("tv_nsec=%" PRId64 "}", tswap64(ts->tv_nsec), last);
- unlock_user(ts, ts_addr, 0);
- } else {
- qemu_log("NULL%s", get_comma(last));
- }
- }
- static void
- print_timezone(abi_ulong tz_addr, int last)
- {
- if (tz_addr) {
- struct target_timezone *tz;
- tz = lock_user(VERIFY_READ, tz_addr, sizeof(*tz), 1);
- if (!tz) {
- print_pointer(tz_addr, last);
- return;
- }
- qemu_log("{%d,%d}%s", tswap32(tz->tz_minuteswest),
- tswap32(tz->tz_dsttime), get_comma(last));
- unlock_user(tz, tz_addr, 0);
- } else {
- qemu_log("NULL%s", get_comma(last));
- }
- }
- static void
- print_itimerval(abi_ulong it_addr, int last)
- {
- if (it_addr) {
- qemu_log("{it_interval=");
- print_timeval(it_addr +
- offsetof(struct target_itimerval, it_interval), 0);
- qemu_log("it_value=");
- print_timeval(it_addr +
- offsetof(struct target_itimerval, it_value), 0);
- qemu_log("}%s", get_comma(last));
- } else {
- qemu_log("NULL%s", get_comma(last));
- }
- }
- void
- print_termios(void *arg)
- {
- const struct target_termios *target = arg;
- target_tcflag_t iflags = tswap32(target->c_iflag);
- target_tcflag_t oflags = tswap32(target->c_oflag);
- target_tcflag_t cflags = tswap32(target->c_cflag);
- target_tcflag_t lflags = tswap32(target->c_lflag);
- qemu_log("{");
- qemu_log("c_iflag = ");
- print_flags(termios_iflags, iflags, 0);
- qemu_log("c_oflag = ");
- target_tcflag_t oflags_clean = oflags & ~(TARGET_NLDLY | TARGET_CRDLY |
- TARGET_TABDLY | TARGET_BSDLY |
- TARGET_VTDLY | TARGET_FFDLY);
- print_flags(termios_oflags, oflags_clean, 0);
- if (oflags & TARGET_NLDLY) {
- print_enums(termios_oflags_NLDLY, oflags & TARGET_NLDLY, 0);
- }
- if (oflags & TARGET_CRDLY) {
- print_enums(termios_oflags_CRDLY, oflags & TARGET_CRDLY, 0);
- }
- if (oflags & TARGET_TABDLY) {
- print_enums(termios_oflags_TABDLY, oflags & TARGET_TABDLY, 0);
- }
- if (oflags & TARGET_BSDLY) {
- print_enums(termios_oflags_BSDLY, oflags & TARGET_BSDLY, 0);
- }
- if (oflags & TARGET_VTDLY) {
- print_enums(termios_oflags_VTDLY, oflags & TARGET_VTDLY, 0);
- }
- if (oflags & TARGET_FFDLY) {
- print_enums(termios_oflags_FFDLY, oflags & TARGET_FFDLY, 0);
- }
- qemu_log("c_cflag = ");
- if (cflags & TARGET_CBAUD) {
- print_enums(termios_cflags_CBAUD, cflags & TARGET_CBAUD, 0);
- }
- if (cflags & TARGET_CSIZE) {
- print_enums(termios_cflags_CSIZE, cflags & TARGET_CSIZE, 0);
- }
- target_tcflag_t cflags_clean = cflags & ~(TARGET_CBAUD | TARGET_CSIZE);
- print_flags(termios_cflags, cflags_clean, 0);
- qemu_log("c_lflag = ");
- print_flags(termios_lflags, lflags, 0);
- qemu_log("c_cc = ");
- qemu_log("\"%s\",", target->c_cc);
- qemu_log("c_line = ");
- print_raw_param("\'%c\'", target->c_line, 1);
- qemu_log("}");
- }
- #undef UNUSED
- #ifdef TARGET_NR_accept
- static void
- print_accept(CPUArchState *cpu_env, const struct syscallname *name,
- abi_long arg0, abi_long arg1, abi_long arg2,
- abi_long arg3, abi_long arg4, abi_long arg5)
- {
- print_syscall_prologue(name);
- print_raw_param("%d", arg0, 0);
- print_pointer(arg1, 0);
- print_number(arg2, 1);
- print_syscall_epilogue(name);
- }
- #endif
- #ifdef TARGET_NR_access
- static void
- print_access(CPUArchState *cpu_env, const struct syscallname *name,
- abi_long arg0, abi_long arg1, abi_long arg2,
- abi_long arg3, abi_long arg4, abi_long arg5)
- {
- print_syscall_prologue(name);
- print_string(arg0, 0);
- print_flags(access_flags, arg1, 1);
- print_syscall_epilogue(name);
- }
- #endif
- #ifdef TARGET_NR_acct
- static void
- print_acct(CPUArchState *cpu_env, const struct syscallname *name,
- abi_long arg0, abi_long arg1, abi_long arg2,
- abi_long arg3, abi_long arg4, abi_long arg5)
- {
- print_syscall_prologue(name);
- print_string(arg0, 1);
- print_syscall_epilogue(name);
- }
- #endif
- #ifdef TARGET_NR_brk
- static void
- print_brk(CPUArchState *cpu_env, const struct syscallname *name,
- abi_long arg0, abi_long arg1, abi_long arg2,
- abi_long arg3, abi_long arg4, abi_long arg5)
- {
- print_syscall_prologue(name);
- print_pointer(arg0, 1);
- print_syscall_epilogue(name);
- }
- #endif
- #ifdef TARGET_NR_chdir
- static void
- print_chdir(CPUArchState *cpu_env, const struct syscallname *name,
- abi_long arg0, abi_long arg1, abi_long arg2,
- abi_long arg3, abi_long arg4, abi_long arg5)
- {
- print_syscall_prologue(name);
- print_string(arg0, 1);
- print_syscall_epilogue(name);
- }
- #endif
- #ifdef TARGET_NR_chroot
- static void
- print_chroot(CPUArchState *cpu_env, const struct syscallname *name,
- abi_long arg0, abi_long arg1, abi_long arg2,
- abi_long arg3, abi_long arg4, abi_long arg5)
- {
- print_syscall_prologue(name);
- print_string(arg0, 1);
- print_syscall_epilogue(name);
- }
- #endif
- #ifdef TARGET_NR_chmod
- static void
- print_chmod(CPUArchState *cpu_env, const struct syscallname *name,
- abi_long arg0, abi_long arg1, abi_long arg2,
- abi_long arg3, abi_long arg4, abi_long arg5)
- {
- print_syscall_prologue(name);
- print_string(arg0, 0);
- print_file_mode(arg1, 1);
- print_syscall_epilogue(name);
- }
- #endif
- #if defined(TARGET_NR_chown) || defined(TARGET_NR_lchown)
- static void
- print_chown(CPUArchState *cpu_env, const struct syscallname *name,
- abi_long arg0, abi_long arg1, abi_long arg2,
- abi_long arg3, abi_long arg4, abi_long arg5)
- {
- print_syscall_prologue(name);
- print_string(arg0, 0);
- print_raw_param("%d", arg1, 0);
- print_raw_param("%d", arg2, 1);
- print_syscall_epilogue(name);
- }
- #define print_lchown print_chown
- #endif
- #ifdef TARGET_NR_clock_adjtime
- static void
- print_clock_adjtime(CPUArchState *cpu_env, const struct syscallname *name,
- abi_long arg0, abi_long arg1, abi_long arg2,
- abi_long arg3, abi_long arg4, abi_long arg5)
- {
- print_syscall_prologue(name);
- print_enums(clockids, arg0, 0);
- print_pointer(arg1, 1);
- print_syscall_epilogue(name);
- }
- #endif
- #ifdef TARGET_NR_clone
- static void do_print_clone(unsigned int flags, abi_ulong newsp,
- abi_ulong parent_tidptr, target_ulong newtls,
- abi_ulong child_tidptr)
- {
- print_flags(clone_flags, flags, 0);
- print_raw_param("child_stack=0x" TARGET_ABI_FMT_lx, newsp, 0);
- print_raw_param("parent_tidptr=0x" TARGET_ABI_FMT_lx, parent_tidptr, 0);
- print_raw_param("tls=0x" TARGET_ABI_FMT_lx, newtls, 0);
- print_raw_param("child_tidptr=0x" TARGET_ABI_FMT_lx, child_tidptr, 1);
- }
- static void
- print_clone(CPUArchState *cpu_env, const struct syscallname *name,
- abi_long arg1, abi_long arg2, abi_long arg3,
- abi_long arg4, abi_long arg5, abi_long arg6)
- {
- print_syscall_prologue(name);
- #if defined(TARGET_MICROBLAZE)
- do_print_clone(arg1, arg2, arg4, arg6, arg5);
- #elif defined(TARGET_CLONE_BACKWARDS)
- do_print_clone(arg1, arg2, arg3, arg4, arg5);
- #elif defined(TARGET_CLONE_BACKWARDS2)
- do_print_clone(arg2, arg1, arg3, arg5, arg4);
- #else
- do_print_clone(arg1, arg2, arg3, arg5, arg4);
- #endif
- print_syscall_epilogue(name);
- }
- #endif
- #ifdef TARGET_NR_creat
- static void
- print_creat(CPUArchState *cpu_env, const struct syscallname *name,
- abi_long arg0, abi_long arg1, abi_long arg2,
- abi_long arg3, abi_long arg4, abi_long arg5)
- {
- print_syscall_prologue(name);
- print_string(arg0, 0);
- print_file_mode(arg1, 1);
- print_syscall_epilogue(name);
- }
- #endif
- #ifdef TARGET_NR_execv
- static void
- print_execv(CPUArchState *cpu_env, const struct syscallname *name,
- abi_long arg0, abi_long arg1, abi_long arg2,
- abi_long arg3, abi_long arg4, abi_long arg5)
- {
- print_syscall_prologue(name);
- print_string(arg0, 0);
- print_raw_param("0x" TARGET_ABI_FMT_lx, arg1, 1);
- print_syscall_epilogue(name);
- }
- #endif
- static void
- print_execve_argv(abi_long argv, int last)
- {
- abi_ulong arg_ptr_addr;
- char *s;
- qemu_log("{");
- for (arg_ptr_addr = argv; ; arg_ptr_addr += sizeof(abi_ulong)) {
- abi_ulong *arg_ptr, arg_addr;
- arg_ptr = lock_user(VERIFY_READ, arg_ptr_addr, sizeof(abi_ulong), 1);
- if (!arg_ptr) {
- return;
- }
- arg_addr = tswapal(*arg_ptr);
- unlock_user(arg_ptr, arg_ptr_addr, 0);
- if (!arg_addr) {
- break;
- }
- s = lock_user_string(arg_addr);
- if (s) {
- qemu_log("\"%s\",", s);
- unlock_user(s, arg_addr, 0);
- }
- }
- qemu_log("NULL}%s", get_comma(last));
- }
- static void
- print_execve(CPUArchState *cpu_env, const struct syscallname *name,
- abi_long arg1, abi_long arg2, abi_long arg3,
- abi_long arg4, abi_long arg5, abi_long arg6)
- {
- print_syscall_prologue(name);
- print_string(arg1, 0);
- print_execve_argv(arg2, 1);
- print_syscall_epilogue(name);
- }
- static void
- print_execveat(CPUArchState *cpu_env, const struct syscallname *name,
- abi_long arg1, abi_long arg2, abi_long arg3,
- abi_long arg4, abi_long arg5, abi_long arg6)
- {
- print_syscall_prologue(name);
- print_at_dirfd(arg1, 0);
- print_string(arg2, 0);
- print_execve_argv(arg3, 0);
- print_flags(execveat_flags, arg5, 1);
- print_syscall_epilogue(name);
- }
- #if defined(TARGET_NR_faccessat) || defined(TARGET_NR_faccessat2)
- static void
- print_faccessat(CPUArchState *cpu_env, const struct syscallname *name,
- abi_long arg0, abi_long arg1, abi_long arg2,
- abi_long arg3, abi_long arg4, abi_long arg5)
- {
- print_syscall_prologue(name);
- print_at_dirfd(arg0, 0);
- print_string(arg1, 0);
- print_flags(access_flags, arg2, 0);
- print_flags(at_file_flags, arg3, 1);
- print_syscall_epilogue(name);
- }
- #endif
- #ifdef TARGET_NR_fallocate
- static void
- print_fallocate(CPUArchState *cpu_env, const struct syscallname *name,
- abi_long arg0, abi_long arg1, abi_long arg2,
- abi_long arg3, abi_long arg4, abi_long arg5)
- {
- print_syscall_prologue(name);
- print_raw_param("%d", arg0, 0);
- print_flags(falloc_flags, arg1, 0);
- #if TARGET_ABI_BITS == 32
- print_raw_param("%" PRIu64, target_offset64(arg2, arg3), 0);
- print_raw_param("%" PRIu64, target_offset64(arg4, arg5), 1);
- #else
- print_raw_param(TARGET_ABI_FMT_ld, arg2, 0);
- print_raw_param(TARGET_ABI_FMT_ld, arg3, 1);
- #endif
- print_syscall_epilogue(name);
- }
- #endif
- #ifdef TARGET_NR_fchmodat
- static void
- print_fchmodat(CPUArchState *cpu_env, const struct syscallname *name,
- abi_long arg0, abi_long arg1, abi_long arg2,
- abi_long arg3, abi_long arg4, abi_long arg5)
- {
- print_syscall_prologue(name);
- print_at_dirfd(arg0, 0);
- print_string(arg1, 0);
- print_file_mode(arg2, 0);
- print_flags(at_file_flags, arg3, 1);
- print_syscall_epilogue(name);
- }
- #endif
- #ifdef TARGET_NR_fchownat
- static void
- print_fchownat(CPUArchState *cpu_env, const struct syscallname *name,
- abi_long arg0, abi_long arg1, abi_long arg2,
- abi_long arg3, abi_long arg4, abi_long arg5)
- {
- print_syscall_prologue(name);
- print_at_dirfd(arg0, 0);
- print_string(arg1, 0);
- print_raw_param("%d", arg2, 0);
- print_raw_param("%d", arg3, 0);
- print_flags(at_file_flags, arg4, 1);
- print_syscall_epilogue(name);
- }
- #endif
- #if defined(TARGET_NR_fcntl) || defined(TARGET_NR_fcntl64)
- static void
- print_fcntl(CPUArchState *cpu_env, const struct syscallname *name,
- abi_long arg0, abi_long arg1, abi_long arg2,
- abi_long arg3, abi_long arg4, abi_long arg5)
- {
- print_syscall_prologue(name);
- print_raw_param("%d", arg0, 0);
- switch(arg1) {
- case TARGET_F_DUPFD:
- qemu_log("F_DUPFD,");
- print_raw_param(TARGET_ABI_FMT_ld, arg2, 1);
- break;
- case TARGET_F_GETFD:
- qemu_log("F_GETFD");
- break;
- case TARGET_F_SETFD:
- qemu_log("F_SETFD,");
- print_raw_param(TARGET_ABI_FMT_ld, arg2, 1);
- break;
- case TARGET_F_GETFL:
- qemu_log("F_GETFL");
- break;
- case TARGET_F_SETFL:
- qemu_log("F_SETFL,");
- print_open_flags(arg2, 1);
- break;
- case TARGET_F_GETLK:
- qemu_log("F_GETLK,");
- print_pointer(arg2, 1);
- break;
- case TARGET_F_SETLK:
- qemu_log("F_SETLK,");
- print_pointer(arg2, 1);
- break;
- case TARGET_F_SETLKW:
- qemu_log("F_SETLKW,");
- print_pointer(arg2, 1);
- break;
- case TARGET_F_GETOWN:
- qemu_log("F_GETOWN");
- break;
- case TARGET_F_SETOWN:
- qemu_log("F_SETOWN,");
- print_raw_param(TARGET_ABI_FMT_ld, arg2, 0);
- break;
- case TARGET_F_GETSIG:
- qemu_log("F_GETSIG");
- break;
- case TARGET_F_SETSIG:
- qemu_log("F_SETSIG,");
- print_raw_param(TARGET_ABI_FMT_ld, arg2, 0);
- break;
- #if TARGET_ABI_BITS == 32
- case TARGET_F_GETLK64:
- qemu_log("F_GETLK64,");
- print_pointer(arg2, 1);
- break;
- case TARGET_F_SETLK64:
- qemu_log("F_SETLK64,");
- print_pointer(arg2, 1);
- break;
- case TARGET_F_SETLKW64:
- qemu_log("F_SETLKW64,");
- print_pointer(arg2, 1);
- break;
- #endif
- case TARGET_F_OFD_GETLK:
- qemu_log("F_OFD_GETLK,");
- print_pointer(arg2, 1);
- break;
- case TARGET_F_OFD_SETLK:
- qemu_log("F_OFD_SETLK,");
- print_pointer(arg2, 1);
- break;
- case TARGET_F_OFD_SETLKW:
- qemu_log("F_OFD_SETLKW,");
- print_pointer(arg2, 1);
- break;
- case TARGET_F_SETLEASE:
- qemu_log("F_SETLEASE,");
- print_raw_param(TARGET_ABI_FMT_ld, arg2, 1);
- break;
- case TARGET_F_GETLEASE:
- qemu_log("F_GETLEASE");
- break;
- #ifdef F_DUPFD_CLOEXEC
- case TARGET_F_DUPFD_CLOEXEC:
- qemu_log("F_DUPFD_CLOEXEC,");
- print_raw_param(TARGET_ABI_FMT_ld, arg2, 1);
- break;
- #endif
- case TARGET_F_NOTIFY:
- qemu_log("F_NOTIFY,");
- print_raw_param(TARGET_ABI_FMT_ld, arg2, 1);
- break;
- #ifdef F_GETOWN_EX
- case TARGET_F_GETOWN_EX:
- qemu_log("F_GETOWN_EX,");
- print_pointer(arg2, 1);
- break;
- #endif
- #ifdef F_SETOWN_EX
- case TARGET_F_SETOWN_EX:
- qemu_log("F_SETOWN_EX,");
- print_pointer(arg2, 1);
- break;
- #endif
- #ifdef F_SETPIPE_SZ
- case TARGET_F_SETPIPE_SZ:
- qemu_log("F_SETPIPE_SZ,");
- print_raw_param(TARGET_ABI_FMT_ld, arg2, 1);
- break;
- case TARGET_F_GETPIPE_SZ:
- qemu_log("F_GETPIPE_SZ");
- break;
- #endif
- #ifdef F_ADD_SEALS
- case TARGET_F_ADD_SEALS:
- qemu_log("F_ADD_SEALS,");
- print_raw_param("0x"TARGET_ABI_FMT_lx, arg2, 1);
- break;
- case TARGET_F_GET_SEALS:
- qemu_log("F_GET_SEALS");
- break;
- #endif
- default:
- print_raw_param(TARGET_ABI_FMT_ld, arg1, 0);
- print_pointer(arg2, 1);
- break;
- }
- print_syscall_epilogue(name);
- }
- #define print_fcntl64 print_fcntl
- #endif
- #ifdef TARGET_NR_fgetxattr
- static void
- print_fgetxattr(CPUArchState *cpu_env, const struct syscallname *name,
- abi_long arg0, abi_long arg1, abi_long arg2,
- abi_long arg3, abi_long arg4, abi_long arg5)
- {
- print_syscall_prologue(name);
- print_raw_param("%d", arg0, 0);
- print_string(arg1, 0);
- print_pointer(arg2, 0);
- print_raw_param(TARGET_FMT_lu, arg3, 1);
- print_syscall_epilogue(name);
- }
- #endif
- #ifdef TARGET_NR_flistxattr
- static void
- print_flistxattr(CPUArchState *cpu_env, const struct syscallname *name,
- abi_long arg0, abi_long arg1, abi_long arg2,
- abi_long arg3, abi_long arg4, abi_long arg5)
- {
- print_syscall_prologue(name);
- print_raw_param("%d", arg0, 0);
- print_pointer(arg1, 0);
- print_raw_param(TARGET_FMT_lu, arg2, 1);
- print_syscall_epilogue(name);
- }
- #endif
- #if defined(TARGET_NR_getxattr) || defined(TARGET_NR_lgetxattr)
- static void
- print_getxattr(CPUArchState *cpu_env, const struct syscallname *name,
- abi_long arg0, abi_long arg1, abi_long arg2,
- abi_long arg3, abi_long arg4, abi_long arg5)
- {
- print_syscall_prologue(name);
- print_string(arg0, 0);
- print_string(arg1, 0);
- print_pointer(arg2, 0);
- print_raw_param(TARGET_FMT_lu, arg3, 1);
- print_syscall_epilogue(name);
- }
- #define print_lgetxattr print_getxattr
- #endif
- #if defined(TARGET_NR_listxattr) || defined(TARGET_NR_llistxattr)
- static void
- print_listxattr(CPUArchState *cpu_env, const struct syscallname *name,
- abi_long arg0, abi_long arg1, abi_long arg2,
- abi_long arg3, abi_long arg4, abi_long arg5)
- {
- print_syscall_prologue(name);
- print_string(arg0, 0);
- print_pointer(arg1, 0);
- print_raw_param(TARGET_FMT_lu, arg2, 1);
- print_syscall_epilogue(name);
- }
- #define print_llistxattr print_listxattr
- #endif
- #if defined(TARGET_NR_fremovexattr)
- static void
- print_fremovexattr(CPUArchState *cpu_env, const struct syscallname *name,
- abi_long arg0, abi_long arg1, abi_long arg2,
- abi_long arg3, abi_long arg4, abi_long arg5)
- {
- print_syscall_prologue(name);
- print_raw_param("%d", arg0, 0);
- print_string(arg1, 1);
- print_syscall_epilogue(name);
- }
- #endif
- #if defined(TARGET_NR_removexattr) || defined(TARGET_NR_lremovexattr)
- static void
- print_removexattr(CPUArchState *cpu_env, const struct syscallname *name,
- abi_long arg0, abi_long arg1, abi_long arg2,
- abi_long arg3, abi_long arg4, abi_long arg5)
- {
- print_syscall_prologue(name);
- print_string(arg0, 0);
- print_string(arg1, 1);
- print_syscall_epilogue(name);
- }
- #define print_lremovexattr print_removexattr
- #endif
- #ifdef TARGET_NR_futimesat
- static void
- print_futimesat(CPUArchState *cpu_env, const struct syscallname *name,
- abi_long arg0, abi_long arg1, abi_long arg2,
- abi_long arg3, abi_long arg4, abi_long arg5)
- {
- print_syscall_prologue(name);
- print_at_dirfd(arg0, 0);
- print_string(arg1, 0);
- print_timeval(arg2, 0);
- print_timeval(arg2 + sizeof (struct target_timeval), 1);
- print_syscall_epilogue(name);
- }
- #endif
- #ifdef TARGET_NR_gettimeofday
- static void
- print_gettimeofday(CPUArchState *cpu_env, const struct syscallname *name,
- abi_long arg0, abi_long arg1, abi_long arg2,
- abi_long arg3, abi_long arg4, abi_long arg5)
- {
- print_syscall_prologue(name);
- print_pointer(arg0, 0);
- print_pointer(arg1, 1);
- print_syscall_epilogue(name);
- }
- #endif
- #ifdef TARGET_NR_settimeofday
- static void
- print_settimeofday(CPUArchState *cpu_env, const struct syscallname *name,
- abi_long arg0, abi_long arg1, abi_long arg2,
- abi_long arg3, abi_long arg4, abi_long arg5)
- {
- print_syscall_prologue(name);
- print_timeval(arg0, 0);
- print_timezone(arg1, 1);
- print_syscall_epilogue(name);
- }
- #endif
- #if defined(TARGET_NR_clock_gettime) || defined(TARGET_NR_clock_getres)
- static void
- print_clock_gettime(CPUArchState *cpu_env, const struct syscallname *name,
- abi_long arg0, abi_long arg1, abi_long arg2,
- abi_long arg3, abi_long arg4, abi_long arg5)
- {
- print_syscall_prologue(name);
- print_enums(clockids, arg0, 0);
- print_pointer(arg1, 1);
- print_syscall_epilogue(name);
- }
- #define print_clock_getres print_clock_gettime
- #endif
- #if defined(TARGET_NR_clock_gettime64)
- static void
- print_clock_gettime64(CPUArchState *cpu_env, const struct syscallname *name,
- abi_long arg0, abi_long arg1, abi_long arg2,
- abi_long arg3, abi_long arg4, abi_long arg5)
- {
- print_syscall_prologue(name);
- print_enums(clockids, arg0, 0);
- print_pointer(arg1, 1);
- print_syscall_epilogue(name);
- }
- #endif
- #ifdef TARGET_NR_clock_settime
- static void
- print_clock_settime(CPUArchState *cpu_env, const struct syscallname *name,
- abi_long arg0, abi_long arg1, abi_long arg2,
- abi_long arg3, abi_long arg4, abi_long arg5)
- {
- print_syscall_prologue(name);
- print_enums(clockids, arg0, 0);
- print_timespec(arg1, 1);
- print_syscall_epilogue(name);
- }
- #endif
- #ifdef TARGET_NR_getitimer
- static void
- print_getitimer(CPUArchState *cpu_env, const struct syscallname *name,
- abi_long arg0, abi_long arg1, abi_long arg2,
- abi_long arg3, abi_long arg4, abi_long arg5)
- {
- print_syscall_prologue(name);
- print_enums(itimer_types, arg0, 0);
- print_pointer(arg1, 1);
- print_syscall_epilogue(name);
- }
- #endif
- #ifdef TARGET_NR_setitimer
- static void
- print_setitimer(CPUArchState *cpu_env, const struct syscallname *name,
- abi_long arg0, abi_long arg1, abi_long arg2,
- abi_long arg3, abi_long arg4, abi_long arg5)
- {
- print_syscall_prologue(name);
- print_enums(itimer_types, arg0, 0);
- print_itimerval(arg1, 0);
- print_pointer(arg2, 1);
- print_syscall_epilogue(name);
- }
- #endif
- #ifdef TARGET_NR_link
- static void
- print_link(CPUArchState *cpu_env, const struct syscallname *name,
- abi_long arg0, abi_long arg1, abi_long arg2,
- abi_long arg3, abi_long arg4, abi_long arg5)
- {
- print_syscall_prologue(name);
- print_string(arg0, 0);
- print_string(arg1, 1);
- print_syscall_epilogue(name);
- }
- #endif
- #ifdef TARGET_NR_linkat
- static void
- print_linkat(CPUArchState *cpu_env, const struct syscallname *name,
- abi_long arg0, abi_long arg1, abi_long arg2,
- abi_long arg3, abi_long arg4, abi_long arg5)
- {
- print_syscall_prologue(name);
- print_at_dirfd(arg0, 0);
- print_string(arg1, 0);
- print_at_dirfd(arg2, 0);
- print_string(arg3, 0);
- print_flags(at_file_flags, arg4, 1);
- print_syscall_epilogue(name);
- }
- #endif
- #if defined(TARGET_NR__llseek) || defined(TARGET_NR_llseek)
- static void
- print__llseek(CPUArchState *cpu_env, const struct syscallname *name,
- abi_long arg0, abi_long arg1, abi_long arg2,
- abi_long arg3, abi_long arg4, abi_long arg5)
- {
- const char *whence = "UNKNOWN";
- print_syscall_prologue(name);
- print_raw_param("%d", arg0, 0);
- print_raw_param("%ld", arg1, 0);
- print_raw_param("%ld", arg2, 0);
- print_pointer(arg3, 0);
- switch(arg4) {
- case SEEK_SET: whence = "SEEK_SET"; break;
- case SEEK_CUR: whence = "SEEK_CUR"; break;
- case SEEK_END: whence = "SEEK_END"; break;
- }
- qemu_log("%s", whence);
- print_syscall_epilogue(name);
- }
- #define print_llseek print__llseek
- #endif
- #ifdef TARGET_NR_lseek
- static void
- print_lseek(CPUArchState *cpu_env, const struct syscallname *name,
- abi_long arg0, abi_long arg1, abi_long arg2,
- abi_long arg3, abi_long arg4, abi_long arg5)
- {
- print_syscall_prologue(name);
- print_raw_param("%d", arg0, 0);
- print_raw_param(TARGET_ABI_FMT_ld, arg1, 0);
- switch (arg2) {
- case SEEK_SET:
- qemu_log("SEEK_SET"); break;
- case SEEK_CUR:
- qemu_log("SEEK_CUR"); break;
- case SEEK_END:
- qemu_log("SEEK_END"); break;
- #ifdef SEEK_DATA
- case SEEK_DATA:
- qemu_log("SEEK_DATA"); break;
- #endif
- #ifdef SEEK_HOLE
- case SEEK_HOLE:
- qemu_log("SEEK_HOLE"); break;
- #endif
- default:
- print_raw_param("%#x", arg2, 1);
- }
- print_syscall_epilogue(name);
- }
- #endif
- #ifdef TARGET_NR_truncate
- static void
- print_truncate(CPUArchState *cpu_env, const struct syscallname *name,
- abi_long arg0, abi_long arg1, abi_long arg2,
- abi_long arg3, abi_long arg4, abi_long arg5)
- {
- print_syscall_prologue(name);
- print_string(arg0, 0);
- print_raw_param(TARGET_ABI_FMT_ld, arg1, 1);
- print_syscall_epilogue(name);
- }
- #endif
- #ifdef TARGET_NR_truncate64
- static void
- print_truncate64(CPUArchState *cpu_env, const struct syscallname *name,
- abi_long arg0, abi_long arg1, abi_long arg2,
- abi_long arg3, abi_long arg4, abi_long arg5)
- {
- print_syscall_prologue(name);
- print_string(arg0, 0);
- if (regpairs_aligned(cpu_env, TARGET_NR_truncate64)) {
- arg1 = arg2;
- arg2 = arg3;
- }
- print_raw_param("%" PRIu64, target_offset64(arg1, arg2), 1);
- print_syscall_epilogue(name);
- }
- #endif
- #ifdef TARGET_NR_ftruncate64
- static void
- print_ftruncate64(CPUArchState *cpu_env, const struct syscallname *name,
- abi_long arg0, abi_long arg1, abi_long arg2,
- abi_long arg3, abi_long arg4, abi_long arg5)
- {
- print_syscall_prologue(name);
- print_raw_param("%d", arg0, 0);
- if (regpairs_aligned(cpu_env, TARGET_NR_ftruncate64)) {
- arg1 = arg2;
- arg2 = arg3;
- }
- print_raw_param("%" PRIu64, target_offset64(arg1, arg2), 1);
- print_syscall_epilogue(name);
- }
- #endif
- #ifdef TARGET_NR_mlockall
- static void
- print_mlockall(CPUArchState *cpu_env, const struct syscallname *name,
- abi_long arg0, abi_long arg1, abi_long arg2,
- abi_long arg3, abi_long arg4, abi_long arg5)
- {
- print_syscall_prologue(name);
- print_flags(mlockall_flags, arg0, 1);
- print_syscall_epilogue(name);
- }
- #endif
- #if defined(TARGET_NR_socket)
- static void
- print_socket(CPUArchState *cpu_env, const struct syscallname *name,
- abi_long arg0, abi_long arg1, abi_long arg2,
- abi_long arg3, abi_long arg4, abi_long arg5)
- {
- abi_ulong domain = arg0, type = arg1, protocol = arg2;
- print_syscall_prologue(name);
- print_socket_domain(domain);
- qemu_log(",");
- print_socket_type(type);
- qemu_log(",");
- if (domain == AF_PACKET ||
- (domain == AF_INET && type == TARGET_SOCK_PACKET)) {
- protocol = tswap16(protocol);
- }
- print_socket_protocol(domain, type, protocol);
- print_syscall_epilogue(name);
- }
- #endif
- #if defined(TARGET_NR_socketcall) || defined(TARGET_NR_bind)
- static void print_sockfd(abi_long sockfd, int last)
- {
- print_raw_param(TARGET_ABI_FMT_ld, sockfd, last);
- }
- #endif
- #if defined(TARGET_NR_socketcall)
- #define get_user_ualx(x, gaddr, idx) \
- get_user_ual(x, (gaddr) + (idx) * sizeof(abi_long))
- static void do_print_socket(const char *name, abi_long arg1)
- {
- abi_ulong domain, type, protocol;
- get_user_ualx(domain, arg1, 0);
- get_user_ualx(type, arg1, 1);
- get_user_ualx(protocol, arg1, 2);
- qemu_log("%s(", name);
- print_socket_domain(domain);
- qemu_log(",");
- print_socket_type(type);
- qemu_log(",");
- if (domain == AF_PACKET ||
- (domain == AF_INET && type == TARGET_SOCK_PACKET)) {
- protocol = tswap16(protocol);
- }
- print_socket_protocol(domain, type, protocol);
- qemu_log(")");
- }
- static void do_print_sockaddr(const char *name, abi_long arg1)
- {
- abi_ulong sockfd, addr, addrlen;
- get_user_ualx(sockfd, arg1, 0);
- get_user_ualx(addr, arg1, 1);
- get_user_ualx(addrlen, arg1, 2);
- qemu_log("%s(", name);
- print_sockfd(sockfd, 0);
- print_sockaddr(addr, addrlen, 0);
- qemu_log(")");
- }
- static void do_print_listen(const char *name, abi_long arg1)
- {
- abi_ulong sockfd, backlog;
- get_user_ualx(sockfd, arg1, 0);
- get_user_ualx(backlog, arg1, 1);
- qemu_log("%s(", name);
- print_sockfd(sockfd, 0);
- print_raw_param(TARGET_ABI_FMT_ld, backlog, 1);
- qemu_log(")");
- }
- static void do_print_socketpair(const char *name, abi_long arg1)
- {
- abi_ulong domain, type, protocol, tab;
- get_user_ualx(domain, arg1, 0);
- get_user_ualx(type, arg1, 1);
- get_user_ualx(protocol, arg1, 2);
- get_user_ualx(tab, arg1, 3);
- qemu_log("%s(", name);
- print_socket_domain(domain);
- qemu_log(",");
- print_socket_type(type);
- qemu_log(",");
- print_socket_protocol(domain, type, protocol);
- qemu_log(",");
- print_raw_param(TARGET_ABI_FMT_lx, tab, 1);
- qemu_log(")");
- }
- static void do_print_sendrecv(const char *name, abi_long arg1)
- {
- abi_ulong sockfd, msg, len, flags;
- get_user_ualx(sockfd, arg1, 0);
- get_user_ualx(msg, arg1, 1);
- get_user_ualx(len, arg1, 2);
- get_user_ualx(flags, arg1, 3);
- qemu_log("%s(", name);
- print_sockfd(sockfd, 0);
- print_buf(msg, len, 0);
- print_raw_param(TARGET_ABI_FMT_ld, len, 0);
- print_flags(msg_flags, flags, 1);
- qemu_log(")");
- }
- static void do_print_msgaddr(const char *name, abi_long arg1)
- {
- abi_ulong sockfd, msg, len, flags, addr, addrlen;
- get_user_ualx(sockfd, arg1, 0);
- get_user_ualx(msg, arg1, 1);
- get_user_ualx(len, arg1, 2);
- get_user_ualx(flags, arg1, 3);
- get_user_ualx(addr, arg1, 4);
- get_user_ualx(addrlen, arg1, 5);
- qemu_log("%s(", name);
- print_sockfd(sockfd, 0);
- print_buf(msg, len, 0);
- print_raw_param(TARGET_ABI_FMT_ld, len, 0);
- print_flags(msg_flags, flags, 0);
- print_sockaddr(addr, addrlen, 0);
- qemu_log(")");
- }
- static void do_print_shutdown(const char *name, abi_long arg1)
- {
- abi_ulong sockfd, how;
- get_user_ualx(sockfd, arg1, 0);
- get_user_ualx(how, arg1, 1);
- qemu_log("shutdown(");
- print_sockfd(sockfd, 0);
- switch (how) {
- case SHUT_RD:
- qemu_log("SHUT_RD");
- break;
- case SHUT_WR:
- qemu_log("SHUT_WR");
- break;
- case SHUT_RDWR:
- qemu_log("SHUT_RDWR");
- break;
- default:
- print_raw_param(TARGET_ABI_FMT_ld, how, 1);
- break;
- }
- qemu_log(")");
- }
- static void do_print_msg(const char *name, abi_long arg1)
- {
- abi_ulong sockfd, msg, flags;
- get_user_ualx(sockfd, arg1, 0);
- get_user_ualx(msg, arg1, 1);
- get_user_ualx(flags, arg1, 2);
- qemu_log("%s(", name);
- print_sockfd(sockfd, 0);
- print_pointer(msg, 0);
- print_flags(msg_flags, flags, 1);
- qemu_log(")");
- }
- static void do_print_sockopt(const char *name, abi_long arg1)
- {
- abi_ulong sockfd, level, optname, optval, optlen;
- get_user_ualx(sockfd, arg1, 0);
- get_user_ualx(level, arg1, 1);
- get_user_ualx(optname, arg1, 2);
- get_user_ualx(optval, arg1, 3);
- get_user_ualx(optlen, arg1, 4);
- qemu_log("%s(", name);
- print_sockfd(sockfd, 0);
- switch (level) {
- case SOL_TCP:
- qemu_log("SOL_TCP,");
- print_raw_param(TARGET_ABI_FMT_ld, optname, 0);
- print_pointer(optval, 0);
- break;
- case SOL_UDP:
- qemu_log("SOL_UDP,");
- print_raw_param(TARGET_ABI_FMT_ld, optname, 0);
- print_pointer(optval, 0);
- break;
- case SOL_IP:
- qemu_log("SOL_IP,");
- print_raw_param(TARGET_ABI_FMT_ld, optname, 0);
- print_pointer(optval, 0);
- break;
- case SOL_RAW:
- qemu_log("SOL_RAW,");
- print_raw_param(TARGET_ABI_FMT_ld, optname, 0);
- print_pointer(optval, 0);
- break;
- case TARGET_SOL_SOCKET:
- qemu_log("SOL_SOCKET,");
- switch (optname) {
- case TARGET_SO_DEBUG:
- qemu_log("SO_DEBUG,");
- print_optint:
- print_number(optval, 0);
- break;
- case TARGET_SO_REUSEADDR:
- qemu_log("SO_REUSEADDR,");
- goto print_optint;
- case TARGET_SO_REUSEPORT:
- qemu_log("SO_REUSEPORT,");
- goto print_optint;
- case TARGET_SO_TYPE:
- qemu_log("SO_TYPE,");
- goto print_optint;
- case TARGET_SO_ERROR:
- qemu_log("SO_ERROR,");
- goto print_optint;
- case TARGET_SO_DONTROUTE:
- qemu_log("SO_DONTROUTE,");
- goto print_optint;
- case TARGET_SO_BROADCAST:
- qemu_log("SO_BROADCAST,");
- goto print_optint;
- case TARGET_SO_SNDBUF:
- qemu_log("SO_SNDBUF,");
- goto print_optint;
- case TARGET_SO_RCVBUF:
- qemu_log("SO_RCVBUF,");
- goto print_optint;
- case TARGET_SO_KEEPALIVE:
- qemu_log("SO_KEEPALIVE,");
- goto print_optint;
- case TARGET_SO_OOBINLINE:
- qemu_log("SO_OOBINLINE,");
- goto print_optint;
- case TARGET_SO_NO_CHECK:
- qemu_log("SO_NO_CHECK,");
- goto print_optint;
- case TARGET_SO_PRIORITY:
- qemu_log("SO_PRIORITY,");
- goto print_optint;
- case TARGET_SO_BSDCOMPAT:
- qemu_log("SO_BSDCOMPAT,");
- goto print_optint;
- case TARGET_SO_PASSCRED:
- qemu_log("SO_PASSCRED,");
- goto print_optint;
- case TARGET_SO_TIMESTAMP:
- qemu_log("SO_TIMESTAMP,");
- goto print_optint;
- case TARGET_SO_RCVLOWAT:
- qemu_log("SO_RCVLOWAT,");
- goto print_optint;
- case TARGET_SO_RCVTIMEO:
- qemu_log("SO_RCVTIMEO,");
- print_timeval(optval, 0);
- break;
- case TARGET_SO_SNDTIMEO:
- qemu_log("SO_SNDTIMEO,");
- print_timeval(optval, 0);
- break;
- case TARGET_SO_ATTACH_FILTER: {
- struct target_sock_fprog *fprog;
- qemu_log("SO_ATTACH_FILTER,");
- if (lock_user_struct(VERIFY_READ, fprog, optval, 0)) {
- struct target_sock_filter *filter;
- qemu_log("{");
- if (lock_user_struct(VERIFY_READ, filter,
- tswapal(fprog->filter), 0)) {
- int i;
- for (i = 0; i < tswap16(fprog->len) - 1; i++) {
- qemu_log("[%d]{0x%x,%d,%d,0x%x},",
- i, tswap16(filter[i].code),
- filter[i].jt, filter[i].jf,
- tswap32(filter[i].k));
- }
- qemu_log("[%d]{0x%x,%d,%d,0x%x}",
- i, tswap16(filter[i].code),
- filter[i].jt, filter[i].jf,
- tswap32(filter[i].k));
- } else {
- qemu_log(TARGET_ABI_FMT_lx, tswapal(fprog->filter));
- }
- qemu_log(",%d},", tswap16(fprog->len));
- unlock_user(fprog, optval, 0);
- } else {
- print_pointer(optval, 0);
- }
- break;
- }
- default:
- print_raw_param(TARGET_ABI_FMT_ld, optname, 0);
- print_pointer(optval, 0);
- break;
- }
- break;
- case SOL_IPV6:
- qemu_log("SOL_IPV6,");
- switch (optname) {
- case IPV6_MTU_DISCOVER:
- qemu_log("IPV6_MTU_DISCOVER,");
- goto print_optint;
- case IPV6_MTU:
- qemu_log("IPV6_MTU,");
- goto print_optint;
- case IPV6_V6ONLY:
- qemu_log("IPV6_V6ONLY,");
- goto print_optint;
- case IPV6_RECVPKTINFO:
- qemu_log("IPV6_RECVPKTINFO,");
- goto print_optint;
- case IPV6_UNICAST_HOPS:
- qemu_log("IPV6_UNICAST_HOPS,");
- goto print_optint;
- case IPV6_MULTICAST_HOPS:
- qemu_log("IPV6_MULTICAST_HOPS,");
- goto print_optint;
- case IPV6_MULTICAST_LOOP:
- qemu_log("IPV6_MULTICAST_LOOP,");
- goto print_optint;
- case IPV6_RECVERR:
- qemu_log("IPV6_RECVERR,");
- goto print_optint;
- case IPV6_RECVHOPLIMIT:
- qemu_log("IPV6_RECVHOPLIMIT,");
- goto print_optint;
- case IPV6_2292HOPLIMIT:
- qemu_log("IPV6_2292HOPLIMIT,");
- goto print_optint;
- case IPV6_CHECKSUM:
- qemu_log("IPV6_CHECKSUM,");
- goto print_optint;
- case IPV6_ADDRFORM:
- qemu_log("IPV6_ADDRFORM,");
- goto print_optint;
- case IPV6_2292PKTINFO:
- qemu_log("IPV6_2292PKTINFO,");
- goto print_optint;
- case IPV6_RECVTCLASS:
- qemu_log("IPV6_RECVTCLASS,");
- goto print_optint;
- case IPV6_RECVRTHDR:
- qemu_log("IPV6_RECVRTHDR,");
- goto print_optint;
- case IPV6_2292RTHDR:
- qemu_log("IPV6_2292RTHDR,");
- goto print_optint;
- case IPV6_RECVHOPOPTS:
- qemu_log("IPV6_RECVHOPOPTS,");
- goto print_optint;
- case IPV6_2292HOPOPTS:
- qemu_log("IPV6_2292HOPOPTS,");
- goto print_optint;
- case IPV6_RECVDSTOPTS:
- qemu_log("IPV6_RECVDSTOPTS,");
- goto print_optint;
- case IPV6_2292DSTOPTS:
- qemu_log("IPV6_2292DSTOPTS,");
- goto print_optint;
- case IPV6_TCLASS:
- qemu_log("IPV6_TCLASS,");
- goto print_optint;
- case IPV6_ADDR_PREFERENCES:
- qemu_log("IPV6_ADDR_PREFERENCES,");
- goto print_optint;
- #ifdef IPV6_RECVPATHMTU
- case IPV6_RECVPATHMTU:
- qemu_log("IPV6_RECVPATHMTU,");
- goto print_optint;
- #endif
- #ifdef IPV6_TRANSPARENT
- case IPV6_TRANSPARENT:
- qemu_log("IPV6_TRANSPARENT,");
- goto print_optint;
- #endif
- #ifdef IPV6_FREEBIND
- case IPV6_FREEBIND:
- qemu_log("IPV6_FREEBIND,");
- goto print_optint;
- #endif
- #ifdef IPV6_RECVORIGDSTADDR
- case IPV6_RECVORIGDSTADDR:
- qemu_log("IPV6_RECVORIGDSTADDR,");
- goto print_optint;
- #endif
- case IPV6_PKTINFO:
- qemu_log("IPV6_PKTINFO,");
- print_pointer(optval, 0);
- break;
- case IPV6_ADD_MEMBERSHIP:
- qemu_log("IPV6_ADD_MEMBERSHIP,");
- print_pointer(optval, 0);
- break;
- case IPV6_DROP_MEMBERSHIP:
- qemu_log("IPV6_DROP_MEMBERSHIP,");
- print_pointer(optval, 0);
- break;
- default:
- print_raw_param(TARGET_ABI_FMT_ld, optname, 0);
- print_pointer(optval, 0);
- break;
- }
- break;
- default:
- print_raw_param(TARGET_ABI_FMT_ld, level, 0);
- print_raw_param(TARGET_ABI_FMT_ld, optname, 0);
- print_pointer(optval, 0);
- break;
- }
- print_raw_param(TARGET_ABI_FMT_ld, optlen, 1);
- qemu_log(")");
- }
- #define PRINT_SOCKOP(name, func) \
- [TARGET_SYS_##name] = { #name, func }
- static struct {
- const char *name;
- void (*print)(const char *, abi_long);
- } scall[] = {
- PRINT_SOCKOP(SOCKET, do_print_socket),
- PRINT_SOCKOP(BIND, do_print_sockaddr),
- PRINT_SOCKOP(CONNECT, do_print_sockaddr),
- PRINT_SOCKOP(LISTEN, do_print_listen),
- PRINT_SOCKOP(ACCEPT, do_print_sockaddr),
- PRINT_SOCKOP(GETSOCKNAME, do_print_sockaddr),
- PRINT_SOCKOP(GETPEERNAME, do_print_sockaddr),
- PRINT_SOCKOP(SOCKETPAIR, do_print_socketpair),
- PRINT_SOCKOP(SEND, do_print_sendrecv),
- PRINT_SOCKOP(RECV, do_print_sendrecv),
- PRINT_SOCKOP(SENDTO, do_print_msgaddr),
- PRINT_SOCKOP(RECVFROM, do_print_msgaddr),
- PRINT_SOCKOP(SHUTDOWN, do_print_shutdown),
- PRINT_SOCKOP(SETSOCKOPT, do_print_sockopt),
- PRINT_SOCKOP(GETSOCKOPT, do_print_sockopt),
- PRINT_SOCKOP(SENDMSG, do_print_msg),
- PRINT_SOCKOP(RECVMSG, do_print_msg),
- PRINT_SOCKOP(ACCEPT4, NULL),
- PRINT_SOCKOP(RECVMMSG, NULL),
- PRINT_SOCKOP(SENDMMSG, NULL),
- };
- static void
- print_socketcall(CPUArchState *cpu_env, const struct syscallname *name,
- abi_long arg0, abi_long arg1, abi_long arg2,
- abi_long arg3, abi_long arg4, abi_long arg5)
- {
- if (arg0 >= 0 && arg0 < ARRAY_SIZE(scall) && scall[arg0].print) {
- scall[arg0].print(scall[arg0].name, arg1);
- return;
- }
- print_syscall_prologue(name);
- print_raw_param(TARGET_ABI_FMT_ld, arg0, 0);
- print_raw_param(TARGET_ABI_FMT_ld, arg1, 0);
- print_raw_param(TARGET_ABI_FMT_ld, arg2, 0);
- print_raw_param(TARGET_ABI_FMT_ld, arg3, 0);
- print_raw_param(TARGET_ABI_FMT_ld, arg4, 0);
- print_raw_param(TARGET_ABI_FMT_ld, arg5, 0);
- print_syscall_epilogue(name);
- }
- #endif
- #if defined(TARGET_NR_bind)
- static void
- print_bind(CPUArchState *cpu_env, const struct syscallname *name,
- abi_long arg0, abi_long arg1, abi_long arg2,
- abi_long arg3, abi_long arg4, abi_long arg5)
- {
- print_syscall_prologue(name);
- print_sockfd(arg0, 0);
- print_sockaddr(arg1, arg2, 1);
- print_syscall_epilogue(name);
- }
- #endif
- #if defined(TARGET_NR_stat) || defined(TARGET_NR_stat64) || \
- defined(TARGET_NR_lstat) || defined(TARGET_NR_lstat64)
- static void
- print_stat(CPUArchState *cpu_env, const struct syscallname *name,
- abi_long arg0, abi_long arg1, abi_long arg2,
- abi_long arg3, abi_long arg4, abi_long arg5)
- {
- print_syscall_prologue(name);
- print_string(arg0, 0);
- print_pointer(arg1, 1);
- print_syscall_epilogue(name);
- }
- #define print_lstat print_stat
- #define print_stat64 print_stat
- #define print_lstat64 print_stat
- #endif
- #if defined(TARGET_NR_madvise)
- static struct enums madvise_advice[] = {
- ENUM_TARGET(MADV_NORMAL),
- ENUM_TARGET(MADV_RANDOM),
- ENUM_TARGET(MADV_SEQUENTIAL),
- ENUM_TARGET(MADV_WILLNEED),
- ENUM_TARGET(MADV_DONTNEED),
- ENUM_TARGET(MADV_FREE),
- ENUM_TARGET(MADV_REMOVE),
- ENUM_TARGET(MADV_DONTFORK),
- ENUM_TARGET(MADV_DOFORK),
- ENUM_TARGET(MADV_MERGEABLE),
- ENUM_TARGET(MADV_UNMERGEABLE),
- ENUM_TARGET(MADV_HUGEPAGE),
- ENUM_TARGET(MADV_NOHUGEPAGE),
- ENUM_TARGET(MADV_DONTDUMP),
- ENUM_TARGET(MADV_DODUMP),
- ENUM_TARGET(MADV_WIPEONFORK),
- ENUM_TARGET(MADV_KEEPONFORK),
- ENUM_TARGET(MADV_COLD),
- ENUM_TARGET(MADV_PAGEOUT),
- ENUM_TARGET(MADV_POPULATE_READ),
- ENUM_TARGET(MADV_POPULATE_WRITE),
- ENUM_TARGET(MADV_DONTNEED_LOCKED),
- ENUM_END,
- };
- static void
- print_madvise(CPUArchState *cpu_env, const struct syscallname *name,
- abi_long arg0, abi_long arg1, abi_long arg2,
- abi_long arg3, abi_long arg4, abi_long arg5)
- {
- print_syscall_prologue(name);
- print_pointer(arg0, 0);
- print_raw_param("%d", arg1, 0);
- print_enums(madvise_advice, arg2, 1);
- print_syscall_epilogue(name);
- }
- #endif
- #if defined(TARGET_NR_fstat) || defined(TARGET_NR_fstat64)
- static void
- print_fstat(CPUArchState *cpu_env, const struct syscallname *name,
- abi_long arg0, abi_long arg1, abi_long arg2,
- abi_long arg3, abi_long arg4, abi_long arg5)
- {
- print_syscall_prologue(name);
- print_raw_param("%d", arg0, 0);
- print_pointer(arg1, 1);
- print_syscall_epilogue(name);
- }
- #define print_fstat64 print_fstat
- #endif
- #ifdef TARGET_NR_mkdir
- static void
- print_mkdir(CPUArchState *cpu_env, const struct syscallname *name,
- abi_long arg0, abi_long arg1, abi_long arg2,
- abi_long arg3, abi_long arg4, abi_long arg5)
- {
- print_syscall_prologue(name);
- print_string(arg0, 0);
- print_file_mode(arg1, 1);
- print_syscall_epilogue(name);
- }
- #endif
- #ifdef TARGET_NR_mkdirat
- static void
- print_mkdirat(CPUArchState *cpu_env, const struct syscallname *name,
- abi_long arg0, abi_long arg1, abi_long arg2,
- abi_long arg3, abi_long arg4, abi_long arg5)
- {
- print_syscall_prologue(name);
- print_at_dirfd(arg0, 0);
- print_string(arg1, 0);
- print_file_mode(arg2, 1);
- print_syscall_epilogue(name);
- }
- #endif
- #ifdef TARGET_NR_rmdir
- static void
- print_rmdir(CPUArchState *cpu_env, const struct syscallname *name,
- abi_long arg0, abi_long arg1, abi_long arg2,
- abi_long arg3, abi_long arg4, abi_long arg5)
- {
- print_syscall_prologue(name);
- print_string(arg0, 0);
- print_syscall_epilogue(name);
- }
- #endif
- #ifdef TARGET_NR_rt_sigaction
- static void
- print_rt_sigaction(CPUArchState *cpu_env, const struct syscallname *name,
- abi_long arg0, abi_long arg1, abi_long arg2,
- abi_long arg3, abi_long arg4, abi_long arg5)
- {
- print_syscall_prologue(name);
- print_signal(arg0, 0);
- print_pointer(arg1, 0);
- print_pointer(arg2, 1);
- print_syscall_epilogue(name);
- }
- #endif
- #ifdef TARGET_NR_rt_sigprocmask
- static void
- print_rt_sigprocmask(CPUArchState *cpu_env, const struct syscallname *name,
- abi_long arg0, abi_long arg1, abi_long arg2,
- abi_long arg3, abi_long arg4, abi_long arg5)
- {
- const char *how = "UNKNOWN";
- print_syscall_prologue(name);
- switch(arg0) {
- case TARGET_SIG_BLOCK: how = "SIG_BLOCK"; break;
- case TARGET_SIG_UNBLOCK: how = "SIG_UNBLOCK"; break;
- case TARGET_SIG_SETMASK: how = "SIG_SETMASK"; break;
- }
- qemu_log("%s,", how);
- print_pointer(arg1, 0);
- print_pointer(arg2, 0);
- print_raw_param("%u", arg3, 1);
- print_syscall_epilogue(name);
- }
- #endif
- #ifdef TARGET_NR_rt_sigqueueinfo
- static void
- print_rt_sigqueueinfo(CPUArchState *cpu_env, const struct syscallname *name,
- abi_long arg0, abi_long arg1, abi_long arg2,
- abi_long arg3, abi_long arg4, abi_long arg5)
- {
- void *p;
- target_siginfo_t uinfo;
- print_syscall_prologue(name);
- print_raw_param("%d", arg0, 0);
- print_signal(arg1, 0);
- p = lock_user(VERIFY_READ, arg2, sizeof(target_siginfo_t), 1);
- if (p) {
- get_target_siginfo(&uinfo, p);
- print_siginfo(&uinfo);
- unlock_user(p, arg2, 0);
- } else {
- print_pointer(arg2, 1);
- }
- print_syscall_epilogue(name);
- }
- #endif
- #ifdef TARGET_NR_rt_tgsigqueueinfo
- static void
- print_rt_tgsigqueueinfo(CPUArchState *cpu_env, const struct syscallname *name,
- abi_long arg0, abi_long arg1, abi_long arg2,
- abi_long arg3, abi_long arg4, abi_long arg5)
- {
- void *p;
- target_siginfo_t uinfo;
- print_syscall_prologue(name);
- print_raw_param("%d", arg0, 0);
- print_raw_param("%d", arg1, 0);
- print_signal(arg2, 0);
- p = lock_user(VERIFY_READ, arg3, sizeof(target_siginfo_t), 1);
- if (p) {
- get_target_siginfo(&uinfo, p);
- print_siginfo(&uinfo);
- unlock_user(p, arg3, 0);
- } else {
- print_pointer(arg3, 1);
- }
- print_syscall_epilogue(name);
- }
- #endif
- #ifdef TARGET_NR_syslog
- static void
- print_syslog_action(abi_ulong arg, int last)
- {
- const char *type;
- switch (arg) {
- case TARGET_SYSLOG_ACTION_CLOSE: {
- type = "SYSLOG_ACTION_CLOSE";
- break;
- }
- case TARGET_SYSLOG_ACTION_OPEN: {
- type = "SYSLOG_ACTION_OPEN";
- break;
- }
- case TARGET_SYSLOG_ACTION_READ: {
- type = "SYSLOG_ACTION_READ";
- break;
- }
- case TARGET_SYSLOG_ACTION_READ_ALL: {
- type = "SYSLOG_ACTION_READ_ALL";
- break;
- }
- case TARGET_SYSLOG_ACTION_READ_CLEAR: {
- type = "SYSLOG_ACTION_READ_CLEAR";
- break;
- }
- case TARGET_SYSLOG_ACTION_CLEAR: {
- type = "SYSLOG_ACTION_CLEAR";
- break;
- }
- case TARGET_SYSLOG_ACTION_CONSOLE_OFF: {
- type = "SYSLOG_ACTION_CONSOLE_OFF";
- break;
- }
- case TARGET_SYSLOG_ACTION_CONSOLE_ON: {
- type = "SYSLOG_ACTION_CONSOLE_ON";
- break;
- }
- case TARGET_SYSLOG_ACTION_CONSOLE_LEVEL: {
- type = "SYSLOG_ACTION_CONSOLE_LEVEL";
- break;
- }
- case TARGET_SYSLOG_ACTION_SIZE_UNREAD: {
- type = "SYSLOG_ACTION_SIZE_UNREAD";
- break;
- }
- case TARGET_SYSLOG_ACTION_SIZE_BUFFER: {
- type = "SYSLOG_ACTION_SIZE_BUFFER";
- break;
- }
- default: {
- print_raw_param("%ld", arg, last);
- return;
- }
- }
- qemu_log("%s%s", type, get_comma(last));
- }
- static void
- print_syslog(CPUArchState *cpu_env, const struct syscallname *name,
- abi_long arg0, abi_long arg1, abi_long arg2,
- abi_long arg3, abi_long arg4, abi_long arg5)
- {
- print_syscall_prologue(name);
- print_syslog_action(arg0, 0);
- print_pointer(arg1, 0);
- print_raw_param("%d", arg2, 1);
- print_syscall_epilogue(name);
- }
- #endif
- #ifdef TARGET_NR_mknod
- static void
- print_mknod(CPUArchState *cpu_env, const struct syscallname *name,
- abi_long arg0, abi_long arg1, abi_long arg2,
- abi_long arg3, abi_long arg4, abi_long arg5)
- {
- int hasdev = (arg1 & (S_IFCHR|S_IFBLK));
- print_syscall_prologue(name);
- print_string(arg0, 0);
- print_file_mode(arg1, (hasdev == 0));
- if (hasdev) {
- print_raw_param("makedev(%d", major(arg2), 0);
- print_raw_param("%d)", minor(arg2), 1);
- }
- print_syscall_epilogue(name);
- }
- #endif
- #ifdef TARGET_NR_mknodat
- static void
- print_mknodat(CPUArchState *cpu_env, const struct syscallname *name,
- abi_long arg0, abi_long arg1, abi_long arg2,
- abi_long arg3, abi_long arg4, abi_long arg5)
- {
- int hasdev = (arg2 & (S_IFCHR|S_IFBLK));
- print_syscall_prologue(name);
- print_at_dirfd(arg0, 0);
- print_string(arg1, 0);
- print_file_mode(arg2, (hasdev == 0));
- if (hasdev) {
- print_raw_param("makedev(%d", major(arg3), 0);
- print_raw_param("%d)", minor(arg3), 1);
- }
- print_syscall_epilogue(name);
- }
- #endif
- #ifdef TARGET_NR_mq_open
- static void
- print_mq_open(CPUArchState *cpu_env, const struct syscallname *name,
- abi_long arg0, abi_long arg1, abi_long arg2,
- abi_long arg3, abi_long arg4, abi_long arg5)
- {
- int is_creat = (arg1 & TARGET_O_CREAT);
- print_syscall_prologue(name);
- print_string(arg0, 0);
- print_open_flags(arg1, (is_creat == 0));
- if (is_creat) {
- print_file_mode(arg2, 0);
- print_pointer(arg3, 1);
- }
- print_syscall_epilogue(name);
- }
- #endif
- #ifdef TARGET_NR_open
- static void
- print_open(CPUArchState *cpu_env, const struct syscallname *name,
- abi_long arg0, abi_long arg1, abi_long arg2,
- abi_long arg3, abi_long arg4, abi_long arg5)
- {
- int is_creat = (arg1 & TARGET_O_CREAT);
- print_syscall_prologue(name);
- print_string(arg0, 0);
- print_open_flags(arg1, (is_creat == 0));
- if (is_creat)
- print_file_mode(arg2, 1);
- print_syscall_epilogue(name);
- }
- #endif
- #ifdef TARGET_NR_openat
- static void
- print_openat(CPUArchState *cpu_env, const struct syscallname *name,
- abi_long arg0, abi_long arg1, abi_long arg2,
- abi_long arg3, abi_long arg4, abi_long arg5)
- {
- int is_creat = (arg2 & TARGET_O_CREAT);
- print_syscall_prologue(name);
- print_at_dirfd(arg0, 0);
- print_string(arg1, 0);
- print_open_flags(arg2, (is_creat == 0));
- if (is_creat)
- print_file_mode(arg3, 1);
- print_syscall_epilogue(name);
- }
- #endif
- #ifdef TARGET_NR_pidfd_send_signal
- static void
- print_pidfd_send_signal(CPUArchState *cpu_env, const struct syscallname *name,
- abi_long arg0, abi_long arg1, abi_long arg2,
- abi_long arg3, abi_long arg4, abi_long arg5)
- {
- void *p;
- target_siginfo_t uinfo;
- print_syscall_prologue(name);
- print_raw_param("%d", arg0, 0);
- print_signal(arg1, 0);
- p = lock_user(VERIFY_READ, arg2, sizeof(target_siginfo_t), 1);
- if (p) {
- get_target_siginfo(&uinfo, p);
- print_siginfo(&uinfo);
- unlock_user(p, arg2, 0);
- } else {
- print_pointer(arg2, 0);
- }
- print_raw_param("%u", arg3, 1);
- print_syscall_epilogue(name);
- }
- #endif
- #ifdef TARGET_NR_mq_unlink
- static void
- print_mq_unlink(CPUArchState *cpu_env, const struct syscallname *name,
- abi_long arg0, abi_long arg1, abi_long arg2,
- abi_long arg3, abi_long arg4, abi_long arg5)
- {
- print_syscall_prologue(name);
- print_string(arg0, 1);
- print_syscall_epilogue(name);
- }
- #endif
- #if defined(TARGET_NR_fstatat64) || defined(TARGET_NR_newfstatat)
- static void
- print_fstatat64(CPUArchState *cpu_env, const struct syscallname *name,
- abi_long arg0, abi_long arg1, abi_long arg2,
- abi_long arg3, abi_long arg4, abi_long arg5)
- {
- print_syscall_prologue(name);
- print_at_dirfd(arg0, 0);
- print_string(arg1, 0);
- print_pointer(arg2, 0);
- print_flags(at_file_flags, arg3, 1);
- print_syscall_epilogue(name);
- }
- #define print_newfstatat print_fstatat64
- #endif
- #ifdef TARGET_NR_readlink
- static void
- print_readlink(CPUArchState *cpu_env, const struct syscallname *name,
- abi_long arg0, abi_long arg1, abi_long arg2,
- abi_long arg3, abi_long arg4, abi_long arg5)
- {
- print_syscall_prologue(name);
- print_string(arg0, 0);
- print_pointer(arg1, 0);
- print_raw_param("%u", arg2, 1);
- print_syscall_epilogue(name);
- }
- #endif
- #ifdef TARGET_NR_readlinkat
- static void
- print_readlinkat(CPUArchState *cpu_env, const struct syscallname *name,
- abi_long arg0, abi_long arg1, abi_long arg2,
- abi_long arg3, abi_long arg4, abi_long arg5)
- {
- print_syscall_prologue(name);
- print_at_dirfd(arg0, 0);
- print_string(arg1, 0);
- print_pointer(arg2, 0);
- print_raw_param("%u", arg3, 1);
- print_syscall_epilogue(name);
- }
- #endif
- #ifdef TARGET_NR_rename
- static void
- print_rename(CPUArchState *cpu_env, const struct syscallname *name,
- abi_long arg0, abi_long arg1, abi_long arg2,
- abi_long arg3, abi_long arg4, abi_long arg5)
- {
- print_syscall_prologue(name);
- print_string(arg0, 0);
- print_string(arg1, 1);
- print_syscall_epilogue(name);
- }
- #endif
- #ifdef TARGET_NR_renameat
- static void
- print_renameat(CPUArchState *cpu_env, const struct syscallname *name,
- abi_long arg0, abi_long arg1, abi_long arg2,
- abi_long arg3, abi_long arg4, abi_long arg5)
- {
- print_syscall_prologue(name);
- print_at_dirfd(arg0, 0);
- print_string(arg1, 0);
- print_at_dirfd(arg2, 0);
- print_string(arg3, 1);
- print_syscall_epilogue(name);
- }
- #endif
- #ifdef TARGET_NR_statfs
- static void
- print_statfs(CPUArchState *cpu_env, const struct syscallname *name,
- abi_long arg0, abi_long arg1, abi_long arg2,
- abi_long arg3, abi_long arg4, abi_long arg5)
- {
- print_syscall_prologue(name);
- print_string(arg0, 0);
- print_pointer(arg1, 1);
- print_syscall_epilogue(name);
- }
- #endif
- #ifdef TARGET_NR_statfs64
- static void
- print_statfs64(CPUArchState *cpu_env, const struct syscallname *name,
- abi_long arg0, abi_long arg1, abi_long arg2,
- abi_long arg3, abi_long arg4, abi_long arg5)
- {
- print_syscall_prologue(name);
- print_string(arg0, 0);
- print_pointer(arg1, 1);
- print_syscall_epilogue(name);
- }
- #endif
- #ifdef TARGET_NR_symlink
- static void
- print_symlink(CPUArchState *cpu_env, const struct syscallname *name,
- abi_long arg0, abi_long arg1, abi_long arg2,
- abi_long arg3, abi_long arg4, abi_long arg5)
- {
- print_syscall_prologue(name);
- print_string(arg0, 0);
- print_string(arg1, 1);
- print_syscall_epilogue(name);
- }
- #endif
- #ifdef TARGET_NR_symlinkat
- static void
- print_symlinkat(CPUArchState *cpu_env, const struct syscallname *name,
- abi_long arg0, abi_long arg1, abi_long arg2,
- abi_long arg3, abi_long arg4, abi_long arg5)
- {
- print_syscall_prologue(name);
- print_string(arg0, 0);
- print_at_dirfd(arg1, 0);
- print_string(arg2, 1);
- print_syscall_epilogue(name);
- }
- #endif
- #ifdef TARGET_NR_mount
- static void
- print_mount(CPUArchState *cpu_env, const struct syscallname *name,
- abi_long arg0, abi_long arg1, abi_long arg2,
- abi_long arg3, abi_long arg4, abi_long arg5)
- {
- print_syscall_prologue(name);
- print_string(arg0, 0);
- print_string(arg1, 0);
- print_string(arg2, 0);
- print_flags(mount_flags, arg3, 0);
- print_pointer(arg4, 1);
- print_syscall_epilogue(name);
- }
- #endif
- #ifdef TARGET_NR_umount
- static void
- print_umount(CPUArchState *cpu_env, const struct syscallname *name,
- abi_long arg0, abi_long arg1, abi_long arg2,
- abi_long arg3, abi_long arg4, abi_long arg5)
- {
- print_syscall_prologue(name);
- print_string(arg0, 1);
- print_syscall_epilogue(name);
- }
- #endif
- #ifdef TARGET_NR_umount2
- static void
- print_umount2(CPUArchState *cpu_env, const struct syscallname *name,
- abi_long arg0, abi_long arg1, abi_long arg2,
- abi_long arg3, abi_long arg4, abi_long arg5)
- {
- print_syscall_prologue(name);
- print_string(arg0, 0);
- print_flags(umount2_flags, arg1, 1);
- print_syscall_epilogue(name);
- }
- #endif
- #ifdef TARGET_NR_unlink
- static void
- print_unlink(CPUArchState *cpu_env, const struct syscallname *name,
- abi_long arg0, abi_long arg1, abi_long arg2,
- abi_long arg3, abi_long arg4, abi_long arg5)
- {
- print_syscall_prologue(name);
- print_string(arg0, 1);
- print_syscall_epilogue(name);
- }
- #endif
- #ifdef TARGET_NR_unlinkat
- static void
- print_unlinkat(CPUArchState *cpu_env, const struct syscallname *name,
- abi_long arg0, abi_long arg1, abi_long arg2,
- abi_long arg3, abi_long arg4, abi_long arg5)
- {
- print_syscall_prologue(name);
- print_at_dirfd(arg0, 0);
- print_string(arg1, 0);
- print_flags(unlinkat_flags, arg2, 1);
- print_syscall_epilogue(name);
- }
- #endif
- #ifdef TARGET_NR_unshare
- static void
- print_unshare(CPUArchState *cpu_env, const struct syscallname *name,
- abi_long arg0, abi_long arg1, abi_long arg2,
- abi_long arg3, abi_long arg4, abi_long arg5)
- {
- print_syscall_prologue(name);
- print_flags(clone_flags, arg0, 1);
- print_syscall_epilogue(name);
- }
- #endif
- #ifdef TARGET_NR_clock_nanosleep
- static void
- print_clock_nanosleep(CPUArchState *cpu_env, const struct syscallname *name,
- abi_long arg0, abi_long arg1, abi_long arg2,
- abi_long arg3, abi_long arg4, abi_long arg5)
- {
- print_syscall_prologue(name);
- print_enums(clockids, arg0, 0);
- print_raw_param("%d", arg1, 0);
- print_timespec(arg2, 0);
- print_timespec(arg3, 1);
- print_syscall_epilogue(name);
- }
- #endif
- #ifdef TARGET_NR_utime
- static void
- print_utime(CPUArchState *cpu_env, const struct syscallname *name,
- abi_long arg0, abi_long arg1, abi_long arg2,
- abi_long arg3, abi_long arg4, abi_long arg5)
- {
- print_syscall_prologue(name);
- print_string(arg0, 0);
- print_pointer(arg1, 1);
- print_syscall_epilogue(name);
- }
- #endif
- #ifdef TARGET_NR_utimes
- static void
- print_utimes(CPUArchState *cpu_env, const struct syscallname *name,
- abi_long arg0, abi_long arg1, abi_long arg2,
- abi_long arg3, abi_long arg4, abi_long arg5)
- {
- print_syscall_prologue(name);
- print_string(arg0, 0);
- print_pointer(arg1, 1);
- print_syscall_epilogue(name);
- }
- #endif
- #ifdef TARGET_NR_utimensat
- static void
- print_utimensat(CPUArchState *cpu_env, const struct syscallname *name,
- abi_long arg0, abi_long arg1, abi_long arg2,
- abi_long arg3, abi_long arg4, abi_long arg5)
- {
- print_syscall_prologue(name);
- print_at_dirfd(arg0, 0);
- print_string(arg1, 0);
- print_pointer(arg2, 0);
- print_flags(at_file_flags, arg3, 1);
- print_syscall_epilogue(name);
- }
- #endif
- #if defined(TARGET_NR_mmap) || defined(TARGET_NR_mmap2)
- static void
- print_mmap(CPUArchState *cpu_env, const struct syscallname *name,
- abi_long arg0, abi_long arg1, abi_long arg2,
- abi_long arg3, abi_long arg4, abi_long arg5)
- {
- print_syscall_prologue(name);
- print_pointer(arg0, 0);
- print_raw_param("%d", arg1, 0);
- print_flags(mmap_prot_flags, arg2, 0);
- print_flags(mmap_flags, arg3, 0);
- print_raw_param("%d", arg4, 0);
- print_raw_param("%#x", arg5, 1);
- print_syscall_epilogue(name);
- }
- #define print_mmap2 print_mmap
- #endif
- #ifdef TARGET_NR_mprotect
- static void
- print_mprotect(CPUArchState *cpu_env, const struct syscallname *name,
- abi_long arg0, abi_long arg1, abi_long arg2,
- abi_long arg3, abi_long arg4, abi_long arg5)
- {
- print_syscall_prologue(name);
- print_pointer(arg0, 0);
- print_raw_param("%d", arg1, 0);
- print_flags(mmap_prot_flags, arg2, 1);
- print_syscall_epilogue(name);
- }
- #endif
- #ifdef TARGET_NR_munmap
- static void
- print_munmap(CPUArchState *cpu_env, const struct syscallname *name,
- abi_long arg0, abi_long arg1, abi_long arg2,
- abi_long arg3, abi_long arg4, abi_long arg5)
- {
- print_syscall_prologue(name);
- print_pointer(arg0, 0);
- print_raw_param("%d", arg1, 1);
- print_syscall_epilogue(name);
- }
- #endif
- #ifdef TARGET_NR_futex
- static void print_futex_op(int cmd, int last)
- {
- static const char * const futex_names[] = {
- #define NAME(X) [X] = #X
- NAME(FUTEX_WAIT),
- NAME(FUTEX_WAKE),
- NAME(FUTEX_FD),
- NAME(FUTEX_REQUEUE),
- NAME(FUTEX_CMP_REQUEUE),
- NAME(FUTEX_WAKE_OP),
- NAME(FUTEX_LOCK_PI),
- NAME(FUTEX_UNLOCK_PI),
- NAME(FUTEX_TRYLOCK_PI),
- NAME(FUTEX_WAIT_BITSET),
- NAME(FUTEX_WAKE_BITSET),
- NAME(FUTEX_WAIT_REQUEUE_PI),
- NAME(FUTEX_CMP_REQUEUE_PI),
- NAME(FUTEX_LOCK_PI2),
- #undef NAME
- };
- unsigned base_cmd = cmd & FUTEX_CMD_MASK;
- if (base_cmd < ARRAY_SIZE(futex_names)) {
- qemu_log("%s%s%s",
- (cmd & FUTEX_PRIVATE_FLAG ? "FUTEX_PRIVATE_FLAG|" : ""),
- (cmd & FUTEX_CLOCK_REALTIME ? "FUTEX_CLOCK_REALTIME|" : ""),
- futex_names[base_cmd]);
- } else {
- qemu_log("0x%x", cmd);
- }
- }
- static void
- print_futex(CPUArchState *cpu_env, const struct syscallname *name,
- abi_long arg0, abi_long arg1, abi_long arg2,
- abi_long arg3, abi_long arg4, abi_long arg5)
- {
- abi_long op = arg1 & FUTEX_CMD_MASK;
- print_syscall_prologue(name);
- print_pointer(arg0, 0);
- print_futex_op(arg1, 0);
- print_raw_param(",%d", arg2, 0);
- switch (op) {
- case FUTEX_WAIT:
- case FUTEX_WAIT_BITSET:
- case FUTEX_LOCK_PI:
- case FUTEX_LOCK_PI2:
- case FUTEX_WAIT_REQUEUE_PI:
- print_timespec(arg3, 0);
- break;
- default:
- print_pointer(arg3, 0);
- break;
- }
- print_pointer(arg4, 0);
- print_raw_param("%d", arg4, 1);
- print_syscall_epilogue(name);
- }
- #endif
- #ifdef TARGET_NR_prlimit64
- static const char *target_ressource_string(abi_ulong r)
- {
- #define RET_RES_ENTRY(res) case TARGET_##res: return #res;
- switch (r) {
- RET_RES_ENTRY(RLIMIT_AS);
- RET_RES_ENTRY(RLIMIT_CORE);
- RET_RES_ENTRY(RLIMIT_CPU);
- RET_RES_ENTRY(RLIMIT_DATA);
- RET_RES_ENTRY(RLIMIT_FSIZE);
- RET_RES_ENTRY(RLIMIT_LOCKS);
- RET_RES_ENTRY(RLIMIT_MEMLOCK);
- RET_RES_ENTRY(RLIMIT_MSGQUEUE);
- RET_RES_ENTRY(RLIMIT_NICE);
- RET_RES_ENTRY(RLIMIT_NOFILE);
- RET_RES_ENTRY(RLIMIT_NPROC);
- RET_RES_ENTRY(RLIMIT_RSS);
- RET_RES_ENTRY(RLIMIT_RTPRIO);
- #ifdef RLIMIT_RTTIME
- RET_RES_ENTRY(RLIMIT_RTTIME);
- #endif
- RET_RES_ENTRY(RLIMIT_SIGPENDING);
- RET_RES_ENTRY(RLIMIT_STACK);
- default:
- return NULL;
- }
- #undef RET_RES_ENTRY
- }
- static void
- print_rlimit64(abi_ulong rlim_addr, int last)
- {
- if (rlim_addr) {
- struct target_rlimit64 *rl;
- rl = lock_user(VERIFY_READ, rlim_addr, sizeof(*rl), 1);
- if (!rl) {
- print_pointer(rlim_addr, last);
- return;
- }
- print_raw_param64("{rlim_cur=%" PRId64, tswap64(rl->rlim_cur), 0);
- print_raw_param64("rlim_max=%" PRId64 "}", tswap64(rl->rlim_max),
- last);
- unlock_user(rl, rlim_addr, 0);
- } else {
- qemu_log("NULL%s", get_comma(last));
- }
- }
- static void
- print_prlimit64(CPUArchState *cpu_env, const struct syscallname *name,
- abi_long arg0, abi_long arg1, abi_long arg2,
- abi_long arg3, abi_long arg4, abi_long arg5)
- {
- const char *rlim_name;
- print_syscall_prologue(name);
- print_raw_param("%d", arg0, 0);
- rlim_name = target_ressource_string(arg1);
- if (rlim_name) {
- qemu_log("%s,", rlim_name);
- } else {
- print_raw_param("%d", arg1, 0);
- }
- print_rlimit64(arg2, 0);
- print_pointer(arg3, 1);
- print_syscall_epilogue(name);
- }
- static void
- print_syscall_ret_prlimit64(CPUArchState *cpu_env,
- const struct syscallname *name,
- abi_long ret, abi_long arg0, abi_long arg1,
- abi_long arg2, abi_long arg3, abi_long arg4,
- abi_long arg5)
- {
- if (!print_syscall_err(ret)) {
- qemu_log(TARGET_ABI_FMT_ld, ret);
- if (arg3) {
- qemu_log(" (");
- print_rlimit64(arg3, 1);
- qemu_log(")");
- }
- }
- qemu_log("\n");
- }
- #endif
- #ifdef TARGET_NR_kill
- static void
- print_kill(CPUArchState *cpu_env, const struct syscallname *name,
- abi_long arg0, abi_long arg1, abi_long arg2,
- abi_long arg3, abi_long arg4, abi_long arg5)
- {
- print_syscall_prologue(name);
- print_raw_param("%d", arg0, 0);
- print_signal(arg1, 1);
- print_syscall_epilogue(name);
- }
- #endif
- #ifdef TARGET_NR_tkill
- static void
- print_tkill(CPUArchState *cpu_env, const struct syscallname *name,
- abi_long arg0, abi_long arg1, abi_long arg2,
- abi_long arg3, abi_long arg4, abi_long arg5)
- {
- print_syscall_prologue(name);
- print_raw_param("%d", arg0, 0);
- print_signal(arg1, 1);
- print_syscall_epilogue(name);
- }
- #endif
- #ifdef TARGET_NR_tgkill
- static void
- print_tgkill(CPUArchState *cpu_env, const struct syscallname *name,
- abi_long arg0, abi_long arg1, abi_long arg2,
- abi_long arg3, abi_long arg4, abi_long arg5)
- {
- print_syscall_prologue(name);
- print_raw_param("%d", arg0, 0);
- print_raw_param("%d", arg1, 0);
- print_signal(arg2, 1);
- print_syscall_epilogue(name);
- }
- #endif
- #ifdef TARGET_NR_statx
- static void
- print_statx(CPUArchState *cpu_env, const struct syscallname *name,
- abi_long arg0, abi_long arg1, abi_long arg2,
- abi_long arg3, abi_long arg4, abi_long arg5)
- {
- print_syscall_prologue(name);
- print_at_dirfd(arg0, 0);
- print_string(arg1, 0);
- print_flags(statx_flags, arg2, 0);
- print_flags(statx_mask, arg3, 0);
- print_pointer(arg4, 1);
- print_syscall_epilogue(name);
- }
- #endif
- #ifdef TARGET_NR_ioctl
- static void
- print_ioctl(CPUArchState *cpu_env, const struct syscallname *name,
- abi_long arg0, abi_long arg1, abi_long arg2,
- abi_long arg3, abi_long arg4, abi_long arg5)
- {
- print_syscall_prologue(name);
- print_raw_param("%d", arg0, 0);
- const IOCTLEntry *ie;
- const argtype *arg_type;
- void *argptr;
- int target_size;
- for (ie = ioctl_entries; ie->target_cmd != 0; ie++) {
- if (ie->target_cmd == arg1) {
- break;
- }
- }
- if (ie->target_cmd == 0) {
- print_raw_param("%#x", arg1, 0);
- print_raw_param("%#x", arg2, 1);
- } else {
- qemu_log("%s", ie->name);
- arg_type = ie->arg_type;
- if (arg_type[0] != TYPE_NULL) {
- qemu_log(",");
- switch (arg_type[0]) {
- case TYPE_PTRVOID:
- print_pointer(arg2, 1);
- break;
- case TYPE_CHAR:
- case TYPE_SHORT:
- case TYPE_INT:
- print_raw_param("%d", arg2, 1);
- break;
- case TYPE_LONG:
- print_raw_param(TARGET_ABI_FMT_ld, arg2, 1);
- break;
- case TYPE_ULONG:
- print_raw_param(TARGET_ABI_FMT_lu, arg2, 1);
- break;
- case TYPE_PTR:
- switch (ie->access) {
- case IOC_R:
- print_pointer(arg2, 1);
- break;
- case IOC_W:
- case IOC_RW:
- arg_type++;
- target_size = thunk_type_size(arg_type, 0);
- argptr = lock_user(VERIFY_READ, arg2, target_size, 1);
- if (argptr) {
- thunk_print(argptr, arg_type);
- unlock_user(argptr, arg2, target_size);
- } else {
- print_pointer(arg2, 1);
- }
- break;
- }
- break;
- default:
- g_assert_not_reached();
- }
- }
- }
- print_syscall_epilogue(name);
- }
- #endif
- /*
- * An array of all of the syscalls we know about
- */
- static const struct syscallname scnames[] = {
- #include "strace.list"
- };
- static int nsyscalls = ARRAY_SIZE(scnames);
- /*
- * The public interface to this module.
- */
- void
- print_syscall(CPUArchState *cpu_env, int num,
- abi_long arg1, abi_long arg2, abi_long arg3,
- abi_long arg4, abi_long arg5, abi_long arg6)
- {
- int i;
- FILE *f;
- const char *format = "%s(" TARGET_ABI_FMT_ld "," TARGET_ABI_FMT_ld ","
- TARGET_ABI_FMT_ld "," TARGET_ABI_FMT_ld ","
- TARGET_ABI_FMT_ld "," TARGET_ABI_FMT_ld ")";
- f = qemu_log_trylock();
- if (!f) {
- return;
- }
- fprintf(f, "%d ", getpid());
- for (i = 0; i < nsyscalls; i++) {
- if (scnames[i].nr == num) {
- if (scnames[i].call != NULL) {
- scnames[i].call(cpu_env, &scnames[i], arg1, arg2, arg3,
- arg4, arg5, arg6);
- } else {
- /* XXX: this format system is broken because it uses
- host types and host pointers for strings */
- if (scnames[i].format != NULL) {
- format = scnames[i].format;
- }
- fprintf(f, format, scnames[i].name, arg1, arg2,
- arg3, arg4, arg5, arg6);
- }
- qemu_log_unlock(f);
- return;
- }
- }
- fprintf(f, "Unknown syscall %d\n", num);
- qemu_log_unlock(f);
- }
- void
- print_syscall_ret(CPUArchState *cpu_env, int num, abi_long ret,
- abi_long arg1, abi_long arg2, abi_long arg3,
- abi_long arg4, abi_long arg5, abi_long arg6)
- {
- int i;
- FILE *f;
- f = qemu_log_trylock();
- if (!f) {
- return;
- }
- for (i = 0; i < nsyscalls; i++) {
- if (scnames[i].nr == num) {
- if (scnames[i].result != NULL) {
- scnames[i].result(cpu_env, &scnames[i], ret,
- arg1, arg2, arg3,
- arg4, arg5, arg6);
- } else {
- if (!print_syscall_err(ret)) {
- fprintf(f, TARGET_ABI_FMT_ld, ret);
- }
- fprintf(f, "\n");
- }
- break;
- }
- }
- qemu_log_unlock(f);
- }
- void print_taken_signal(int target_signum, const target_siginfo_t *tinfo)
- {
- /* Print the strace output for a signal being taken:
- * --- SIGSEGV {si_signo=SIGSEGV, si_code=SI_KERNEL, si_addr=0} ---
- */
- FILE *f;
- f = qemu_log_trylock();
- if (!f) {
- return;
- }
- fprintf(f, "--- ");
- print_signal(target_signum, 1);
- fprintf(f, " ");
- print_siginfo(tinfo);
- fprintf(f, " ---\n");
- qemu_log_unlock(f);
- }
|